fix: align sync status heuristic with leanSpec (#417) #16
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: | |
| branches: [main] | |
| pull_request: | |
| branches: ["**"] | |
| workflow_dispatch: | |
| # Cancel in-progress runs when a new commit is pushed to the same PR or branch | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_NET_GIT_FETCH_WITH_CLI: "true" | |
| CARGO_NET_RETRY: "10" | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: "1.92.0" | |
| components: rustfmt, clippy | |
| - name: Setup cache | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Cargo check | |
| run: cargo check --workspace --all-targets | |
| - name: Clippy | |
| run: cargo clippy --workspace --all-targets -- -D warnings | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Get leanSpec fixtures release info | |
| id: fixtures-release | |
| run: | | |
| api_url="https://api.github.com/repos/leanEthereum/leanSpec/releases/latest" | |
| json=$(curl -sL "$api_url") | |
| fixtures_url=$(echo "$json" | python3 -c "import sys,json; j=json.load(sys.stdin); print(next(a.get('browser_download_url') for a in j.get('assets',[]) if a.get('name')=='fixtures-prod-scheme.tar.gz'))") | |
| sha_url=$(echo "$json" | python3 -c "import sys,json; j=json.load(sys.stdin); print(next(a.get('browser_download_url') for a in j.get('assets',[]) if a.get('name')=='fixtures-prod-scheme.tar.gz.sha256'))") | |
| sha=$(curl -sL "$sha_url" | cut -d' ' -f1) | |
| { | |
| echo "url=$fixtures_url" | |
| echo "sha_url=$sha_url" | |
| echo "sha=$sha" | |
| } >> $GITHUB_OUTPUT | |
| - name: Restore test fixtures cache | |
| id: cache-fixtures | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: leanSpec/fixtures | |
| key: leanspec-fixtures-${{ steps.fixtures-release.outputs.sha }} | |
| - name: Download leanSpec fixtures release | |
| id: download-fixtures | |
| if: steps.cache-fixtures.outputs.cache-hit != 'true' | |
| run: | | |
| tmpdir=$(mktemp -d) | |
| trap 'rm -rf "$tmpdir"' EXIT | |
| fixtures_url="${{ steps.fixtures-release.outputs.url }}" | |
| sha_url="${{ steps.fixtures-release.outputs.sha_url }}" | |
| echo "Downloading fixtures from $fixtures_url" | |
| curl -L -f -o "$tmpdir/fixtures-prod-scheme.tar.gz" "$fixtures_url" | |
| curl -L -f -o "$tmpdir/fixtures-prod-scheme.tar.gz.sha256" "$sha_url" | |
| expected=$(cut -d' ' -f1 "$tmpdir/fixtures-prod-scheme.tar.gz.sha256") | |
| actual=$(sha256sum "$tmpdir/fixtures-prod-scheme.tar.gz" | awk '{print $1}') | |
| if [ "$expected" != "$actual" ]; then | |
| echo "SHA256 mismatch: expected $expected, got $actual" | |
| exit 1 | |
| fi | |
| rm -rf leanSpec/fixtures | |
| mkdir -p leanSpec/fixtures | |
| tar -xzf "$tmpdir/fixtures-prod-scheme.tar.gz" -C leanSpec/fixtures --strip-components=1 | |
| # Save fixtures only when the download actually SUCCEEDED, so a | |
| # cancelled or failed download never persists a partial fixture set, | |
| # while still saving even if the later Rust test step fails. | |
| - name: Save test fixtures cache | |
| if: >- | |
| always() | |
| && steps.cache-fixtures.outputs.cache-hit != 'true' | |
| && steps.download-fixtures.outcome == 'success' | |
| uses: actions/cache/save@v5 | |
| with: | |
| path: leanSpec/fixtures | |
| key: ${{ steps.cache-fixtures.outputs.cache-primary-key }} | |
| # Ensure make sees fixtures as up-to-date (its timestamp must be | |
| # newer than leanSpec/, which intermediate steps may have modified). | |
| - name: Mark fixtures as up-to-date | |
| run: touch leanSpec/fixtures | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: "1.92.0" | |
| - name: Setup cache | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run tests | |
| run: make test |