WASM / PR 38 #183
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: WASM | |
| run-name: WASM / ${{ github.event_name == 'workflow_dispatch' && inputs.target || (github.event_name == 'pull_request' && format('PR {0}', github.event.pull_request.number) || github.ref_name) }} | |
| on: | |
| pull_request: | |
| push: | |
| branches: [main] | |
| paths: | |
| - ".github/workflows/assets.yml" | |
| - ".github/actions/setup-wasmer-llvm/**" | |
| - "Cargo.lock" | |
| - "Cargo.toml" | |
| - "src/postgres18/**" | |
| - "src/third-party/**" | |
| - "src/extensions/**" | |
| - "src/oliphaunt-wasm/assets/wasix-build/**" | |
| - "src/oliphaunt-wasm/crates/oliphaunt-wasm/Cargo.toml" | |
| - "src/oliphaunt-wasm/crates/aot/**" | |
| - "src/oliphaunt-wasm/crates/oliphaunt-wasm-assets/**" | |
| - "tools/xtask/**" | |
| workflow_dispatch: | |
| inputs: | |
| target: | |
| description: WASM AOT target to build | |
| required: true | |
| default: all | |
| type: choice | |
| options: | |
| - all | |
| - aarch64-apple-darwin | |
| - x86_64-unknown-linux-gnu | |
| - aarch64-unknown-linux-gnu | |
| - x86_64-pc-windows-msvc | |
| schedule: | |
| - cron: "17 3 * * 1" | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: wasm-runtime-${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}-${{ inputs.target || 'all' }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| ASSET_PROFILE: release | |
| RUST_CACHE_SAVE_IF: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
| WASMER_LLVM_VERSION: "22.1" | |
| WASMER_LLVM_LINUX_X64_URL: https://github.com/wasmerio/llvm-custom-builds/releases/download/22.x/llvm-linux-amd64.tar.xz | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| runtime-plan: | |
| name: runtime-plan | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| outputs: | |
| runtime_portable_required: ${{ steps.plan.outputs.wasm_runtime_portable_required }} | |
| reason: ${{ steps.plan.outputs.reason }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| persist-credentials: false | |
| - name: Set up Moon | |
| uses: ./.github/actions/setup-moon | |
| with: | |
| install-workspace: "false" | |
| - name: Plan WASM runtime producer work | |
| id: plan | |
| env: | |
| GITHUB_EVENT_NAME: ${{ github.event_name }} | |
| MOON_BASE: ${{ github.event.pull_request.base.sha }} | |
| MOON_HEAD: ${{ github.event.pull_request.head.sha }} | |
| run: python3 .github/scripts/plan-affected.py | |
| runtime-inputs: | |
| name: runtime-inputs | |
| if: ${{ github.event_name == 'pull_request' }} | |
| needs: | |
| - runtime-plan | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up Rust | |
| uses: ./.github/actions/setup-rust | |
| with: | |
| cache-save-if: ${{ env.RUST_CACHE_SAVE_IF }} | |
| - name: Set up Moon | |
| uses: ./.github/actions/setup-moon | |
| - name: Run affected WASM runtime-input checks | |
| env: | |
| MOON_BASE: ${{ github.event.pull_request.base.sha }} | |
| MOON_HEAD: ${{ github.event.pull_request.head.sha }} | |
| run: | | |
| .github/scripts/run-moon-ci.sh \ | |
| postgres18:check \ | |
| third-party:check \ | |
| extensions:check \ | |
| oliphaunt-wasm:release-check | |
| wasm-runtime-portable: | |
| name: runtime-portable | |
| if: ${{ needs.runtime-plan.outputs.runtime_portable_required == 'true' }} | |
| needs: | |
| - runtime-plan | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 360 | |
| permissions: | |
| contents: read | |
| actions: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up Rust | |
| uses: ./.github/actions/setup-rust | |
| with: | |
| cache-save-if: ${{ env.RUST_CACHE_SAVE_IF }} | |
| - name: Verify source-controlled asset inputs | |
| run: cargo run -p xtask -- assets verify-committed | |
| - name: Fetch pinned asset sources | |
| run: cargo run -p xtask -- assets fetch | |
| - name: Restore WASIX compilation cache | |
| id: wasix-build-cache | |
| uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 | |
| with: | |
| path: | | |
| target/liboliphaunt-pg18/source | |
| target/oliphaunt-wasm/wasix-build/source-cache | |
| target/oliphaunt-wasm/wasix-build/work/docker-oliphaunt | |
| target/oliphaunt-wasm/wasix-build/work/icu-native | |
| target/oliphaunt-wasm/wasix-build/work/icu-wasix | |
| target/oliphaunt-wasm/wasix-build/work/icu-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/json-c-wasix | |
| target/oliphaunt-wasm/wasix-build/work/json-c-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/libiconv-wasix | |
| target/oliphaunt-wasm/wasix-build/work/libiconv-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/libxml2-wasix | |
| target/oliphaunt-wasm/wasix-build/work/libxml2-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/openssl-wasix | |
| target/oliphaunt-wasm/wasix-build/work/openssl-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/proj-wasix | |
| target/oliphaunt-wasm/wasix-build/work/proj-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/sqlite-wasix | |
| target/oliphaunt-wasm/wasix-build/work/sqlite-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/geos-wasix | |
| target/oliphaunt-wasm/wasix-build/work/geos-wasix-build | |
| target/oliphaunt-wasm/wasix-build/build | |
| key: wasix-build-${{ runner.os }}-${{ env.ASSET_PROFILE }}-${{ hashFiles('src/oliphaunt-wasm/assets/generated/asset-inputs.sha256', 'src/postgres18/**', 'src/third-party/**', 'src/extensions/**', 'src/oliphaunt-wasm/assets/wasix-build/**', 'src/oliphaunt-wasm/crates/oliphaunt-wasm/Cargo.toml', 'src/oliphaunt-wasm/crates/oliphaunt-wasm-assets/**', 'tools/xtask/**', 'Cargo.toml', 'Cargo.lock') }} | |
| restore-keys: | | |
| wasix-build-${{ runner.os }}-${{ env.ASSET_PROFILE }}- | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd | |
| - name: Build WASIX builder image and save cache | |
| if: ${{ github.ref == 'refs/heads/main' }} | |
| uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f | |
| with: | |
| context: src/oliphaunt-wasm/assets/wasix-build/docker | |
| file: src/oliphaunt-wasm/assets/wasix-build/docker/Dockerfile | |
| tags: oliphaunt-wasm-wasix-build:ci | |
| load: true | |
| cache-from: type=gha,scope=wasix-builder | |
| cache-to: type=gha,mode=max,scope=wasix-builder | |
| - name: Build WASIX builder image | |
| if: ${{ github.ref != 'refs/heads/main' }} | |
| uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f | |
| with: | |
| context: src/oliphaunt-wasm/assets/wasix-build/docker | |
| file: src/oliphaunt-wasm/assets/wasix-build/docker/Dockerfile | |
| tags: oliphaunt-wasm-wasix-build:ci | |
| load: true | |
| cache-from: type=gha,scope=wasix-builder | |
| - name: Install Wasmer LLVM 22.1 for WASIX template generation | |
| uses: ./.github/actions/setup-wasmer-llvm | |
| with: | |
| url: ${{ env.WASMER_LLVM_LINUX_X64_URL }} | |
| version: ${{ env.WASMER_LLVM_VERSION }} | |
| cache-save-if: ${{ env.RUST_CACHE_SAVE_IF }} | |
| - name: Build portable WASIX modules and package runtime assets | |
| env: | |
| IMAGE: oliphaunt-wasm-wasix-build:ci | |
| run: | | |
| cargo run -p xtask --features template-runner -- assets release-build \ | |
| --profile "$ASSET_PROFILE" \ | |
| --target-triple x86_64-unknown-linux-gnu \ | |
| --skip-aot \ | |
| --skip-package-size | |
| - name: Validate generated portable assets | |
| run: cargo run -p xtask -- assets check --strict-generated | |
| - name: Save WASIX compilation cache | |
| if: ${{ github.ref == 'refs/heads/main' && steps.wasix-build-cache.outputs.cache-hit != 'true' }} | |
| uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 | |
| with: | |
| path: | | |
| target/liboliphaunt-pg18/source | |
| target/oliphaunt-wasm/wasix-build/source-cache | |
| target/oliphaunt-wasm/wasix-build/work/docker-oliphaunt | |
| target/oliphaunt-wasm/wasix-build/work/icu-native | |
| target/oliphaunt-wasm/wasix-build/work/icu-wasix | |
| target/oliphaunt-wasm/wasix-build/work/icu-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/json-c-wasix | |
| target/oliphaunt-wasm/wasix-build/work/json-c-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/libiconv-wasix | |
| target/oliphaunt-wasm/wasix-build/work/libiconv-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/libxml2-wasix | |
| target/oliphaunt-wasm/wasix-build/work/libxml2-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/openssl-wasix | |
| target/oliphaunt-wasm/wasix-build/work/openssl-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/proj-wasix | |
| target/oliphaunt-wasm/wasix-build/work/proj-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/sqlite-wasix | |
| target/oliphaunt-wasm/wasix-build/work/sqlite-wasix-build | |
| target/oliphaunt-wasm/wasix-build/work/geos-wasix | |
| target/oliphaunt-wasm/wasix-build/work/geos-wasix-build | |
| target/oliphaunt-wasm/wasix-build/build | |
| key: wasix-build-${{ runner.os }}-${{ env.ASSET_PROFILE }}-${{ hashFiles('src/oliphaunt-wasm/assets/generated/asset-inputs.sha256', 'src/postgres18/**', 'src/third-party/**', 'src/extensions/**', 'src/oliphaunt-wasm/assets/wasix-build/**', 'src/oliphaunt-wasm/crates/oliphaunt-wasm/Cargo.toml', 'src/oliphaunt-wasm/crates/oliphaunt-wasm-assets/**', 'tools/xtask/**', 'Cargo.toml', 'Cargo.lock') }} | |
| - name: Upload portable WASIX build outputs | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: oliphaunt-wasm-runtime-portable | |
| path: | | |
| target/oliphaunt-wasm/wasix-build/build/** | |
| target/oliphaunt-wasm/assets/** | |
| src/extensions/generated/** | |
| src/oliphaunt-wasm/assets/generated/** | |
| if-no-files-found: error | |
| wasm-runtime-targets: | |
| name: aot-targets | |
| if: ${{ needs.runtime-plan.outputs.runtime_portable_required == 'true' }} | |
| needs: | |
| - runtime-plan | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| outputs: | |
| matrix: ${{ steps.targets.outputs.matrix }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| with: | |
| persist-credentials: false | |
| - name: Set up Rust | |
| uses: ./.github/actions/setup-rust | |
| with: | |
| cache-save-if: ${{ env.RUST_CACHE_SAVE_IF }} | |
| - name: Build target matrix | |
| id: targets | |
| env: | |
| REQUESTED_TARGET: ${{ github.event_name == 'workflow_dispatch' && inputs.target || 'all' }} | |
| run: cargo run --quiet -p xtask -- assets ci-matrix --target "$REQUESTED_TARGET" --github-output >> "$GITHUB_OUTPUT" | |
| wasm-runtime-aot: | |
| name: aot-${{ matrix.target }} | |
| if: ${{ needs.runtime-plan.outputs.runtime_portable_required == 'true' }} | |
| needs: | |
| - runtime-plan | |
| - wasm-runtime-portable | |
| - wasm-runtime-targets | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 180 | |
| permissions: | |
| contents: read | |
| actions: write | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.wasm-runtime-targets.outputs.matrix || '{"include":[]}') }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up Rust | |
| uses: ./.github/actions/setup-rust | |
| with: | |
| cache-save-if: ${{ env.RUST_CACHE_SAVE_IF }} | |
| - name: Download portable WASIX build outputs | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c | |
| with: | |
| name: oliphaunt-wasm-runtime-portable | |
| path: . | |
| - name: Install Wasmer LLVM 22.1 for AOT generation | |
| uses: ./.github/actions/setup-wasmer-llvm | |
| with: | |
| url: ${{ matrix.llvm_url }} | |
| version: ${{ env.WASMER_LLVM_VERSION }} | |
| cache-save-if: ${{ env.RUST_CACHE_SAVE_IF }} | |
| - name: Generate and package target AOT artifacts | |
| env: | |
| AOT_TARGET: ${{ matrix.target }} | |
| run: | | |
| cargo run -p xtask -- assets aot --target-triple "$AOT_TARGET" | |
| cargo run -p xtask -- assets package-aot --target-triple "$AOT_TARGET" | |
| cargo run -p xtask -- assets check-aot --target-triple "$AOT_TARGET" | |
| - name: Check target AOT crate | |
| env: | |
| AOT_PACKAGE: ${{ matrix.package }} | |
| run: cargo check -p "$AOT_PACKAGE" --locked | |
| - name: Run asset smoke tests | |
| run: cargo run -p xtask -- assets smoke | |
| - name: Upload target artifacts | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: oliphaunt-wasm-runtime-aot-${{ matrix.target }} | |
| path: | | |
| target/oliphaunt-wasm/aot/${{ matrix.target }}/** | |
| if-no-files-found: error |