-
Notifications
You must be signed in to change notification settings - Fork 60
Create new job to make cancelled jobs as failure jobs in CI runner #780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,14 +85,28 @@ jobs: | |
| pytest --rootdir=. -v | ||
| cd .. | ||
|
|
||
| send_email_on_failure: | ||
| fail_on_cancelled_jobs: | ||
| needs: [nouse_install] | ||
| # Run if any of the dependencies failed in master branch | ||
| if: ${{ always() }} | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - name: Fail on cancelled jobs | ||
| run: | | ||
| result="${{ needs.nouse_install.result }}" | ||
| echo "nouse_install: ${result}" | ||
| if [ "${result}" = "cancelled" ]; then | ||
| exit 1 | ||
| fi | ||
|
Comment on lines
-88
to
+99
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot make a time-out job as a failure job easily. There are two workaround method. I prefer the first opinion, so I create a new job to monitor the cancelled jobs.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would work, but is not as elegant as I hoped for. If there is not a better way, I would take it. But I hope there is. |
||
|
|
||
| send_email_on_failure: | ||
| needs: [nouse_install, fail_on_cancelled_jobs] | ||
| # Run if any of the dependencies failed or timed out in master branch | ||
| if: ${{ always() && contains(needs.*.result, 'failure') && github.ref_name == 'master' && github.event.repository.fork == false }} | ||
| uses: ./.github/workflows/send_email_on_fail.yml | ||
| with: | ||
| job_results: | | ||
| - nouse_install: ${{ needs.nouse_install.result }} | ||
| - fail_on_cancelled_jobs: ${{ needs.fail_on_cancelled_jobs.result }} | ||
|
Comment on lines
+101
to
+109
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When a job is cancelled, a notified email would be sent now. |
||
| secrets: | ||
| EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }} | ||
| EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to write the
if, if italways()happens?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is. It's an interesting technique. See this reference.
In other words, if we remove
if: ${{ always() }}, this job would be skipped if the jobs in needs are cancelled or failed. However, we don't want to skip this job at any time, so we need to addif: ${{ always() }}.