Check wasm-bindgen changes #68
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: Check wasm-bindgen changes | |
| # Tests expand macro output. This changes a lot based on the version of wasm-bindgen that is installed | |
| # This cron job is meant to create a PR whenever there are changes to the expanded macro output. | |
| # Since all PRs that affect tsify's macro output should update their own tests, this should only detect | |
| # changes in other rust crates. | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" # every day at midnight GMT | |
| workflow_dispatch: | |
| env: | |
| TARGET_BRANCH: ${{ github.event.pull_request.base.ref || github.ref_name }} | |
| jobs: | |
| test: | |
| name: Create Test Artifacts | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| - name: Install toolchain | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| profile: minimal | |
| toolchain: stable | |
| override: true | |
| components: rustfmt | |
| - name: Install wasm-pack | |
| uses: jetli/wasm-pack-action@v0.4.0 | |
| with: | |
| # specify exact version to work around | |
| # https://github.com/jetli/wasm-pack-action/issues/23 | |
| version: v0.14.0 | |
| - name: Add cargo-expand | |
| run: cargo install cargo-expand | |
| - name: Setup git config | |
| run: | | |
| git config user.name "${{ github.actor }} via GitHub Actions" | |
| git config user.email "${{ github.actor }}@github_actions.no_reply" | |
| git checkout -b update-expanded-test-artifacts | |
| # Ensure the branch exists on the remote | |
| git ls-remote --exit-code origin update-expanded-test-artifacts || { | |
| git push -u origin update-expanded-test-artifacts | |
| } | |
| # Fetch the branch from the remote | |
| git fetch origin update-expanded-test-artifacts | |
| git fetch origin ${{ env.TARGET_BRANCH }} | |
| git fetch origin main | |
| # Reset to the target branch to avoid conflicts with the existing branch | |
| git reset --hard origin/${{ env.TARGET_BRANCH }} | |
| git branch --set-upstream-to=origin/${{ env.TARGET_BRANCH }} update-expanded-test-artifacts | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Run `MACROTEST=overwrite cargo test -p tsify --test expandtest` to rebuild the test artifacts with expanded macros. | |
| - name: Expand Macros | |
| run: cargo test -p tsify --test expandtest | |
| env: | |
| MACROTEST: overwrite | |
| - name: Check for changes | |
| run: | | |
| git diff --quiet || { | |
| echo "Available branches:" | |
| git branch -a | |
| echo "Remote configuration:" | |
| git remote -v | |
| echo "Creating PR with changes..." | |
| git add tests | |
| git commit -m "Update expanded test artifacts" | |
| git push --force --set-upstream origin update-expanded-test-artifacts | |
| gh pr create --fill | |
| } | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |