add test snapshot #9
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: Snapshot Checker | |
| on: | |
| pull_request: | |
| jobs: | |
| snapshot-checker: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install dependencies | |
| working-directory: checker-utils | |
| run: npm install --no-fund --no-audit | |
| - name: Summarize added snapshots | |
| env: | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| HEAD_SHA: ${{ github.sha }} | |
| run: | | |
| set -euo pipefail | |
| mapfile -t files < <(git diff --name-status "$BASE_SHA...$HEAD_SHA" -- snapshots | awk '$1=="A"{print $2}') | |
| if [ ${#files[@]} -eq 0 ]; then | |
| echo "No new snapshot files added." >> "$GITHUB_STEP_SUMMARY" | |
| exit 0 | |
| fi | |
| npx --yes --prefix checker-utils ts-node --project checker-utils/tsconfig.json --transpile-only checker-utils/snapshot-checker.ts "${files[@]}" |