forked from spack/spack
-
Notifications
You must be signed in to change notification settings - Fork 0
279 lines (271 loc) · 10.7 KB
/
Copy pathunit_tests.yaml
File metadata and controls
279 lines (271 loc) · 10.7 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
name: unit tests
on:
workflow_dispatch:
workflow_call:
concurrency:
group: unit_tests-${{github.ref}}-${{github.event.pull_request.number || github.run_number}}
cancel-in-progress: true
env:
# RUNNER_TEMP is set by the runner on every platform, and is the only temporary directory
# Windows runners guarantee to be writable. The runner context is not available here, so
# the plugin expands the variable itself.
SPACK_TEST_CONCRETIZATION_CACHE: ${RUNNER_TEMP}/spack-concretization-cache
jobs:
# Run unit tests with different configurations on linux
ubuntu:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
# On develop test every supported Python, on pull requests only the newest to keep
# feedback fast. Python 3.6 is covered at runtime by rhel8-platform-python, since
# setup-python cannot provide it on current runners.
python-version: >-
${{ github.ref == 'refs/heads/develop'
&& fromJSON('["3.8", "3.9", "3.10", "3.11", "3.14"]')
|| fromJSON('["3.14"]') }}
# Python 3.7 needs ubuntu-22.04, newer runner images no longer ship it.
include: >-
${{ github.ref == 'refs/heads/develop'
&& fromJSON('[{"os": "ubuntu-22.04", "python-version": "3.7"}]')
|| fromJSON('[]') }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Install System packages
run: |
sudo apt-get -y update
# Needed for unit tests
sudo apt-get -y install \
coreutils cvs gfortran graphviz gnupg2 mercurial ninja-build \
cmake bison libbison-dev subversion
# This job tests older Python versions, which the pins in the requirements file do
# not support, so it installs unpinned. mypy and ruff are needed by the tests
# covering "spack style". See coveragepy issue 2082 for the coverage bound.
- name: Setup Spack
uses: ./.github/actions/setup-spack
with:
python-version: ${{ matrix.python-version }}
pip-install: >-
pytest pytest-xdist pytest-cov "coverage<=7.11.0" "mypy>=0.900" ruff
- name: Run unit tests
env:
COVERAGE_FILE: coverage/.coverage-${{ matrix.os }}-python${{ matrix.python-version }}
PYTEST_ADDOPTS: ${{ matrix.python-version == '3.14' && '--cov --cov-config=pyproject.toml' || '' }}
run: |
python3 -m pytest -x --verbose --dist worksteal -n4
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ matrix.python-version == '3.14' }}
with:
name: coverage-${{ matrix.os }}-python${{ matrix.python-version }}
path: coverage
include-hidden-files: true
# Test shell integration
shell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Install System packages
run: |
sudo apt-get -y update
# Needed for shell tests
sudo apt-get install -y coreutils csh zsh tcsh fish dash bash subversion
# On ubuntu 24.04, kcov was removed. It may come back in some future Ubuntu
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@40e9946c182a64b3db1bf51be0dcb915f7802aa9
- name: Install kcov with brew
run: "brew install kcov"
- name: Setup Spack
uses: ./.github/actions/setup-spack
with:
python-version: '3.11'
- name: Run shell tests
env:
COVERAGE: true
run: |
share/spack/qa/run-shell-tests
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-shell
path: coverage
include-hidden-files: true
# Test RHEL8 UBI with platform Python. This job is run
# only on PRs modifying core Spack
rhel8-platform-python:
runs-on: ubuntu-latest
container: registry.access.redhat.com/ubi8/ubi
steps:
- name: Install dependencies
run: |
dnf install -y \
bzip2 curl gcc-c++ gcc gcc-gfortran git gnupg2 gzip \
make patch tcl unzip which xz
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup repo and non-root user
run: |
git --version
git config --global --add safe.directory '*'
git fetch --unshallow
. .github/workflows/bin/setup_git.sh
- name: Setup a virtual environment with platform-python
run: |
# platform-python is the only runtime coverage we have of Python 3.6
/usr/libexec/platform-python -m venv ~/platform-spack
echo "$HOME/platform-spack/bin" >> $GITHUB_PATH
~/platform-spack/bin/pip install --upgrade pip pytest coverage[toml] pytest-xdist
- name: Bootstrap Spack development environment
run: |
source share/spack/setup-env.sh
spack debug report
spack -d bootstrap now
- name: Smoke tests
run: |
bin/spack -h
bin/spack help -a
bin/spack python -c "from spack_repo.builtin.packages.mpileaks.package import Mpileaks"
- name: Run unit tests
run: |
python3 -m pytest --verbose -x -n3 --dist loadfile -k 'not cvs and not svn and not hg'
# Test the concretizer against clingo builds published on PyPI, rather than the binaries
# we bootstrap. clingo v6 is still pre-release, so that variant is allowed to fail
# without blocking the workflow.
clingo:
name: clingo-${{ matrix.variant }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
include:
- variant: cffi
install: clingo==5.8.0
experimental: false
- variant: v6
install: --pre --extra-index-url https://test.pypi.org/simple clingo
experimental: true
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Install System packages
run: |
sudo apt-get -y update
sudo apt-get -y install coreutils gfortran graphviz gnupg2
- name: Setup Spack
uses: ./.github/actions/setup-spack
with:
python-version: '3.13'
pip-install: >-
-r .github/workflows/requirements/unit_tests/requirements.txt
${{ matrix.install }}
bootstrap: none
- name: Run unit tests (full suite with coverage)
env:
COVERAGE_FILE: coverage/.coverage-clingo-${{ matrix.variant }}
run: |
python3 -m pytest --verbose --cov --cov-config=pyproject.toml -x -n3 --dist worksteal lib/spack/spack/test/concretization/
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-clingo-${{ matrix.variant }}
path: coverage
include-hidden-files: true
# Run unit tests on MacOS
macos:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-15-intel, macos-latest]
python-version: ["3.14"]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Setup Homebrew packages
run: |
brew install dash fish gcc gnupg kcov
- name: Setup Spack
uses: ./.github/actions/setup-spack
with:
python-version: ${{ matrix.python-version }}
- name: Run unit tests
env:
COVERAGE_FILE: coverage/.coverage-${{ matrix.os }}-python${{ matrix.python-version }}
run: |
python3 -m pytest --verbose --cov --cov-config=pyproject.toml --dist worksteal -x -n4
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-${{ matrix.os }}-python${{ matrix.python-version }}
path: coverage
include-hidden-files: true
# Run unit tests on Windows
windows:
defaults:
run:
shell:
powershell Invoke-Expression -Command "./share/spack/qa/windows_test_setup.ps1"; {0}
runs-on: windows-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: '3.14'
- name: Install Python packages
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade -r .github/workflows/requirements/unit_tests/requirements.txt -r .github/workflows/requirements/style/requirements.txt
# There are no prebuilt clingo binaries for Windows to bootstrap from
python -m pip install --upgrade clingo==5.8.0
- name: Create local develop
run: |
./.github/workflows/bin/setup_git.ps1
- name: Smoke tests
run: |
spack -h
./share/spack/qa/validate_last_exit.ps1
spack help -a
./share/spack/qa/validate_last_exit.ps1
spack python -c "from spack_repo.builtin.packages.mpileaks.package import Mpileaks"
./share/spack/qa/validate_last_exit.ps1
- name: Unit Test
env:
COVERAGE_FILE: coverage/.coverage-windows
run: |
python -m pytest -x --verbose --cov --cov-config=pyproject.toml
./share/spack/qa/validate_last_exit.ps1
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-windows
path: coverage
include-hidden-files: true
canonicalization:
name: package.py canonicalization
runs-on: ubuntu-latest
container:
image: ghcr.io/spack/all-pythons:2025-10-10
steps:
- name: Checkout Spack (current)
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
path: spack-current
- name: Checkout Spack (previous)
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
path: spack-previous
ref: ${{ github.event.pull_request.base.sha || github.event.before }}
- name: Checkout Spack Packages
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: spack/spack-packages
path: spack-packages
- name: Test package.py canonicalization
run: spack-current/.github/workflows/bin/canonicalize.py
--spack $PWD/spack-previous $PWD/spack-current
--python python3.6 python3.7 python3.8 python3.9 python3.10 python3.11 python3.12 python3.13 python3.14
--input-dir spack-packages/repos/spack_repo/builtin/packages/
--output-dir canonicalized