Repository navigation
chore: release 1.0.1 #81
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: Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| schedule: | |
| # Nightly run of the integration tests against the real API | |
| - cron: '0 3 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| unit: | |
| name: Unit (Node ${{ matrix.node-version }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # Matches engines.node: ">=18" in package.json | |
| node-version: [18, 20, 22] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: npm | |
| - run: npm ci | |
| - name: Run unit tests with coverage | |
| run: npm run test:unit -- --coverage | |
| # Coverage is uploaded once, not per Node version -- the figure | |
| # doesn't depend on the version, and duplicates would only clutter | |
| # the report. | |
| # | |
| # fail-on-error: false -- the coverage upload is a secondary step, and | |
| # its failure shouldn't turn a job red when all tests passed. Otherwise | |
| # Coveralls being down or the repo not being connected would block | |
| # merging an otherwise working PR. A stale badge is noticeable on its | |
| # own anyway. | |
| - name: Upload coverage to Coveralls | |
| if: matrix.node-version == 20 | |
| uses: coverallsapp/github-action@v2 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| file: coverage/lcov.info | |
| fail-on-error: false | |
| integration: | |
| name: Integration (real API) | |
| # Only on schedule and manual dispatch. Deliberately not run on | |
| # pull_request: the tests spend real account balance, and secrets are | |
| # unavailable in PRs from forks anyway -- the tests would silently skip | |
| # and produce a false-green result. | |
| if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - run: npm ci | |
| - name: Fail early if the API key is missing | |
| # Without a key the integration tests skip themselves and the job | |
| # goes green having checked nothing. Better to fail explicitly. | |
| env: | |
| CAPTCHA_API_KEY: ${{ secrets.CAPTCHA_API_KEY }} | |
| run: | | |
| if [ -z "$CAPTCHA_API_KEY" ]; then | |
| echo "::error::secrets.CAPTCHA_API_KEY is not set -- integration tests would silently skip" | |
| exit 1 | |
| fi | |
| - name: Run integration tests | |
| env: | |
| CAPTCHA_API_KEY: ${{ secrets.CAPTCHA_API_KEY }} | |
| run: npm run test:integration |