Skip to content

Commit bdf3c7f

Browse files
committed
Run CI build and tests on schedule
Run CI build and test matrix on a schedule and report failures as an issue. Taken from the beman.examplar CI.
1 parent b4c7cfd commit bdf3c7f

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
name: CI Tests
22
on:
3+
# Allows you to run this workflow manually from the Actions tab
34
workflow_dispatch:
45
push:
5-
branches: [main]
66
pull_request:
7-
branches: [main]
7+
schedule:
8+
# minute hour day month day-of-week
9+
# Run at 12:25 UTC every day
10+
- cron: '25 12 * * *'
11+
812
jobs:
913
build:
1014
name: ${{ matrix.config.name }}
@@ -135,3 +139,30 @@ jobs:
135139
with:
136140
file: ${{runner.workspace}}/optional/.build/coverage.json
137141
github-token: ${{ secrets.GITHUB_TOKEN }}
142+
143+
create-issue-when-fault:
144+
runs-on: ubuntu-latest
145+
needs: [preset-test, gtest-test, configuration-test, compiler-test]
146+
if: failure() && github.event_name == 'schedule'
147+
steps:
148+
# See https://github.com/cli/cli/issues/5075
149+
- uses: actions/checkout@v4
150+
- name: Create issue
151+
run: |
152+
issue_num=$(gh issue list -s open -S "[SCHEDULED-BUILD] Build & Test failure" -L 1 --json number | jq 'if length == 0 then -1 else .[0].number end')
153+
154+
body="**Build-and-Test Failure Report**
155+
- **Time of Failure**: $(date -u '+%B %d, %Y, %H:%M %Z')
156+
- **Commit**: [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})
157+
- **Action Run**: [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
158+
159+
The scheduled build-and-test triggered by cron has failed.
160+
Please investigate the logs and recent changes associated with this commit or rerun the workflow if you believe this is an error."
161+
162+
if [[ $issue_num -eq -1 ]]; then
163+
gh issue create --repo ${{ github.repository }} --title "[SCHEDULED-BUILD] Build & Test failure" --body "$body"
164+
else
165+
gh issue comment --repo ${{ github.repository }} $issue_num --body "$body"
166+
fi
167+
env:
168+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)