-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (72 loc) · 2.58 KB
/
Copy pathtests.yml
File metadata and controls
85 lines (72 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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