-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trigger test action if wikitextprocessor is updated after the last test.
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Test schedule | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 * * *" | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test_schedule: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
- run: python -m pip install requests | ||
- run: python tools/test_schedule.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import sys | ||
from datetime import datetime | ||
|
||
import requests | ||
|
||
|
||
def main() -> int: | ||
""" | ||
This code runs daily to trigger test action then update container image if | ||
wikitextprocessor's code is newer than the version used in the latest test. | ||
https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-workflow | ||
""" | ||
|
||
r = requests.get( | ||
"https://api.github.com/repos/tatuylonen/wiktextract/actions/workflows/59463306/runs?branch=master&per_page=1" | ||
) | ||
latest_test = datetime.fromisoformat( | ||
r.json()["workflow_runs"][0]["created_at"] | ||
) | ||
r = requests.get( | ||
"https://api.github.com/repos/tatuylonen/wikitextprocessor/commits/main" | ||
) | ||
latest_wikitextprocessor_commit = datetime.fromisoformat( | ||
r.json()["commit"]["committer"]["date"] | ||
) | ||
if latest_test < latest_wikitextprocessor_commit: | ||
return 0 | ||
return 1 | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |