Skip to content

Commit b235b3a

Browse files
authored
Send Slack notification if test-install.yml fails (#6897)
* Add slack-notification action, use it in test-install.yml * Don't run on PRs
1 parent cbbdedb commit b235b3a

File tree

3 files changed

+70
-20
lines changed

3 files changed

+70
-20
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Slack notification
2+
description: Send message to aiida-core-dev channel
3+
4+
inputs:
5+
title:
6+
description: Message title
7+
required: true
8+
message:
9+
description: Text of the message
10+
required: true
11+
12+
runs:
13+
using: composite
14+
steps:
15+
16+
- name: Slack notification
17+
uses: rtCamp/action-slack-notify@v2
18+
env:
19+
SLACK_ICON: https://www.materialscloud.org/discover/images/0ba0a17d.aiida-logo-128.png
20+
SLACK_CHANNEL: dev-aiida-core
21+
SLACK_COLOR: b60205
22+
SLACK_TITLE: ${{ inputs.title }}
23+
SLACK_MESSAGE: ${{ inputs.message }}

.github/workflows/nightly.yml

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,23 @@ jobs:
8282
run: .github/workflows/daemon_tests.sh
8383

8484
- name: Slack notification
85-
# Always run this step (otherwise it would be skipped if any of the previous steps fail) but only if the
86-
# `install` or `tests` steps failed, and the `SLACK_WEBHOOK` is available. The latter is not the case for
87-
# pull requests that come from forks. This is a limitation of secrets on GHA
88-
if: always() && (steps.install.outcome == 'failure' || steps.pytest-tests.outcome == 'failure' || steps.daemon-tests.outcome == 'failure') && env.SLACK_WEBHOOK != null
89-
uses: rtCamp/action-slack-notify@v2
85+
# Always run this step (otherwise it would be skipped if any of the previous steps fail)
86+
# but only if the `install` or `tests` steps failed.
87+
# Don't run on PRs, the failure is clearly visible in GitHub UI.
88+
# Run only when the `secrets.SLACK_WEBHOOK` is available, which is not the case for forks.
89+
if: >-
90+
always() &&
91+
(steps.install.outcome == 'failure' ||
92+
steps.pytest-tests.outcome == 'failure' ||
93+
steps.daemon-tests.outcome == 'failure') &&
94+
github.event_name != 'pull_request' &&
95+
env.SLACK_WEBHOOK != null
96+
uses: ./.github/actions/slack-notification
9097
env:
9198
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
92-
SLACK_ICON: https://www.materialscloud.org/discover/images/0ba0a17d.aiida-logo-128.png
93-
SLACK_CHANNEL: dev-aiida-core
94-
SLACK_COLOR: b60205
95-
SLACK_TITLE: Nightly build of `aiida-core/main` failed
96-
SLACK_MESSAGE: The tests of the `nightly.yml` GHA worklow failed.
99+
with:
100+
title: Nightly build of `aiida-core/main` failed
101+
message: The tests of the `nightly.yml` GHA worklow failed.
97102

98103

99104
# Run a subset of test suite to ensure compatibility with latest RabbitMQ releases
@@ -139,15 +144,18 @@ jobs:
139144
run: pytest -s --db-backend sqlite -m 'requires_rmq' tests/
140145

141146
- name: Slack notification
142-
# Always run this step (otherwise it would be skipped if any of the previous steps fail) but only if the
143-
# `install` or `tests` steps failed, and the `SLACK_WEBHOOK` is available. The latter is not the case for
144-
# pull requests that come from forks. This is a limitation of secrets on GHA
145-
if: always() && (steps.install.outcome == 'failure' || steps.tests.outcome == 'failure') && env.SLACK_WEBHOOK != null
146-
uses: rtCamp/action-slack-notify@v2
147+
# Always run this step (otherwise it would be skipped if any of the previous steps fail)
148+
# but only if the `install` or `tests` steps failed.
149+
# Don't run on PRs, the failure is clearly visible in GitHub UI.
150+
# Run only when the `secrets.SLACK_WEBHOOK` is available, which is not the case for forks.
151+
if: >-
152+
always() &&
153+
(steps.install.outcome == 'failure' || steps.tests.outcome == 'failure') &&
154+
github.event_name != 'pull_request' &&
155+
env.SLACK_WEBHOOK != null
156+
uses: ./.github/actions/slack-notification
147157
env:
148158
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
149-
SLACK_ICON: https://www.materialscloud.org/discover/images/0ba0a17d.aiida-logo-128.png
150-
SLACK_CHANNEL: dev-aiida-core
151-
SLACK_COLOR: b60205
152-
SLACK_TITLE: RabbitMQ nightly tests of `aiida-core/main` failed
153-
SLACK_MESSAGE: The rabbitmq tests in the `nightly.yml` GHA worklow failed.
159+
with:
160+
title: RabbitMQ nightly tests of `aiida-core/main` failed
161+
message: RabbitMQ (${{ matrix.rabbitmq-version }}) tests in the `nightly.yml` GHA worklow failed.

.github/workflows/test-install.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ jobs:
195195
run: sudo apt update && sudo apt install postgresql graphviz
196196

197197
- name: Install aiida-core
198+
id: install
198199
uses: ./.github/actions/install-aiida-core
199200
with:
200201
python-version: ${{ matrix.python-version }}
@@ -205,8 +206,26 @@ jobs:
205206
run: .github/workflows/setup.sh
206207

207208
- name: Run test suite
209+
id: tests
208210
env:
209211
AIIDA_TEST_PROFILE: test_aiida
210212
AIIDA_WARN_v3: 1
211213
run: |
212214
pytest -n auto --db-backend psql -m 'not nightly' tests/
215+
216+
- name: Slack notification
217+
# Always run this step (otherwise it would be skipped if any of the previous steps fail)
218+
# but only if the `install` or `tests` steps failed.
219+
# Don't run on PRs, the failure is clearly visible in GitHub UI.
220+
# Run only when the `secrets.SLACK_WEBHOOK` is available, which is not the case for forks.
221+
if: >-
222+
always() &&
223+
(steps.install.outcome == 'failure' || steps.tests.outcome == 'failure') &&
224+
github.event_name != 'pull_request' &&
225+
env.SLACK_WEBHOOK != null
226+
uses: ./.github/actions/slack-notification
227+
env:
228+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
229+
with:
230+
title: Install tests of `aiida-core/main` failed
231+
message: '`test-install.yml` GHA workflow for Python ${{ matrix.python-version }} failed.'

0 commit comments

Comments
 (0)