coordinator/tributary tests #1142
Workflow file for this run
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: Reproducible Runtime | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - next | |
| paths: | |
| - "Cargo.lock" | |
| - "common/**" | |
| - "crypto/**" | |
| - "substrate/**" | |
| - "orchestration/runtime/**" | |
| - "tests/reproducible-runtime/**" | |
| pull_request: | |
| paths: | |
| - "Cargo.lock" | |
| - "common/**" | |
| - "crypto/**" | |
| - "substrate/**" | |
| - "orchestration/runtime/**" | |
| - "tests/reproducible-runtime/**" | |
| workflow_dispatch: | |
| jobs: | |
| # Do one run to determine what the hash of the runtime _should_ be | |
| # Any host is valid for this as they _should_ all give the same result | |
| source_of_truth: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| hash: ${{ steps.build.outputs.hash }} | |
| steps: | |
| - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0 | |
| - name: Install Build Dependencies | |
| uses: ./.github/actions/build-dependencies | |
| - name: Run Reproducible Runtime tests on the Source of Truth | |
| id: build | |
| shell: bash | |
| run: | | |
| # Allow the following command to fail | |
| set +e | |
| # Capture the output to `stdout.txt` | |
| cargo test --all-features -p serai-reproducible-runtime-tests -- --nocapture | tee stdout.txt | |
| CODE=$? | |
| # Check the exit code from `cargo` | |
| if [ $CODE -ne 0 ]; then | |
| exit $CODE | |
| fi | |
| # Restore `set -e` | |
| set -e | |
| HASH="$(grep -F 'Hash: ' stdout.txt | cut -d' ' -f2)" | |
| if [ $(printf "%s" "$HASH" | wc -c) -ne 64 ]; then | |
| echo "Hash not found in output of the \`reproducible-runtime\` test" | |
| exit 1 | |
| fi | |
| printf 'hash=%s\n' "$HASH" >> "$GITHUB_OUTPUT" | |
| # Run (mostly) the same job, but for _all_ of the hosts we want to test this with | |
| build: | |
| strategy: | |
| matrix: | |
| # Unfortunately, we do not run this on `macos-latest` at this time due to it being too slow | |
| os: [macos-26-intel, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| needs: source_of_truth | |
| steps: | |
| - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0 | |
| - name: Install Build Dependencies | |
| uses: ./.github/actions/build-dependencies | |
| - name: Run Reproducible Runtime tests | |
| env: | |
| source_of_truth: ${{ needs.source_of_truth.outputs.hash }} | |
| shell: bash | |
| run: | | |
| # Allow the following command to fail | |
| set +e | |
| # Capture the output to `stdout.txt` | |
| cargo test --all-features -p serai-reproducible-runtime-tests -- --nocapture | tee stdout.txt | |
| CODE=$? | |
| # Check the exit code from `cargo` | |
| if [ $CODE -ne 0 ]; then | |
| exit $CODE | |
| fi | |
| # Restore `set -e` | |
| set -e | |
| HASH="$(grep -F 'Hash: ' stdout.txt | cut -d' ' -f2)" | |
| if [ $(printf "%s" "$HASH" | wc -c) -ne 64 ]; then | |
| echo "Hash not found in output of the \`reproducible-runtime\` test" | |
| exit 1 | |
| fi | |
| # Check this agreed with our source of truth | |
| if [ ! "$HASH" = "$source_of_truth" ]; then | |
| echo "$HASH (OCI) is different from $source_of_truth (Linux-host OCI)" | |
| exit 2 | |
| fi | |
| # Perform the build on the native host, without using an OCI runtime. | |
| # | |
| # This is not guaranteed to work nor endorsed as a build mechanism in any way. It generally | |
| # _should_ work however. Unfortunately, even if it does, it can never be recommended in case it | |
| # doesn't (which there'd be no way to know without also doing it properly, saving no time at all). | |
| build_native: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, macos-26-intel, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| needs: source_of_truth | |
| steps: | |
| - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0 | |
| - name: Install dependencies | |
| shell: bash | |
| if: runner.os == 'Windows' | |
| run: rustup set default-host x86_64-pc-windows-gnu | |
| - name: Build the runtime (natively) | |
| env: | |
| source_of_truth: ${{ needs.source_of_truth.outputs.hash }} | |
| shell: bash | |
| run: | | |
| rustup toolchain install 1.94.0 --profile minimal --component rust-src | |
| cargo +1.94.0 build -p serai-runtime --release --no-default-features | |
| HASH=$(sha256sum $(find ./target -name serai_runtime.wasm | head -n1) | cut -d' ' -f1) | |
| # Check this agreed with our source of truth | |
| if [ ! "$HASH" = "$source_of_truth" ]; then | |
| echo "$HASH (natively-built runtime) is different from $source_of_truth (Linux-host OCI)" | |
| exit 1 | |
| fi |