Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ jobs:
run: |
git config --global init.defaultBranch main
python -m pytest tests -o log_cli=true -vv --python_version ${{ matrix.python-version }}
notify:
needs: build
runs-on: ubuntu-latest
if: ${{ always() && needs.build.result == 'failure' && github.event_name != 'workflow_dispatch' }}
Comment on lines +45 to +48

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the generated workflow’s optional email and Slack notifications into one failure-gated job and updated messages to report the build result. Commit: e17805d.

steps:
- name: Send status to Slack app
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
id: slack
uses: slackapi/slack-github-action@v4
with:
Expand All @@ -63,7 +67,7 @@ jobs:
"type": "section",
"text": {
"type": "mrkdwn",
"text": "GitHub Action build result: *${{ job.status }}* :${{ job.status }}:"
"text": "GitHub Action build result: *${{ needs.build.result }}* :x:"
}
},
{
Expand Down
17 changes: 11 additions & 6 deletions python-project-template/.github/workflows/smoke-test.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ jobs:
- name: Run unit tests with pytest
run: |
python -m pytest -o log_cli=true -vv
{%- if failure_notification %}
notify:
needs: build
runs-on: ubuntu-latest
if: {% raw %}${{ always() && needs.build.result == 'failure' && github.event_name != 'workflow_dispatch' }}{% endraw %}
steps:
{%- if 'email' in failure_notification %}
- name: Send status to author's email
if: {% raw %}${{ failure() }} && github.event_name != 'workflow_dispatch' }}{% endraw %} # Only email if the workflow failed and was not manually started. Customize this as necessary.
uses: dawidd6/action-send-mail@v18
with:
# Required mail server address if not connection_url:
Expand All @@ -59,16 +64,16 @@ jobs:
to: {{ author_email }}

# Required mail subject:
subject: {% raw %}Smoke test ${{ job.status }} in ${{github.repository}}{% endraw %}
subject: {% raw %}Smoke test ${{ needs.build.result }} in ${{github.repository}}{% endraw %}
# Required sender full name:
from: GitHub Actions Report
# Optional body:
html_body: {% raw %}|
<!DOCTYPE html>
<html>
<body>
<h3>Smoke test ${{ job.status }}</h3>
<p>The smoke test in <b>${{ github.repository }}</b> has completed with result: <b>${{ job.status }}</b></p>
<h3>Smoke test ${{ needs.build.result }}</h3>
<p>The smoke test in <b>${{ github.repository }}</b> has completed with result: <b>${{ needs.build.result }}</b></p>
<p><a href="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}">
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
</a></p>
Expand All @@ -79,7 +84,6 @@ jobs:
{%- if 'slack' in failure_notification %}
{%- raw %}
- name: Send status to Slack app
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
id: slack
uses: slackapi/slack-github-action@v4
with:
Expand All @@ -100,7 +104,7 @@ jobs:
"type": "section",
"text": {
"type": "mrkdwn",
"text": "GitHub Action build result: *${{ job.status }}* :${{ job.status }}:"
"text": "GitHub Action build result: *${{ needs.build.result }}* :x:"
}
},
{
Expand All @@ -116,4 +120,5 @@ jobs:
]
}
{%- endraw %}
{%- endif %}
{%- endif %}