Post to zulip if the nightly-testing branch is failing. #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Post to zulip if the nightly-testing branch is failing. | |
on: | |
workflow_run: | |
workflows: ["ci"] | |
types: | |
- completed | |
jobs: | |
# Whenever `nightly-testing` fails CI, | |
# notify the 'mathlib reviewers' stream on Zulip. | |
handle_failure: | |
if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.head_branch == 'nightly-testing' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Send message on Zulip | |
uses: zulip/github-actions-zulip/send-message@v1 | |
with: | |
api-key: ${{ secrets.ZULIP_API_KEY }} | |
email: '[email protected]' | |
organization-url: 'https://leanprover.zulipchat.com' | |
to: 'mathlib reviewers' | |
type: 'stream' | |
topic: 'CI failure on the nightly-testing branch' | |
content: | | |
The latest CI for Std's [`nightly-testing`](https://github.com/leanprover/std4/tree/nightly-testing) branch has [failed](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}). | |
# Whenever `nightly-testing` passes CI, | |
# push it to `nightly-testing-YYYY-MM-DD` so we have a known good version of Std on that nightly release. | |
handle_success: | |
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'nightly-testing' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: nightly-testing # checkout nightly-testing branch | |
fetch-depth: 0 # checkout all branches so that we can push from `nightly-testing` to `nightly-testing-YYYY-MM-DD` | |
token: ${{ secrets.NIGHTLY_TESTING }} | |
- name: Update the nightly-testing-YYYY-MM-DD branch | |
run: | | |
toolchain=$(<lean-toolchain) | |
if [[ $toolchain =~ leanprover/lean4:nightly-([a-zA-Z0-9_-]+) ]]; then | |
version=${BASH_REMATCH[1]} | |
git push origin refs/heads/nightly-testing:refs/heads/nightly-testing-$version | |
else | |
echo "Error: The file lean-toolchain does not contain the expected pattern." | |
exit 1 | |
fi |