1
1
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
2
- # TODO: Line 48, enable pytest --doctest-modules
2
+ # TODO: add `python -m pytest --doctest-modules`
3
3
4
4
name : Tests
5
5
on :
@@ -12,44 +12,82 @@ permissions:
12
12
contents : read # to fetch code (actions/checkout)
13
13
14
14
jobs :
15
- Lint_Python :
15
+ lint-python :
16
+ name : Lint Python
16
17
runs-on : ubuntu-latest
17
18
steps :
18
19
- uses : actions/checkout@v4
19
20
- run : pip install --user ruff
20
21
- run : ruff --output-format=github --select="E,F,PLC,PLE,UP,W,YTT" --ignore="E721,PLC1901,S101,UP031" --target-version=py38 .
21
- Lint_JS :
22
+
23
+ lint-js :
24
+ name : Lint JS
22
25
runs-on : ubuntu-latest
23
26
steps :
24
27
- name : Checkout Repository
25
28
uses : actions/checkout@v4
26
29
- name : Use Node.js 20.x
27
- uses : actions/setup-node@v3
30
+ uses : actions/setup-node@v4
28
31
with :
29
32
node-version : 20.x
30
33
- name : Install Dependencies
31
- run : npm install --no-progress
34
+ run : npm install
32
35
- name : Lint
33
36
run : npm run lint
34
- Engines :
37
+
38
+ check-engines :
39
+ name : Check Engines
35
40
runs-on : ubuntu-latest
36
41
steps :
37
42
- name : Checkout Repository
38
43
uses : actions/checkout@v4
39
44
- name : Use Node.js 20.x
40
- uses : actions/setup-node@v3
45
+ uses : actions/setup-node@v4
41
46
with :
42
47
node-version : 20.x
43
48
- name : Install Dependencies
44
- run : |
45
- npm install --no-progress
49
+ run : npm install
46
50
- name : Check Engines
47
51
run : |
48
52
# TODO: move this to its own action
49
53
npm install @npmcli/arborist@7 semver@7 --no-save
50
54
node .github/scripts/check-engines.js
51
- Tests :
52
- needs : Lint_Python # Lint_Python takes ~5 seconds, so wait for it to pass before running the full matrix of tests.
55
+
56
+ test-pack :
57
+ name : Test Pack
58
+ runs-on : ubuntu-latest
59
+ steps :
60
+ - name : Checkout Repository
61
+ uses : actions/checkout@v4
62
+ - name : Use Node.js 20.x
63
+ uses : actions/setup-node@v4
64
+ with :
65
+ node-version : 20.x
66
+ - name : Update npm
67
+ run : npm install npm@latest -g
68
+ - name : Install Dependencies
69
+ run : npm install
70
+ - name : Pack
71
+ id : pack
72
+ env :
73
+ NODE_GYP_TEMP_DIR : ' ${{ runner.temp }}/node-gyp'
74
+ run : |
75
+ mkdir -p $NODE_GYP_TEMP_DIR
76
+ npm pack
77
+ tar xzf *.tgz -C $NODE_GYP_TEMP_DIR --strip-components=1
78
+ cp -r test/ $NODE_GYP_TEMP_DIR/test/
79
+ echo "dir=$NODE_GYP_TEMP_DIR" >> "$GITHUB_OUTPUT"
80
+ - name : Test
81
+ working-directory : ${{ steps.pack.outputs.dir }}
82
+ env :
83
+ FULL_TEST : ' 1'
84
+ run : |
85
+ npm install
86
+ npm test
87
+
88
+ tests :
89
+ # lint-python takes ~5 seconds, so wait for it to pass before running the full matrix of tests.
90
+ needs : [lint-python]
53
91
strategy :
54
92
fail-fast : false
55
93
max-parallel : 15
63
101
- name : Checkout Repository
64
102
uses : actions/checkout@v4
65
103
- name : Use Node.js ${{ matrix.node }}
66
- uses : actions/setup-node@v3
104
+ uses : actions/setup-node@v4
67
105
with :
68
106
node-version : ${{ matrix.node }}
69
107
- name : Use Python ${{ matrix.python }}
@@ -74,26 +112,22 @@ jobs:
74
112
PYTHON_VERSION : ${{ matrix.python }} # Why do this?
75
113
- name : Install Dependencies
76
114
run : |
77
- npm install --no-progress
115
+ npm install
78
116
pip install pytest
79
- - name : Set Windows environment
80
- if : matrix .os == 'windows '
117
+ - name : Set Windows Env
118
+ if : runner .os == 'Windows '
81
119
run : |
82
120
echo 'GYP_MSVS_VERSION=2015' >> $Env:GITHUB_ENV
83
121
echo 'GYP_MSVS_OVERRIDE_PATH=C:\\Dummy' >> $Env:GITHUB_ENV
84
- - name : Run Python tests
122
+ - name : Run Python Tests
85
123
run : python -m pytest
86
- # - name: Run doctests with pytest
87
- # run: python -m pytest --doctest-modules
88
- - name : Environment Information
89
- run : npx envinfo
90
- - name : Run Node tests (macOS or Linux)
124
+ - name : Run Tests (macOS or Linux)
91
125
if : runner.os != 'Windows'
92
126
shell : bash
93
127
run : npm test --python="${pythonLocation}/python"
94
128
env :
95
129
FULL_TEST : ${{ (matrix.node == '20.x' && matrix.python == '3.12') && '1' || '0' }}
96
- - name : Run tests (Windows)
130
+ - name : Run Tests (Windows)
97
131
if : runner.os == 'Windows'
98
132
shell : pwsh
99
133
run : npm run test --python="${env:pythonLocation}\\python.exe"
0 commit comments