GitHub Actions part 2: test every pull request, test on a schedule, and keep the report
Start the tests on every pull request and every night, make the result a check that must pass before merging, and upload the report so anyone can open it.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a lighthouse keeper's lamp check. Every night the keeper checks the lamp, whether or not a ship asked. When a new course is proposed, the keeper checks again. A page of the log goes to the harbour office. A rule at the harbour says a ship may not sail while the page is marked bad.
The night check is the schedule. The proposed course is the . The page is the uploaded report. The harbour rule is the .
Mei works with Tom, a tester at Daily List, a to-do list app, to set all three.
What it is: This slice of GitHub Actions starts a workflow on a pull request and on a timer. are the pull_request and schedule keys. A GitHub Actions required status check must pass before a merge, and a is a saved report. A local pytest run is the neighbour. It does not block the merge button.
Why it matters: A pull request with no required check can merge a broken Daily List build. A night run catches a failure that nobody pushed today. A lost report forces Tom to retest. The three together let Mei see the result and stop a bad merge.
PLAIN WORDS · 4 in this section
- github
- a web site that hosts code and runs checks
- workflow
- the steps a piece of work follows, start to finish
- pytest
- A free Python tool that finds and runs checks.
- retest
- test again
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB A lighthouse keeper's lamp check.
- Evening
- Ship
- Logbook
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The evening lamp check | The scheduled trigger |
| The check for a new ship | The pull request trigger |
| The harbour office rule | The required status check |
| The record book page | The uploaded artifact |
WHERE THIS PICTURE STOPS
- The keeper checks the same lamp, but a schedule checks the default branch only.
- A harbour rule can be bent, but a required check blocks the merge.
- A record book page is kept long, but an artifact is kept for limited days.
HOOK
Evening check, ship check, record book.
TELL A FRIEND
A keeper with a lamp and a record book.
OFTEN MIXED UP WITH GitHub Actions part 1: write your first workflow file and read the run log. That topic writes the first . This one adds triggers, a and a saved report.
PRACTISE AND KEEP
Sources for this topic — 4 sources
- Market practice
Events that trigger workflows (GitHub Docs) ↗ — GitHub Docs · GitHub Docs on events: schedule uses five-field cron in Coordinated Universal Time by default, the shortest gap is five minutes, scheduled runs use the latest commit on the default branch, and busy times such as the start of an hour can delay a run
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Store and share data with workflow artifacts (GitHub Docs) ↗ — GitHub Docs · GitHub Docs artifact guide: upload-artifact takes a name and a path, retention-days is capped by the repository limit, a Python example uses if always so results upload even when tests fail, and deleting a run deletes its artifacts
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Status checks (GitHub Docs) ↗ — GitHub Docs · GitHub Docs on status checks: a required status check must pass before a pull request can merge
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
About protected branches and required status checks (GitHub Docs) ↗ — GitHub · The GitHub pages on protected branches: required status checks must pass before a merge. An optional setting needs the branch to be up to date. A check must have run in the past seven days and be successful, skipped or neutral.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.