diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index c9ee305..f587234 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -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' }} + steps: - name: Send status to Slack app - if: ${{ failure() && github.event_name != 'workflow_dispatch' }} id: slack uses: slackapi/slack-github-action@v4 with: @@ -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:" } }, { diff --git a/python-project-template/.github/workflows/smoke-test.yml.jinja b/python-project-template/.github/workflows/smoke-test.yml.jinja index 209785b..c1f8f30 100644 --- a/python-project-template/.github/workflows/smoke-test.yml.jinja +++ b/python-project-template/.github/workflows/smoke-test.yml.jinja @@ -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: @@ -59,7 +64,7 @@ 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: @@ -67,8 +72,8 @@ jobs: -

Smoke test ${{ job.status }}

-

The smoke test in ${{ github.repository }} has completed with result: ${{ job.status }}

+

Smoke test ${{ needs.build.result }}

+

The smoke test in ${{ github.repository }} has completed with result: ${{ needs.build.result }}

${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

@@ -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: @@ -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:" } }, { @@ -116,4 +120,5 @@ jobs: ] } {%- endraw %} +{%- endif %} {%- endif %} \ No newline at end of file