feat: enhance CI workflows with caching for Node.js and Rust dependen… #292
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: ci | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| node-version: [20, 22, 24] | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Setup Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - name: Cache Rust dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: wit-bindgen-wasm | |
| shared-key: ${{ runner.os }}-cargo-${{ hashFiles('wit-bindgen-wasm/Cargo.lock') }} | |
| - name: Setup WebAssembly build tools | |
| run: npm run setup-wasm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm test | |
| - name: Update snapshot | |
| run: npm run update-snapshot && git add --all | |
| - name: Prepare diff for comment | |
| id: diff | |
| continue-on-error: true | |
| run: | | |
| set +e | |
| body=$(git diff --exit-code --diff-filter=AM $GITHUB_SHA -- '*.snap' 2>&1) | |
| echo "exitcode=$?" >> $GITHUB_OUTPUT | |
| body="${body//'<'/'<'}" | |
| body="${body//'>'/'>'}" | |
| delimiter="$(openssl rand -hex 8)" | |
| echo "body<<${delimiter}" >> $GITHUB_OUTPUT | |
| echo "${body:0:64000}" >> $GITHUB_OUTPUT | |
| echo "${delimiter}" >> $GITHUB_OUTPUT | |
| - uses: marocchino/sticky-pull-request-comment@v2 | |
| if: github.event_name == 'pull_request' && steps.diff.outputs.exitcode == '1' | |
| with: | |
| header: sticky-comment-for-git-diff | |
| hide_and_recreate: true | |
| hide_classify: "OUTDATED" | |
| message: | | |
| **Found changes in the snapshot tests. Please review.** | |
| <details> | |
| <summary>Diff 📖</summary> | |
| <pre lang="diff"><code> | |
| ${{ steps.diff.outputs.body }} | |
| </code></pre> | |
| </details> | |
| - uses: marocchino/sticky-pull-request-comment@v2 | |
| if: github.event_name == 'pull_request' && steps.diff.outputs.exitcode == '0' | |
| with: | |
| header: sticky-comment-for-git-diff | |
| hide: true | |
| hide_classify: "OUTDATED" |