11# 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`
33
44name : Tests
55on :
@@ -12,44 +12,82 @@ permissions:
1212 contents : read # to fetch code (actions/checkout)
1313
1414jobs :
15- Lint_Python :
15+ lint-python :
16+ name : Lint Python
1617 runs-on : ubuntu-latest
1718 steps :
1819 - uses : actions/checkout@v4
1920 - run : pip install --user ruff
2021 - 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
2225 runs-on : ubuntu-latest
2326 steps :
2427 - name : Checkout Repository
2528 uses : actions/checkout@v4
2629 - name : Use Node.js 20.x
27- uses : actions/setup-node@v3
30+ uses : actions/setup-node@v4
2831 with :
2932 node-version : 20.x
3033 - name : Install Dependencies
31- run : npm install --no-progress
34+ run : npm install
3235 - name : Lint
3336 run : npm run lint
34- Engines :
37+
38+ check-engines :
39+ name : Check Engines
3540 runs-on : ubuntu-latest
3641 steps :
3742 - name : Checkout Repository
3843 uses : actions/checkout@v4
3944 - name : Use Node.js 20.x
40- uses : actions/setup-node@v3
45+ uses : actions/setup-node@v4
4146 with :
4247 node-version : 20.x
4348 - name : Install Dependencies
44- run : |
45- npm install --no-progress
49+ run : npm install
4650 - name : Check Engines
4751 run : |
4852 # TODO: move this to its own action
4953 npm install @npmcli/arborist@7 semver@7 --no-save
5054 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]
5391 strategy :
5492 fail-fast : false
5593 max-parallel : 15
63101 - name : Checkout Repository
64102 uses : actions/checkout@v4
65103 - name : Use Node.js ${{ matrix.node }}
66- uses : actions/setup-node@v3
104+ uses : actions/setup-node@v4
67105 with :
68106 node-version : ${{ matrix.node }}
69107 - name : Use Python ${{ matrix.python }}
@@ -74,26 +112,22 @@ jobs:
74112 PYTHON_VERSION : ${{ matrix.python }} # Why do this?
75113 - name : Install Dependencies
76114 run : |
77- npm install --no-progress
115+ npm install
78116 pip install pytest
79- - name : Set Windows environment
80- if : matrix .os == 'windows '
117+ - name : Set Windows Env
118+ if : runner .os == 'Windows '
81119 run : |
82120 echo 'GYP_MSVS_VERSION=2015' >> $Env:GITHUB_ENV
83121 echo 'GYP_MSVS_OVERRIDE_PATH=C:\\Dummy' >> $Env:GITHUB_ENV
84- - name : Run Python tests
122+ - name : Run Python Tests
85123 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)
91125 if : runner.os != 'Windows'
92126 shell : bash
93127 run : npm test --python="${pythonLocation}/python"
94128 env :
95129 FULL_TEST : ${{ (matrix.node == '20.x' && matrix.python == '3.12') && '1' || '0' }}
96- - name : Run tests (Windows)
130+ - name : Run Tests (Windows)
97131 if : runner.os == 'Windows'
98132 shell : pwsh
99133 run : npm run test --python="${env:pythonLocation}\\python.exe"
0 commit comments