Skip to content

Commit

Permalink
Fail the nox-cross-arch-all job if any matrix job fails
Browse files Browse the repository at this point in the history
Otherwise this job will be skipped, just like when the matrix jobs are
skipped, resulting in a passed check when it should have failed.

Co-authored-by: daniel-zullo-frequenz <120166726+daniel-zullo-frequenz@users.noreply.github.com>
Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
  • Loading branch information
llucax and daniel-zullo-frequenz committed May 3, 2024
1 parent 72ca05b commit dec2ab3
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 14 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,17 @@ jobs:
# The job name should match the name of the `nox-cross-arch` job.
name: Cross-arch tests with nox
needs: ["nox-cross-arch"]
# We only run if there are failures, to propagate the failure, so if this
# check is required, it will fail if the child matrix jobs failed.
# If the child matrix jobs didn't run, this job will be skipped
# because there will be no dependency with a failure result.
if: always() && contains(needs.*.result, 'failure')
runs-on: ubuntu-20.04
steps:
- name: Return true
run: "true"
- name: Fail because some cross-arch tests failed
run: |
echo "Error: Some cross-arch tests failed"
exit 1
build:
name: Build distribution packages
Expand Down
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@
### Cookiecutter template

- Fixed a bug where the pip cache post action fails in the CI workflow because of permissions issues.
- Make the `nox-cross-arch-all` job fail if any `nox-cross-arch` matrix job fails.
18 changes: 18 additions & 0 deletions cookiecutter/migrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,23 @@ echo "========================================================================"
echo "Fixing pip cache in '.github/workflows/ci.yaml'"
sed -i "|hashFiles('**/pyproject.toml')|hashFiles('pyproject.toml')|" .github/workflows/ci.yaml

echo "========================================================================"

echo "Fixing nox-cross-arch-all jobs to fail on child jobs failure in '.github/workflows/ci.yaml'"
sed -i '/^ needs: \["nox-cross-arch"\]$/,/^ run: "true"$/c\
needs: \["nox-cross-arch"\]\
# We only run if there are failures, to propagate the failure, so if this\
# check is required, it will fail if the child matrix jobs failed.\
# If they didn'"'"'t ran, this job will be skipped because there will be no\
# dependency with a failure result.\
if: always() && contains(needs.*.result, '"'"'failure'"'"')\
runs-on: ubuntu-20.04\
steps:\
- name: Fail because some cross-arch tests failed\
run: |\
echo "Error: Some cross-arch tests failed"\
exit 1' \
.github/workflows/ci.yaml

# Add a separation line like this one after each migration step.
echo "========================================================================"
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,17 @@ jobs:
# The job name should match the name of the `nox-cross-arch` job.
name: Cross-arch tests with nox
needs: ["nox-cross-arch"]
# We only run if there are failures, to propagate the failure, so if this
# check is required, it will fail if the child matrix jobs failed.
# If they didn't ran, this job will be skipped because there will be no
# dependency with a failure result.
if: always() && contains(needs.*.result, 'failure')
runs-on: ubuntu-20.04
steps:
- name: Return true
run: "true"
- name: Fail because some cross-arch tests failed
run: |
echo "Error: Some cross-arch tests failed"
exit 1
build:
name: Build distribution packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,17 @@ jobs:
# The job name should match the name of the `nox-cross-arch` job.
name: Cross-arch tests with nox
needs: ["nox-cross-arch"]
# We only run if there are failures, to propagate the failure, so if this
# check is required, it will fail if the child matrix jobs failed.
# If they didn't ran, this job will be skipped because there will be no
# dependency with a failure result.
if: always() && contains(needs.*.result, 'failure')
runs-on: ubuntu-20.04
steps:
- name: Return true
run: "true"
- name: Fail because some cross-arch tests failed
run: |
echo "Error: Some cross-arch tests failed"
exit 1
build:
name: Build distribution packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,17 @@ jobs:
# The job name should match the name of the `nox-cross-arch` job.
name: Cross-arch tests with nox
needs: ["nox-cross-arch"]
# We only run if there are failures, to propagate the failure, so if this
# check is required, it will fail if the child matrix jobs failed.
# If they didn't ran, this job will be skipped because there will be no
# dependency with a failure result.
if: always() && contains(needs.*.result, 'failure')
runs-on: ubuntu-20.04
steps:
- name: Return true
run: "true"
- name: Fail because some cross-arch tests failed
run: |
echo "Error: Some cross-arch tests failed"
exit 1
build:
name: Build distribution packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,17 @@ jobs:
# The job name should match the name of the `nox-cross-arch` job.
name: Cross-arch tests with nox
needs: ["nox-cross-arch"]
# We only run if there are failures, to propagate the failure, so if this
# check is required, it will fail if the child matrix jobs failed.
# If they didn't ran, this job will be skipped because there will be no
# dependency with a failure result.
if: always() && contains(needs.*.result, 'failure')
runs-on: ubuntu-20.04
steps:
- name: Return true
run: "true"
- name: Fail because some cross-arch tests failed
run: |
echo "Error: Some cross-arch tests failed"
exit 1
build:
name: Build distribution packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,17 @@ jobs:
# The job name should match the name of the `nox-cross-arch` job.
name: Cross-arch tests with nox
needs: ["nox-cross-arch"]
# We only run if there are failures, to propagate the failure, so if this
# check is required, it will fail if the child matrix jobs failed.
# If they didn't ran, this job will be skipped because there will be no
# dependency with a failure result.
if: always() && contains(needs.*.result, 'failure')
runs-on: ubuntu-20.04
steps:
- name: Return true
run: "true"
- name: Fail because some cross-arch tests failed
run: |
echo "Error: Some cross-arch tests failed"
exit 1
build:
name: Build distribution packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,17 @@ jobs:
# The job name should match the name of the `nox-cross-arch` job.
name: Cross-arch tests with nox
needs: ["nox-cross-arch"]
# We only run if there are failures, to propagate the failure, so if this
# check is required, it will fail if the child matrix jobs failed.
# If they didn't ran, this job will be skipped because there will be no
# dependency with a failure result.
if: always() && contains(needs.*.result, 'failure')
runs-on: ubuntu-20.04
steps:
- name: Return true
run: "true"
- name: Fail because some cross-arch tests failed
run: |
echo "Error: Some cross-arch tests failed"
exit 1
build:
name: Build distribution packages
Expand Down

0 comments on commit dec2ab3

Please sign in to comment.