Optimisations #404
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| branches: | |
| - main | |
| pull_request: | |
| permissions: | |
| checks: write | |
| pull-requests: write | |
| contents: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| WASI_SDK_VERSION: "25" | |
| WASI_SDK_PATH: /opt/wasi-sdk | |
| # CI always builds and tests against Golem's wasmtime fork — see | |
| # .github/scripts/enable-wasmtime-fork.sh for the rationale. Build/test | |
| # jobs run that script (which uncomments the [patch.crates-io] block in | |
| # Cargo.toml) and pass --features use-golem-wasmtime via this variable. | |
| # The `release-binaries` and `publish` jobs deliberately skip both so | |
| # they keep using the unpatched, crates.io-publishable wasmtime. | |
| CI_WASMTIME_FORK_FEATURES: --features use-golem-wasmtime | |
| jobs: | |
| build: | |
| runs-on: blacksmith-16vcpu-ubuntu-2404 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - uses: ./.github/actions/setup | |
| - name: Enable Golem wasmtime fork | |
| run: bash .github/scripts/enable-wasmtime-fork.sh | |
| - name: Check formatting | |
| run: cargo fmt -- --check | |
| - name: Clippy | |
| run: cargo clippy $CI_WASMTIME_FORK_FEATURES -- -Dwarnings | |
| - name: Build | |
| run: cargo build --all-targets $CI_WASMTIME_FORK_FEATURES | |
| test-other: | |
| needs: [build] | |
| runs-on: blacksmith-16vcpu-ubuntu-2404 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - uses: ./.github/actions/setup | |
| - name: Enable Golem wasmtime fork | |
| run: bash .github/scripts/enable-wasmtime-fork.sh | |
| - name: Compilation, DTS and error tests | |
| run: cargo test --test compilation --test dts --test errors $CI_WASMTIME_FORK_FEATURES -- --report-time --format ctrf --logfile target/ctrf.json | |
| - name: Publish Test Report | |
| uses: ctrf-io/github-test-reporter@v1 | |
| if: always() | |
| with: | |
| report-path: "**/target/ctrf-*.json" | |
| upload-artifact: "true" | |
| artifact-name: test-other-report | |
| summary: true | |
| summary-report: true | |
| failed-report: true | |
| slowest-report: true | |
| github-report: true | |
| flaky-report: true | |
| collapse-large-reports: true | |
| exit-on-no-files: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| test-runtime: | |
| needs: [build] | |
| runs-on: blacksmith-16vcpu-ubuntu-2404 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| group: [1, 2, 3, 4, 5, 6, 7, 8] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - uses: ./.github/actions/setup | |
| - name: Enable Golem wasmtime fork | |
| run: bash .github/scripts/enable-wasmtime-fork.sh | |
| - name: Runtime tests (group ${{ matrix.group }}/8) | |
| run: cargo test --test runtime $CI_WASMTIME_FORK_FEATURES -- --report-time --format ctrf --logfile target/ctrf.json ':tag:group${{ matrix.group }}' | |
| - name: Publish Test Report | |
| uses: ctrf-io/github-test-reporter@v1 | |
| if: always() | |
| with: | |
| report-path: "**/target/ctrf-*.json" | |
| upload-artifact: "true" | |
| artifact-name: test-runtime-group-${{ matrix.group }}-report | |
| summary: true | |
| summary-report: true | |
| failed-report: true | |
| slowest-report: true | |
| github-report: true | |
| flaky-report: true | |
| collapse-large-reports: true | |
| exit-on-no-files: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| test-node-compat: | |
| needs: [build] | |
| runs-on: blacksmith-16vcpu-ubuntu-2404 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| shard: [0, 1, 2, 3, 4, 5, 6, 7] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - uses: ./.github/actions/setup | |
| - name: Enable Golem wasmtime fork | |
| run: bash .github/scripts/enable-wasmtime-fork.sh | |
| - name: Vendor Node.js test suite | |
| run: bash tests/node_compat/vendor.sh | |
| - name: Node compat tests (shard ${{ matrix.shard }}/8) | |
| run: cargo test --test node_compat $CI_WASMTIME_FORK_FEATURES -- --report-time --format ctrf --logfile target/ctrf.json ':tag:shard${{ matrix.shard }}' | |
| - name: Publish Test Report | |
| uses: ctrf-io/github-test-reporter@v1 | |
| if: always() | |
| with: | |
| report-path: "**/target/ctrf-*.json" | |
| upload-artifact: "true" | |
| artifact-name: test-node-compat-shard-${{ matrix.shard }}-report | |
| summary: true | |
| summary-report: true | |
| failed-report: true | |
| slowest-report: true | |
| github-report: true | |
| flaky-report: true | |
| collapse-large-reports: true | |
| exit-on-no-files: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| release-binaries: | |
| needs: [test-other, test-runtime, test-node-compat] | |
| if: "startsWith(github.ref, 'refs/tags/v')" | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: blacksmith-16vcpu-ubuntu-2404 | |
| archive: tar.gz | |
| - target: aarch64-unknown-linux-gnu | |
| os: blacksmith-16vcpu-ubuntu-2404 | |
| archive: tar.gz | |
| cross: true | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| archive: tar.gz | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| archive: tar.gz | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| archive: zip | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: useblacksmith/rust-cache@v3 | |
| with: | |
| prefix-key: v1-rust | |
| shared-key: release-${{ matrix.target }} | |
| cache-all-crates: true | |
| - id: get_version | |
| uses: battila7/get-version-action@v2 | |
| - name: Set version | |
| shell: bash | |
| run: | | |
| VERSION="${{ steps.get_version.outputs.version-without-v }}" | |
| if [[ "$RUNNER_OS" == "macOS" ]]; then | |
| sed -i '' "s/0.0.0/$VERSION/g" Cargo.toml | |
| else | |
| sed -i "s/0.0.0/$VERSION/g" Cargo.toml | |
| fi | |
| - name: Install cross-compilation tools | |
| if: matrix.cross | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
| - name: Add Rust target | |
| run: rustup target add ${{ matrix.target }} | |
| - name: Build release binary | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package (unix) | |
| if: matrix.archive == 'tar.gz' | |
| shell: bash | |
| run: | | |
| ARCHIVE="wasm-rquickjs-cli-v${{ steps.get_version.outputs.version-without-v }}-${{ matrix.target }}.tar.gz" | |
| tar -czf "$ARCHIVE" -C target/${{ matrix.target }}/release wasm-rquickjs | |
| echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV | |
| - name: Package (windows) | |
| if: matrix.archive == 'zip' | |
| shell: bash | |
| run: | | |
| ARCHIVE="wasm-rquickjs-cli-v${{ steps.get_version.outputs.version-without-v }}-${{ matrix.target }}.zip" | |
| cd target/${{ matrix.target }}/release | |
| 7z a "../../../$ARCHIVE" wasm-rquickjs.exe | |
| cd ../../.. | |
| echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV | |
| - name: Upload release asset | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: ${{ env.ARCHIVE }} | |
| publish: | |
| needs: [test-other, test-runtime, test-node-compat] | |
| if: "startsWith(github.ref, 'refs/tags/v')" | |
| runs-on: blacksmith-16vcpu-ubuntu-2404 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - uses: ./.github/actions/setup | |
| with: | |
| cache-key: release | |
| - id: get_version | |
| uses: battila7/get-version-action@v2 | |
| - name: Publish crates | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| run: | | |
| export VERSION="${{ steps.get_version.outputs.version-without-v }}" | |
| sed -i "s/0.0.0/$VERSION/g" Cargo.toml | |
| cargo publish -p wasm-rquickjs --features optimize --allow-dirty | |
| cargo publish -p wasm-rquickjs-cli --allow-dirty |