Skip to content

Commit 71f290b

Browse files
committed
Merge branch 'wasmtime-merge' of https://github.com/alexcrichton/wizer into wizer-inert
2 parents 3c93e2b + a94726c commit 71f290b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+9908
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# binary-compatible-builds
2+
3+
A small (ish) action which is intended to be used and will configure builds of
4+
Rust projects to be "more binary compatible". On Windows and macOS this
5+
involves setting a few env vars, and on Linux this involves spinning up a CentOS
6+
6 container which is running in the background.
7+
8+
All subsequent build commands need to be wrapped in `$CENTOS` to optionally run
9+
on `$CENTOS` on Linux to ensure builds happen inside the container.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: 'Set up a CentOS 6 container to build releases in'
2+
description: 'Set up a CentOS 6 container to build releases in'
3+
4+
runs:
5+
using: node20
6+
main: 'main.js'
7+
inputs:
8+
name:
9+
required: true
10+
description: "Name of the build"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env node
2+
3+
const child_process = require('child_process');
4+
const stdio = { stdio: 'inherit' };
5+
const fs = require('fs');
6+
7+
function set_env(name, val) {
8+
fs.appendFileSync(process.env['GITHUB_ENV'], `${name}=${val}\n`)
9+
}
10+
11+
// On OSX all we need to do is configure our deployment target as old as
12+
// possible. For now 10.9 is the limit.
13+
if (process.platform == 'darwin') {
14+
set_env("MACOSX_DEPLOYMENT_TARGET", "10.9");
15+
return;
16+
}
17+
18+
// On Windows we build against the static CRT to reduce dll dependencies
19+
if (process.platform == 'win32') {
20+
set_env("RUSTFLAGS", "-Ctarget-feature=+crt-static");
21+
return;
22+
}
23+
24+
// Android doesn't use a container as it's controlled by the installation of the
25+
// SDK/NDK.
26+
if (process.env.INPUT_NAME && process.env.INPUT_NAME.indexOf("android") >= 0) {
27+
return;
28+
}
29+
30+
// ... and on Linux we do fancy things with containers. We'll spawn an old
31+
// CentOS container in the background with a super old glibc, and then we'll run
32+
// commands in there with the `$CENTOS` env var.
33+
34+
if (process.env.CENTOS !== undefined) {
35+
const args = ['exec', '-w', process.cwd(), '-i', 'build-container'];
36+
for (const arg of process.argv.slice(2)) {
37+
args.push(arg);
38+
}
39+
child_process.execFileSync('docker', args, stdio);
40+
return;
41+
}
42+
43+
const name = process.env.INPUT_NAME.replace(/-min$/, '');
44+
45+
child_process.execFileSync('docker', [
46+
'build',
47+
'--tag', 'build-image',
48+
`${process.cwd()}/ci/docker/${name}`
49+
], stdio);
50+
51+
child_process.execFileSync('docker', [
52+
'run',
53+
'--detach',
54+
'--interactive',
55+
'--name', 'build-container',
56+
'-v', `${process.cwd()}:${process.cwd()}`,
57+
'-v', `${child_process.execSync('rustc --print sysroot').toString().trim()}:/rust:ro`,
58+
'build-image',
59+
], stdio);
60+
61+
// Use ourselves to run future commands
62+
set_env("CENTOS", __filename);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# install-rust
2+
3+
A small github action to install `rustup` and a Rust toolchain. This is
4+
generally expressed inline, but it was repeated enough in this repository it
5+
seemed worthwhile to extract.
6+
7+
Some gotchas:
8+
9+
* Can't `--self-update` on Windows due to permission errors (a bug in Github
10+
Actions)
11+
* `rustup` isn't installed on macOS (a bug in Github Actions)
12+
13+
When the above are fixed we should delete this action and just use this inline:
14+
15+
```yml
16+
- run: rustup update $toolchain && rustup default $toolchain
17+
shell: bash
18+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: 'Install Rust toolchain'
2+
description: 'Install both `rustup` and a Rust toolchain'
3+
4+
inputs:
5+
toolchain:
6+
description: 'Default toolchan to install'
7+
required: false
8+
default: 'stable'
9+
10+
runs:
11+
using: node12
12+
main: 'main.js'
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const child_process = require('child_process');
2+
const toolchain = process.env.INPUT_TOOLCHAIN;
3+
const fs = require('fs');
4+
5+
function set_env(name, val) {
6+
fs.appendFileSync(process.env['GITHUB_ENV'], `${name}=${val}\n`)
7+
}
8+
9+
// Needed for now to get 1.24.2 which fixes a bug in 1.24.1 that causes issues
10+
// on Windows.
11+
if (process.platform === 'win32') {
12+
child_process.execFileSync('rustup', ['self', 'update']);
13+
}
14+
15+
child_process.execFileSync('rustup', ['set', 'profile', 'minimal']);
16+
child_process.execFileSync('rustup', ['update', toolchain, '--no-self-update']);
17+
child_process.execFileSync('rustup', ['default', toolchain]);
18+
19+
// Deny warnings on CI to keep our code warning-free as it lands in-tree. Don't
20+
// do this on nightly though since there's a fair amount of warning churn there.
21+
if (!toolchain.startsWith('nightly')) {
22+
set_env("RUSTFLAGS", "-D warnings");
23+
}
24+
25+
// Save disk space by avoiding incremental compilation, and also we don't use
26+
// any caching so incremental wouldn't help anyway.
27+
set_env("CARGO_INCREMENTAL", "0");
28+
29+
// Turn down debuginfo from 2 to 1 to help save disk space
30+
set_env("CARGO_PROFILE_DEV_DEBUG", "1");
31+
set_env("CARGO_PROFILE_TEST_DEBUG", "1");
32+
33+
if (process.platform === 'darwin') {
34+
set_env("CARGO_PROFILE_DEV_SPLIT_DEBUGINFO", "unpacked");
35+
set_env("CARGO_PROFILE_TEST_SPLIT_DEBUGINFO", "unpacked");
36+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI
2+
3+
on: pull_request
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
8+
jobs:
9+
build:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
include:
14+
- build: x86_64-linux
15+
os: ubuntu-latest
16+
- build: x86_64-macos
17+
os: macos-latest
18+
target: x86_64-apple-darwin
19+
- build: aarch64-macos
20+
os: macos-latest
21+
target: aarch64-apple-darwin
22+
- build: x86_64-windows
23+
os: windows-latest
24+
- build: x86_64-mingw
25+
os: windows-latest
26+
target: x86_64-pc-windows-gnu
27+
- build: aarch64-linux
28+
os: ubuntu-latest
29+
target: aarch64-unknown-linux-gnu
30+
- build: s390x-linux
31+
os: ubuntu-latest
32+
target: s390x-unknown-linux-gnu
33+
steps:
34+
- uses: actions/checkout@v2
35+
- name: Build
36+
run: cargo build --verbose
37+
- name: Run tests
38+
run: cargo test --verbose
39+
- name: Checking benches
40+
run : cargo check --benches
41+
42+
check_fuzz:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v2
46+
- run: cargo install cargo-fuzz
47+
- run: cargo fuzz build --dev -s none
48+
49+
rustfmt:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v2
53+
- run: rustup update stable --no-self-update
54+
- run: rustup default stable
55+
- run: rustup component add rustfmt
56+
- run: cargo fmt --all -- --check
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Release
2+
on:
3+
push:
4+
branches: [main]
5+
tags-ignore: [dev]
6+
pull_request:
7+
defaults:
8+
run:
9+
shell: bash
10+
11+
permissions: write-all
12+
13+
# Cancel any in-flight jobs for the same PR/branch so there's only one active
14+
# at a time
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
build:
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
include:
25+
- build: x86_64-linux
26+
os: ubuntu-latest
27+
- build: x86_64-macos
28+
os: macos-latest
29+
target: x86_64-apple-darwin
30+
- build: aarch64-macos
31+
os: macos-latest
32+
target: aarch64-apple-darwin
33+
- build: x86_64-windows
34+
os: windows-latest
35+
- build: x86_64-mingw
36+
os: windows-latest
37+
target: x86_64-pc-windows-gnu
38+
- build: aarch64-linux
39+
os: ubuntu-latest
40+
target: aarch64-unknown-linux-gnu
41+
- build: s390x-linux
42+
os: ubuntu-latest
43+
target: s390x-unknown-linux-gnu
44+
steps:
45+
- uses: actions/checkout@v2
46+
with:
47+
submodules: true
48+
- uses: ./.github/actions/install-rust
49+
- uses: ./.github/actions/binary-compatible-builds
50+
with:
51+
name: ${{ matrix.build }}
52+
- run: |
53+
echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
54+
rustup target add ${{ matrix.target }}
55+
if: matrix.target != ''
56+
57+
# Build `wizer` and executables
58+
- run: $CENTOS cargo build --release --locked --bin wizer --all-features
59+
60+
# Assemble release artifats appropriate for this platform, then upload them
61+
# unconditionally to this workflow's files so we have a copy of them.
62+
- run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}"
63+
- uses: actions/upload-artifact@v4
64+
with:
65+
name: bins-${{ matrix.build }}
66+
path: dist
67+
publish:
68+
needs: [build]
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: actions/checkout@v2
72+
# Download all the artifacts that we'll be publishing. Should keep an eye on
73+
# the `download-artifact` repository to see if we can ever get something
74+
# like "download all artifacts" or "download this list of artifacts"
75+
- uses: actions/download-artifact@v4
76+
with:
77+
name: bins-x86_64-macos
78+
path: dist
79+
- uses: actions/download-artifact@v4
80+
with:
81+
name: bins-aarch64-macos
82+
path: dist
83+
- uses: actions/download-artifact@v4
84+
with:
85+
name: bins-x86_64-windows
86+
path: dist
87+
- uses: actions/download-artifact@v4
88+
with:
89+
name: bins-x86_64-mingw
90+
path: dist
91+
- uses: actions/download-artifact@v4
92+
with:
93+
name: bins-x86_64-linux
94+
path: dist
95+
- uses: actions/download-artifact@v4
96+
with:
97+
name: bins-aarch64-linux
98+
path: dist
99+
- uses: actions/download-artifact@v4
100+
with:
101+
name: bins-s390x-linux
102+
path: dist
103+
104+
- name: Calculate tag name
105+
run: |
106+
name=dev
107+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
108+
name=${GITHUB_REF:10}
109+
fi
110+
echo ::set-output name=val::$name
111+
echo TAG=$name >> $GITHUB_ENV
112+
id: tagname
113+
114+
# ... and if this was an actual push (tag or `main`) then we publish a
115+
# new release. This'll automatically publish a tag release or update `dev`
116+
# with this `sha`. Note that `continue-on-error` is set here so if this hits
117+
# a bug we can go back and fetch and upload the release ourselves.
118+
- run: cd .github/actions/github-release && npm install --production
119+
- name: Publish Release
120+
uses: ./.github/actions/github-release
121+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
122+
with:
123+
files: "dist/*"
124+
token: ${{ secrets.GITHUB_TOKEN }}
125+
name: ${{ steps.tagname.outputs.val }}
126+
continue-on-error: true
127+
- name: Update npm packages to latest version
128+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
129+
working-directory: ./npm/wizer
130+
run: npm install && node update.js "${{ steps.tagname.outputs.val }}"
131+
- name: Setup npm auth
132+
run: sudo npm config --global set '//registry.npmjs.org/:_authToken'='${NODE_AUTH_TOKEN}'
133+
- name: Publish npm packages
134+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
135+
working-directory: ./npm
136+
env:
137+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
138+
run: for dir in *; do (echo $dir && cd $dir && npm publish); done

crates/wizer/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/target
2+
node_modules
3+
npm/wizer-darwin-arm64/
4+
npm/wizer-darwin-x64/
5+
npm/wizer-linux-x64/
6+
npm/wizer-win32-x64/
7+
npm/wizer-linux-s390x/
8+
npm/wizer-linux-arm64/

crates/wizer/.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "benches/uap-bench/uap-core"]
2+
path = benches/uap-bench/uap-core
3+
url = https://github.com/ua-parser/uap-core.git

0 commit comments

Comments
 (0)