chore: bundle everything #373
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: 'Build & Test Action' | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| - 'releases/*' | |
| concurrency: | |
| group: build-and-test-${{ github.ref_name }} | |
| cancel-in-progress: true | |
| permissions: {} | |
| jobs: | |
| build-action: | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: 'package.json' | |
| registry-url: 'https://npm.pkg.github.com' | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.PRIVATE_PACKAGE_TOKEN }} | |
| run: pnpm install --frozen-lockfile | |
| - name: Build, Format, Lint, Package, and Test | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.PRIVATE_PACKAGE_TOKEN }} | |
| run: | | |
| pnpm run build | |
| pnpm exec prettier --check . | |
| pnpm run lint | |
| pnpm run test | |
| - name: Fail on dist diff | |
| run: | | |
| if [ ! -d dist/ ]; then | |
| echo "Expected dist/ directory does not exist. See status below:" | |
| ls -la ./ | |
| exit 1 | |
| fi | |
| if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then | |
| echo "Detected uncommitted changes after build. See status below:" | |
| git diff --ignore-space-at-eol --text dist/ | |
| exit 1 | |
| fi | |
| test-action: # make sure the action works on a clean machine without building | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Test built package | |
| uses: ./ | |
| id: action-test | |
| env: | |
| ACTIONS_STEP_DEBUG: 'true' | |
| with: | |
| base-branch: 'test_changes' | |
| command: "echo \\\"$(cat ./__tests__/{branchName}.txt | grep {globs})\\\"" | |
| glob-template: "-e '{glob}'" | |
| change-map: | | |
| text-and-png: {"globs": [".txt", ".png"]} | |
| text: {"globs": ".txt"} | |
| text-separate: {"globs": ".txt", "separateDeleted": true} | |
| missing: {"globs": ".jpg"} | |
| - name: Print Test Outputs | |
| run: | | |
| echo "Result => any-matches: ${{ steps.action-test.outputs.any-matches }}" | |
| echo "Result => text-and-png: ${{ steps.action-test.outputs.text-and-png }}" | |
| echo "Result => any-text-and-png: ${{ steps.action-test.outputs.any-text-and-png }}" | |
| echo "Result => text: ${{ steps.action-test.outputs.text }}" | |
| echo "Result => any-text: ${{ steps.action-test.outputs.any-text }}" | |
| echo "Result => text-separate: ${{ steps.action-test.outputs.text-separate }}" | |
| echo "Result => any-text-separate: ${{ steps.action-test.outputs.any-text-separate }}" | |
| echo "Result => deleted-text-separate: ${{ steps.action-test.outputs.deleted-text-separate }}" | |
| echo "Result => missing: ${{ steps.action-test.outputs.missing }}" | |
| echo "Result => any-missing: ${{ steps.action-test.outputs.any-missing }}" | |
| - name: Fail If Test Outputs Incorrectly | |
| if: >- | |
| steps.action-test.outputs.any-matches != 'true' || | |
| steps.action-test.outputs.text-and-png != 'added_text.txt added_img.png changed_text.txt changed_img.png deleted_text.txt' || | |
| steps.action-test.outputs.any-text-and-png != 'true' || | |
| steps.action-test.outputs.text != 'added_text.txt changed_text.txt deleted_text.txt' || | |
| steps.action-test.outputs.any-text != 'true' || | |
| steps.action-test.outputs.text-separate != 'added_text.txt changed_text.txt' || | |
| steps.action-test.outputs.any-text-separate != 'true' || | |
| steps.action-test.outputs.deleted-text-separate != 'deleted_text.txt' || | |
| steps.action-test.outputs.missing != '' || | |
| steps.action-test.outputs.any-missing != 'false' | |
| run: exit 1 |