ci: avoid running coverage on package only PRs (#32573)

* ci: remove !docs from "core" filters

Written like it is now it causes package only PRs
to run with coverage.

* Try to skip job under condition, see if the workflow proceed

* Try to cancel a running CI job

* Simplify linux unit-tests, skip windows unit-tests on package PRs

* Reduce the inputs to unit-tests workflow

* Move control logic to main workflow, remove inputs

* Revert "Move control logic to main workflow, remove inputs"

This reverts commit 0c46fece4c.

* Do not compute "with_coverage" since it's always == to "core"

* Remove workflow dispatch from unit tests

* Revert "Revert "Move control logic to main workflow, remove inputs""

This reverts commit dd4e4a4e61.

* Try to skip all from the main workflow

* Add back bootstrap to needed checks for "all"

* Restore the correct logic for conditionals
This commit is contained in:
Massimiliano Culpo 2022-09-08 19:58:53 +02:00 committed by GitHub
parent dc1734f0a6
commit 67534516c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 78 deletions

View File

@ -19,12 +19,12 @@ jobs:
needs: [ changes ] needs: [ changes ]
uses: ./.github/workflows/valid-style.yml uses: ./.github/workflows/valid-style.yml
with: with:
with_coverage: ${{ needs.changes.outputs.with_coverage }} with_coverage: ${{ needs.changes.outputs.core }}
audit-ancient-python: audit-ancient-python:
uses: ./.github/workflows/audit.yaml uses: ./.github/workflows/audit.yaml
needs: [ changes ] needs: [ changes ]
with: with:
with_coverage: ${{ needs.changes.outputs.with_coverage }} with_coverage: ${{ needs.changes.outputs.core }}
python_version: 2.7 python_version: 2.7
all-prechecks: all-prechecks:
needs: [ prechecks ] needs: [ prechecks ]
@ -40,7 +40,6 @@ jobs:
bootstrap: ${{ steps.filter.outputs.bootstrap }} bootstrap: ${{ steps.filter.outputs.bootstrap }}
core: ${{ steps.filter.outputs.core }} core: ${{ steps.filter.outputs.core }}
packages: ${{ steps.filter.outputs.packages }} packages: ${{ steps.filter.outputs.packages }}
with_coverage: ${{ steps.coverage.outputs.with_coverage }}
steps: steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # @v2 - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # @v2
if: ${{ github.event_name == 'push' }} if: ${{ github.event_name == 'push' }}
@ -65,7 +64,6 @@ jobs:
- 'share/spack/**' - 'share/spack/**'
- '.github/workflows/bootstrap.yml' - '.github/workflows/bootstrap.yml'
core: core:
- '!lib/spack/docs/**'
- './!(var/**)/**' - './!(var/**)/**'
packages: packages:
- 'var/**' - 'var/**'
@ -75,18 +73,6 @@ jobs:
# job outputs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs # job outputs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs
# setting environment variables from earlier steps: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable # setting environment variables from earlier steps: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
# #
- id: coverage
# Run the subsequent jobs with coverage if core has been modified,
# regardless of whether this is a pull request or a push to a branch
run: |
echo Core changes: ${{ steps.filter.outputs.core }}
echo Event name: ${{ github.event_name }}
if [ "${{ steps.filter.outputs.core }}" == "true" ]
then
echo "::set-output name=with_coverage::true"
else
echo "::set-output name=with_coverage::false"
fi
bootstrap: bootstrap:
if: ${{ github.repository == 'spack/spack' && needs.changes.outputs.bootstrap == 'true' }} if: ${{ github.repository == 'spack/spack' && needs.changes.outputs.bootstrap == 'true' }}
needs: [ prechecks, changes ] needs: [ prechecks, changes ]
@ -95,10 +81,6 @@ jobs:
if: ${{ github.repository == 'spack/spack' && needs.changes.outputs.core == 'true' }} if: ${{ github.repository == 'spack/spack' && needs.changes.outputs.core == 'true' }}
needs: [ prechecks, changes ] needs: [ prechecks, changes ]
uses: ./.github/workflows/unit_tests.yaml uses: ./.github/workflows/unit_tests.yaml
with:
core: ${{ needs.changes.outputs.core }}
packages: ${{ needs.changes.outputs.packages }}
with_coverage: ${{ needs.changes.outputs.with_coverage }}
windows: windows:
if: ${{ github.repository == 'spack/spack' && needs.changes.outputs.core == 'true' }} if: ${{ github.repository == 'spack/spack' && needs.changes.outputs.core == 'true' }}
needs: [ prechecks ] needs: [ prechecks ]
@ -109,4 +91,3 @@ jobs:
steps: steps:
- name: Success - name: Success
run: "true" run: "true"

View File

@ -3,16 +3,6 @@ name: unit tests
on: on:
workflow_dispatch: workflow_dispatch:
workflow_call: workflow_call:
inputs:
core:
required: true
type: string
packages:
required: true
type: string
with_coverage:
required: true
type: string
concurrency: concurrency:
group: unit_tests-${{github.ref}}-${{github.event.pull_request.number || github.run_number}} group: unit_tests-${{github.ref}}-${{github.event.pull_request.number || github.run_number}}
@ -31,10 +21,10 @@ jobs:
include: include:
- python-version: 2.7 - python-version: 2.7
concretizer: original concretizer: original
on_develop: false on_develop: ${{ github.ref == 'refs/heads/develop' }}
- python-version: '3.10' - python-version: '3.10'
concretizer: original concretizer: original
on_develop: false on_develop: ${{ github.ref == 'refs/heads/develop' }}
exclude: exclude:
- python-version: '3.7' - python-version: '3.7'
concretizer: 'clingo' concretizer: 'clingo'
@ -86,7 +76,6 @@ jobs:
spack bootstrap untrust spack-install spack bootstrap untrust spack-install
spack -v solve zlib spack -v solve zlib
- name: Run unit tests (full suite with coverage) - name: Run unit tests (full suite with coverage)
if: ${{ inputs.with_coverage == 'true' }}
env: env:
SPACK_PYTHON: python SPACK_PYTHON: python
COVERAGE: true COVERAGE: true
@ -95,16 +84,7 @@ jobs:
share/spack/qa/run-unit-tests share/spack/qa/run-unit-tests
coverage combine coverage combine
coverage xml coverage xml
- name: Run unit tests (reduced suite without coverage)
if: ${{ inputs.with_coverage == 'false' }}
env:
SPACK_PYTHON: python
ONLY_PACKAGES: true
SPACK_TEST_SOLVER: ${{ matrix.concretizer }}
run: |
share/spack/qa/run-unit-tests
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # @v2.1.0 - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # @v2.1.0
if: ${{ inputs.with_coverage == 'true' }}
with: with:
flags: unittests,linux,${{ matrix.concretizer }} flags: unittests,linux,${{ matrix.concretizer }}
# Test shell integration # Test shell integration
@ -130,18 +110,12 @@ jobs:
# Need this for the git tests to succeed. # Need this for the git tests to succeed.
git --version git --version
. .github/workflows/setup_git.sh . .github/workflows/setup_git.sh
- name: Run shell tests (without coverage) - name: Run shell tests
if: ${{ inputs.with_coverage == 'false' }}
run: |
share/spack/qa/run-shell-tests
- name: Run shell tests (with coverage)
if: ${{ inputs.with_coverage == 'true' }}
env: env:
COVERAGE: true COVERAGE: true
run: | run: |
share/spack/qa/run-shell-tests share/spack/qa/run-shell-tests
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # @v2.1.0 - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # @v2.1.0
if: ${{ inputs.with_coverage == 'true' }}
with: with:
flags: shelltests,linux flags: shelltests,linux
@ -149,7 +123,6 @@ jobs:
# only on PRs modifying core Spack # only on PRs modifying core Spack
rhel8-platform-python: rhel8-platform-python:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ inputs.with_coverage == 'true' }}
container: registry.access.redhat.com/ubi8/ubi container: registry.access.redhat.com/ubi8/ubi
steps: steps:
- name: Install dependencies - name: Install dependencies
@ -197,7 +170,6 @@ jobs:
git --version git --version
. .github/workflows/setup_git.sh . .github/workflows/setup_git.sh
- name: Run unit tests (full suite with coverage) - name: Run unit tests (full suite with coverage)
if: ${{ inputs.with_coverage == 'true' }}
env: env:
COVERAGE: true COVERAGE: true
SPACK_TEST_SOLVER: clingo SPACK_TEST_SOLVER: clingo
@ -205,15 +177,7 @@ jobs:
share/spack/qa/run-unit-tests share/spack/qa/run-unit-tests
coverage combine coverage combine
coverage xml coverage xml
- name: Run unit tests (reduced suite without coverage)
if: ${{ inputs.with_coverage == 'false' }}
env:
ONLY_PACKAGES: true
SPACK_TEST_SOLVER: clingo
run: |
share/spack/qa/run-unit-tests
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # @v2.1.0 - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # @v2.1.0
if: ${{ inputs.with_coverage == 'true' }}
with: with:
flags: unittests,linux,clingo flags: unittests,linux,clingo
# Run unit tests on MacOS # Run unit tests on MacOS
@ -246,21 +210,13 @@ jobs:
$(which spack) bootstrap untrust spack-install $(which spack) bootstrap untrust spack-install
$(which spack) solve zlib $(which spack) solve zlib
common_args=(--dist loadfile --tx '4*popen//python=./bin/spack-tmpconfig python -u ./bin/spack python' -x) common_args=(--dist loadfile --tx '4*popen//python=./bin/spack-tmpconfig python -u ./bin/spack python' -x)
if [ "${{ inputs.with_coverage }}" == "true" ] coverage run $(which spack) unit-test "${common_args[@]}"
then coverage combine
coverage run $(which spack) unit-test "${common_args[@]}" coverage xml
coverage combine # Delete the symlink going from ./lib/spack/docs/_spack_root back to
coverage xml # the initial directory, since it causes ELOOP errors with codecov/actions@2
# Delete the symlink going from ./lib/spack/docs/_spack_root back to rm lib/spack/docs/_spack_root
# the initial directory, since it causes ELOOP errors with codecov/actions@2
rm lib/spack/docs/_spack_root
else
echo "ONLY PACKAGE RECIPES CHANGED [skipping coverage]"
$(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 - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # @v2.1.0
if: ${{ inputs.with_coverage == 'true' }}
with: with:
files: ./coverage.xml files: ./coverage.xml
flags: unittests,macos flags: unittests,macos

View File

@ -46,10 +46,7 @@ $coverage_run $(which spack) python -c "import spack.pkg.builtin.mpileaks; repr(
#----------------------------------------------------------- #-----------------------------------------------------------
# Run unit tests with code coverage # Run unit tests with code coverage
#----------------------------------------------------------- #-----------------------------------------------------------
if [[ "$ONLY_PACKAGES" == "true" ]]; then if [[ "$SPACK_TEST_SOLVER" == "original" ]]; then
echo "ONLY PACKAGE RECIPES CHANGED [running only package sanity]"
export PYTEST_ADDOPTS='-k "test_all_virtual_packages_have_default_providers" -m "not maybeslow"'
elif [[ "$SPACK_TEST_SOLVER" == "original" ]]; then
echo "ORIGINAL CONCRETIZER [skipping slow unit tests]" echo "ORIGINAL CONCRETIZER [skipping slow unit tests]"
export PYTEST_ADDOPTS='-m "not maybeslow"' export PYTEST_ADDOPTS='-m "not maybeslow"'
fi fi