File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ """
3+ Called by GitHub Action when the nightly build fails.
4+ This reports an error to the #nightly-build-failures Slack channel.
5+ """
6+ import os
7+ import requests
8+
9+ if "SLACK_WEBHOOK_URL" in os .environ :
10+ # https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
11+ repository = os .environ ["GITHUB_REPOSITORY" ]
12+ run_id = os .environ ["GITHUB_RUN_ID" ]
13+ url = f"https://github.com/{ repository } /actions/runs/{ run_id } "
14+
15+ print ("Reporting to #nightly-build-failures slack channel" )
16+ response = requests .post (
17+ os .environ ["SLACK_WEBHOOK_URL" ],
18+ json = {
19+ "text" : f"A Nightly build failed. See { url } " ,
20+ },
21+ )
22+
23+ print (f"Slack responded with: { response } " )
24+
25+ else :
26+ print (
27+ "Unable to report to #nightly-build-failures slack channel because SLACK_WEBHOOK_URL is not set"
28+ )
Original file line number Diff line number Diff line change 1+ name : Nightly Wagtail test
2+
3+ on :
4+ schedule :
5+ - cron : " 20 1 * * *"
6+
7+ workflow_dispatch :
8+
9+ jobs :
10+ nightly-test :
11+ # Cannot check the existence of secrets, so limiting to repository name to prevent all forks to run nightly.
12+ # See: https://github.com/actions/runner/issues/520
13+ if : ${{ github.repository == 'torchbox/wagtail-experiments' }}
14+ runs-on : ubuntu-latest
15+ steps :
16+ - uses : actions/checkout@v2
17+ - name : Set up Python 3.9
18+ uses : actions/setup-python@v2
19+ with :
20+ python-version : 3.9
21+ - name : Install dependencies
22+ run : |
23+ python -m pip install --upgrade pip
24+ pip install "git+https://github.com/wagtail/wagtail.git@main#egg=wagtail"
25+ pip install -e .[testing]
26+ - name : Test
27+ id : test
28+ continue-on-error : true
29+ run : ./runtests.py
30+ - name : Send Slack notification on failure
31+ if : steps.test.outcome == 'failure'
32+ run : |
33+ python .github/report_nightly_build_failure.py
34+ env :
35+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
You can’t perform that action at this time.
0 commit comments