Skip to content

Commit 930641c

Browse files
CI: Send Slack message when nightly fails (#2616)
`github_status` is renamed `report_status` to reflect the expanded scope. The `report_status` jobs now declare `dependencies: []` which prevents them from downloading artifacts they have no use for.
1 parent b242d02 commit 930641c

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

.ci/set_github_status.sh renamed to .ci/report_status.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@ curl --url "https://api.github.com/repos/${username}/${repo}/statuses/${CI_COMMI
77
--header 'Content-Type: application/json' \
88
--header "authorization: Bearer ${GITHUB_STATUS_TOKEN}" \
99
--data "{ \"state\": \"${commit_status}\", \"target_url\": \"${CI_PIPELINE_URL}\", \"description\": \"All Gitlab pipelines\", \"context\": \"ci/gitlab/gitlab.com\" }"
10+
11+
if [ "$CI_PIPELINE_SOURCE" = schedule -a "$commit_status" = failure ]; then
12+
# Send a Slack message to #monitor
13+
curl --url "https://slack.com/api/chat.postMessage" --request POST \
14+
--header "Authorization: Bearer ${SLACK_BOT_TOKEN}" \
15+
--data "channel=CQR9YG4CT" \
16+
--data "text=Nightly for \`${CI_COMMIT_BRANCH}\` <${CI_PIPELINE_URL}|*failed*>!"
17+
fi

.gitlab-ci.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,31 +111,35 @@ hackage-release:
111111
rules:
112112
- if: '$CI_COMMIT_TAG != null' # tags
113113

114-
# Work around https://gitlab.com/gitlab-org/gitlab/-/issues/216629
114+
# We manually report status to GitHub to work around
115+
# <https://gitlab.com/gitlab-org/gitlab/-/issues/216629>.
116+
# The script will also send a Slack message when the nightly fails.
115117
#
116-
# If we ever remove this, we may have to rethink the use of the interruptible flag
117-
.github_status:
118+
# If we ever remove this manual GitHub reporting, we may have to rethink the
119+
# use of the interruptible flag: see <https://github.com/clash-lang/clash-compiler/pull/2616#discussion_r1409429185>
120+
.report_status:
118121
# interruptible: false
119122
image: curlimages/curl
123+
dependencies: []
120124
variables:
121125
GIT_SUBMODULE_STRATEGY: recursive
122126

123127
set_pending:
124-
extends: .github_status
128+
extends: .report_status
125129
stage: pre
126130
script:
127-
- .ci/set_github_status.sh pending
131+
- .ci/report_status.sh pending
128132

129133
set_success:
130-
extends: .github_status
134+
extends: .report_status
131135
stage: post
132136
when: on_success
133137
script:
134-
- .ci/set_github_status.sh success
138+
- .ci/report_status.sh success
135139

136140
set_failure:
137-
extends: .github_status
141+
extends: .report_status
138142
stage: post
139143
when: on_failure
140144
script:
141-
- .ci/set_github_status.sh failure
145+
- .ci/report_status.sh failure

0 commit comments

Comments
 (0)