summaryrefslogtreecommitdiff
path: root/.github/workflows/unit_tests.yaml
diff options
context:
space:
mode:
authorTom Scogland <tom.scogland@gmail.com>2022-09-07 11:12:57 -0700
committerGitHub <noreply@github.com>2022-09-07 20:12:57 +0200
commit762ba27036e717aeceeb1b43f3090f0e9a049869 (patch)
treec2b244d849aa12d1256462bc5936963362004fe4 /.github/workflows/unit_tests.yaml
parent8e5ccddc139b32a4a23f63c9dd631dabf3263cad (diff)
downloadspack-762ba27036e717aeceeb1b43f3090f0e9a049869.tar.gz
spack-762ba27036e717aeceeb1b43f3090f0e9a049869.tar.bz2
spack-762ba27036e717aeceeb1b43f3090f0e9a049869.tar.xz
spack-762ba27036e717aeceeb1b43f3090f0e9a049869.zip
Make GHA tests parallel by using xdist (#32361)
* Add two no-op jobs named "all-prechecks" and "all" These are a suggestion from @tgamblin, they are stable named markers we can use from gitlab and possibly for required checks to make CI more resilient to refactors changing the names of specific checks. * Enable parallel testing using xdist for unit testing in CI * Normalize tmp paths to deal with macos * add -u flag compatibility to spack python As of now, it is accepted and ignored. The usage with xdist, where it is invoked specifically by `python -u spack python` which is then passed `-u` by xdist is the entire reason for doing this. It should never be used without explicitly passing -u to the executing python interpreter. * use spack python in xdist to support python 2 When running on python2, spack has many import cycles unless started through main. To allow that, this uses `spack python` as the interpreter, leveraging the `-u` support so xdist doesn't error out when it unconditionally requests unbuffered binary IO. * Use shutil.move to account for tmpdir being in a separate filesystem sometimes
Diffstat (limited to '.github/workflows/unit_tests.yaml')
-rw-r--r--.github/workflows/unit_tests.yaml33
1 files changed, 25 insertions, 8 deletions
diff --git a/.github/workflows/unit_tests.yaml b/.github/workflows/unit_tests.yaml
index 3856f1039f..6b1411c61b 100644
--- a/.github/workflows/unit_tests.yaml
+++ b/.github/workflows/unit_tests.yaml
@@ -1,6 +1,7 @@
name: unit tests
on:
+ workflow_dispatch:
workflow_call:
inputs:
core:
@@ -14,7 +15,7 @@ on:
type: string
concurrency:
- group: unit_tests-${{ github.workflow }}-${{ github.event.pull_request.number || github.run_number }}
+ group: unit_tests-${{github.ref}}-${{github.event.pull_request.number || github.run_number}}
cancel-in-progress: true
jobs:
@@ -25,11 +26,26 @@ jobs:
matrix:
python-version: ['2.7', '3.6', '3.7', '3.8', '3.9', '3.10']
concretizer: ['clingo']
+ on_develop:
+ - ${{ github.ref == 'refs/heads/develop' }}
include:
- python-version: 2.7
concretizer: original
- - python-version: 3.9
+ on_develop: false
+ - python-version: '3.10'
concretizer: original
+ on_develop: false
+ exclude:
+ - python-version: '3.7'
+ concretizer: 'clingo'
+ on_develop: false
+ - python-version: '3.8'
+ concretizer: 'clingo'
+ on_develop: false
+ - python-version: '3.9'
+ concretizer: 'clingo'
+ on_develop: false
+
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # @v2
with:
@@ -46,7 +62,7 @@ jobs:
patchelf cmake bison libbison-dev kcov
- name: Install Python packages
run: |
- pip install --upgrade pip six setuptools pytest codecov "coverage[toml]<=6.2"
+ pip install --upgrade pip six setuptools pytest codecov "coverage[toml]<=6.2" pytest-xdist
# ensure style checks are not skipped in unit tests for python >= 3.6
# note that true/false (i.e., 1/0) are opposite in conditions in python and bash
if python -c 'import sys; sys.exit(not sys.version_info >= (3, 6))'; then
@@ -108,7 +124,7 @@ jobs:
sudo apt-get install -y coreutils kcov csh zsh tcsh fish dash bash
- name: Install Python packages
run: |
- pip install --upgrade pip six setuptools pytest codecov coverage[toml]==6.2
+ pip install --upgrade pip six setuptools pytest codecov coverage[toml]==6.2 pytest-xdist
- name: Setup git configuration
run: |
# Need this for the git tests to succeed.
@@ -174,7 +190,7 @@ jobs:
patchelf kcov
- name: Install Python packages
run: |
- pip install --upgrade pip six setuptools pytest codecov coverage[toml]==6.2 clingo
+ pip install --upgrade pip six setuptools pytest codecov coverage[toml]==6.2 clingo pytest-xdist
- name: Setup git configuration
run: |
# Need this for the git tests to succeed.
@@ -216,7 +232,7 @@ jobs:
- name: Install Python packages
run: |
pip install --upgrade pip six setuptools
- pip install --upgrade pytest codecov coverage[toml]==6.2
+ pip install --upgrade pytest codecov coverage[toml]==6.2 pytest-xdist
- name: Setup Homebrew packages
run: |
brew install dash fish gcc gnupg2 kcov
@@ -229,9 +245,10 @@ jobs:
. share/spack/setup-env.sh
$(which spack) bootstrap untrust spack-install
$(which spack) solve zlib
+ common_args=(--dist loadfile --tx '4*popen//python=./bin/spack-tmpconfig python -u ./bin/spack python' -x)
if [ "${{ inputs.with_coverage }}" == "true" ]
then
- coverage run $(which spack) unit-test -x
+ coverage run $(which spack) unit-test "${common_args[@]}"
coverage combine
coverage xml
# Delete the symlink going from ./lib/spack/docs/_spack_root back to
@@ -239,7 +256,7 @@ jobs:
rm lib/spack/docs/_spack_root
else
echo "ONLY PACKAGE RECIPES CHANGED [skipping coverage]"
- $(which spack) unit-test -x -m "not maybeslow" -k "test_all_virtual_packages_have_default_providers"
+ $(which spack) unit-test "${common_args[@]}" -m "not maybeslow" -k "test_all_virtual_packages_have_default_providers"
fi
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # @v2.1.0
if: ${{ inputs.with_coverage == 'true' }}