Skip to content

Commit

Permalink
Add nightly build test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
gasman committed Aug 10, 2023
1 parent 87d5f67 commit 34dcea3
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/report_nightly_build_failure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

"""
Called by GitHub Action when the nightly build fails.
This reports an error to the #nightly-build-failures Slack channel.
"""
import os
import requests

if "SLACK_WEBHOOK_URL" in os.environ:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
repository = os.environ["GITHUB_REPOSITORY"]
run_id = os.environ["GITHUB_RUN_ID"]
url = f"https://github.com/{repository}/actions/runs/{run_id}"

print("Reporting to #nightly-build-failures slack channel")
response = requests.post(
os.environ["SLACK_WEBHOOK_URL"],
json={
"text": f"A Nightly build failed. See {url}",
},
)

print(f"Slack responded with: {response}")

else:
print(
"Unable to report to #nightly-build-failures slack channel because SLACK_WEBHOOK_URL is not set"
)
35 changes: 35 additions & 0 deletions .github/workflows/nightly-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Nightly Wagtail test

on:
schedule:
- cron: "20 1 * * *"

workflow_dispatch:

jobs:
nightly-test:
# Cannot check the existence of secrets, so limiting to repository name to prevent all forks to run nightly.
# See: https://github.com/actions/runner/issues/520
if: ${{ github.repository == 'torchbox/wagtail-experiments' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install "git+https://github.com/wagtail/wagtail.git@main#egg=wagtail"
pip install -e .[testing]
- name: Test
id: test
continue-on-error: true
run: ./runtests.py
- name: Send Slack notification on failure
if: steps.test.outcome == 'failure'
run: |
python .github/report_nightly_build_failure.py
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

0 comments on commit 34dcea3

Please sign in to comment.