Skip to content

Commit 573eab4

Browse files
authored
Merge pull request #296 from per1234/lockfile
Add infrastructure for checking Poetry configuration files
2 parents b394d22 + 8896832 commit 573eab4

File tree

4 files changed

+1812
-1683
lines changed

4 files changed

+1812
-1683
lines changed
+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Check Poetry
2+
3+
on:
4+
create:
5+
push:
6+
paths:
7+
- ".github/workflows/check-poetry-task.ya?ml"
8+
- "**/poetry.lock"
9+
- "**/pyproject.toml"
10+
- "Taskfile.ya?ml"
11+
pull_request:
12+
paths:
13+
- ".github/workflows/check-poetry-task.ya?ml"
14+
- "**/poetry.lock"
15+
- "**/pyproject.toml"
16+
- "Taskfile.ya?ml"
17+
schedule:
18+
# Run periodically to catch breakage caused by external changes.
19+
- cron: "0 11 * * THU"
20+
workflow_dispatch:
21+
repository_dispatch:
22+
23+
jobs:
24+
run-determination:
25+
runs-on: ubuntu-latest
26+
permissions: {}
27+
outputs:
28+
result: ${{ steps.determination.outputs.result }}
29+
steps:
30+
- name: Determine if the rest of the workflow should run
31+
id: determination
32+
run: |
33+
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
34+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
35+
if [[
36+
"${{ github.event_name }}" != "create" ||
37+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
38+
]]; then
39+
# Run the other jobs.
40+
RESULT="true"
41+
else
42+
# There is no need to run the other jobs.
43+
RESULT="false"
44+
fi
45+
46+
echo "result=$RESULT" >> $GITHUB_OUTPUT
47+
48+
validate:
49+
needs: run-determination
50+
if: needs.run-determination.outputs.result == 'true'
51+
runs-on: ubuntu-latest
52+
permissions:
53+
contents: read
54+
55+
steps:
56+
- name: Checkout repository
57+
uses: actions/checkout@v4
58+
59+
- name: Install Python
60+
uses: actions/setup-python@v5
61+
with:
62+
python-version-file: pyproject.toml
63+
64+
- name: Install Task
65+
uses: arduino/setup-task@v2
66+
with:
67+
repo-token: ${{ secrets.GITHUB_TOKEN }}
68+
version: 3.x
69+
70+
- name: Validate pyproject.toml
71+
run: |
72+
task \
73+
--silent \
74+
poetry:validate
75+
76+
check-sync:
77+
needs: run-determination
78+
if: needs.run-determination.outputs.result == 'true'
79+
runs-on: ubuntu-latest
80+
permissions:
81+
contents: read
82+
83+
steps:
84+
- name: Checkout repository
85+
uses: actions/checkout@v4
86+
87+
- name: Install Python
88+
uses: actions/setup-python@v5
89+
with:
90+
python-version-file: pyproject.toml
91+
92+
- name: Install Task
93+
uses: arduino/setup-task@v2
94+
with:
95+
repo-token: ${{ secrets.GITHUB_TOKEN }}
96+
version: 3.x
97+
98+
- name: Sync lockfile
99+
run: |
100+
task \
101+
--silent \
102+
poetry:sync
103+
104+
- name: Check if lockfile was out of sync
105+
run: |
106+
git diff \
107+
--color \
108+
--exit-code \
109+
poetry.lock

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[![Check License status](https://github.com/arduino/compile-sketches/actions/workflows/check-license.yml/badge.svg)](https://github.com/arduino/compile-sketches/actions/workflows/check-license.yml)
77
[![Check Markdown status](https://github.com/arduino/compile-sketches/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/compile-sketches/actions/workflows/check-markdown-task.yml)
88
[![Check npm status](https://github.com/arduino/compile-sketches/actions/workflows/check-npm-task.yml/badge.svg)](https://github.com/arduino/compile-sketches/actions/workflows/check-npm-task.yml)
9+
[![Check Poetry status](https://github.com/arduino/compile-sketches/actions/workflows/check-poetry-task.yml/badge.svg)](https://github.com/arduino/compile-sketches/actions/workflows/check-poetry-task.yml)
910
[![Check Prettier Formatting status](https://github.com/arduino/compile-sketches/actions/workflows/check-prettier-formatting-task.yml/badge.svg)](https://github.com/arduino/compile-sketches/actions/workflows/check-prettier-formatting-task.yml)
1011
[![Check Python status](https://github.com/arduino/compile-sketches/actions/workflows/check-python-task.yml/badge.svg)](https://github.com/arduino/compile-sketches/actions/workflows/check-python-task.yml)
1112
[![Check Taskfiles status](https://github.com/arduino/compile-sketches/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/arduino/compile-sketches/actions/workflows/check-taskfiles.yml)

Taskfile.yml

+19
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,25 @@ tasks:
423423
--no-root \
424424
{{if .POETRY_GROUPS}} --only {{.POETRY_GROUPS}} {{end}}
425425
426+
poetry:sync:
427+
desc: Sync poetry.lock
428+
deps:
429+
- task: poetry:install
430+
cmds:
431+
- |
432+
poetry lock \
433+
--no-cache \
434+
--no-update
435+
436+
poetry:validate:
437+
desc: Validate pyproject.toml
438+
deps:
439+
- task: poetry:install
440+
cmds:
441+
- |
442+
poetry check \
443+
--lock
444+
426445
python:coverage-report:
427446
desc: Show code coverage report
428447
deps:

0 commit comments

Comments
 (0)