Skip to content

Commit 5b0e954

Browse files
authored
Merge pull request #609 from per1234/check-poetry
Add templates for checking Poetry configuration files
2 parents fbcf2a6 + e1956fd commit 5b0e954

File tree

8 files changed

+344
-3
lines changed

8 files changed

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

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
[![Check Community Health Files Sync status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-community-health-sync.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-community-health-sync.yml)
1616
[![Check Configuration Files Sync status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-config-sync.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-config-sync.yml)
1717
[![Check Markdown status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-markdown-task.yml)
18+
[![Check Poetry status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-poetry-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-poetry-task.yml)
1819
[![Check Prettier Formatting status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-prettier-formatting-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-prettier-formatting-task.yml)
1920
[![Check Taskfiles status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-taskfiles.yml)
2021
[![Check YAML status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-yaml-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-yaml-task.yml)

Taskfile.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ tasks:
2929
- task: markdown:check-links
3030
- task: markdown:lint
3131
- task: markdownlint:validate
32+
- task: poetry:validate
3233
- task: python:lint
3334
- task: python:test
3435
- task: shell:check
@@ -50,6 +51,7 @@ tasks:
5051
- task: js:fix
5152
- task: markdown:fix
5253
- task: npm:fix-config
54+
- task: poetry:sync
5355
- task: python:format
5456
- task: shell:format
5557
vars:
@@ -67,6 +69,7 @@ tasks:
6769
"{{.WORKFLOW_TEMPLATES_PATH}}/check-javascript-task.yml" \
6870
"{{.WORKFLOW_TEMPLATES_PATH}}/check-markdown-task.yml" \
6971
"{{.WORKFLOW_TEMPLATES_PATH}}/check-npm-task.yml" \
72+
"{{.WORKFLOW_TEMPLATES_PATH}}/check-poetry-task.yml" \
7073
"{{.WORKFLOW_TEMPLATES_PATH}}/check-prettier-formatting-task.yml" \
7174
"{{.WORKFLOW_TEMPLATES_PATH}}/check-python-task.yml" \
7275
"{{.WORKFLOW_TEMPLATES_PATH}}/check-taskfiles.yml" \
@@ -897,6 +900,16 @@ tasks:
897900
poetry install \
898901
{{if .POETRY_GROUPS}} --only {{.POETRY_GROUPS}} {{end}}
899902
903+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-poetry-task/Taskfile.yml
904+
poetry:sync:
905+
desc: Sync Poetry lockfile
906+
deps:
907+
- task: poetry:install
908+
cmds:
909+
- |
910+
poetry lock \
911+
--no-cache
912+
900913
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
901914
poetry:update-deps:
902915
desc: Update all dependencies managed by Poetry to their newest versions
@@ -905,6 +918,17 @@ tasks:
905918
cmds:
906919
- poetry update
907920

921+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-poetry-task/Taskfile.yml
922+
poetry:validate:
923+
desc: Validate Poetry configuration
924+
deps:
925+
- task: poetry:install
926+
cmds:
927+
- |
928+
poetry check \
929+
--lock \
930+
--strict
931+
908932
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-python-task/Taskfile.yml
909933
python:format:
910934
desc: Format Python files

poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package-mode = false
77
[tool.poetry.dependencies]
88
python = "~3.9"
99

10-
[tool.poetry.dev-dependencies]
10+
[tool.poetry.group.dev.dependencies]
1111
yamllint = "^v1.37.1"
1212
codespell = "^2.4.1"
1313
black = "^25.1"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# See: https://taskfile.dev/#/usage
2+
version: "3"
3+
4+
tasks:
5+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-poetry-task/Taskfile.yml
6+
poetry:sync:
7+
desc: Sync Poetry lockfile
8+
deps:
9+
- task: poetry:install
10+
cmds:
11+
- |
12+
poetry lock \
13+
--no-cache
14+
15+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-poetry-task/Taskfile.yml
16+
poetry:validate:
17+
desc: Validate Poetry configuration
18+
deps:
19+
- task: poetry:install
20+
cmds:
21+
- |
22+
poetry check \
23+
--lock \
24+
--strict
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# "Check Poetry" workflow (Task)
2+
3+
Check for problems with configuration files of the [**Poetry**](https://python-poetry.org/) Python package manager.
4+
5+
This is the version of the workflow for projects using the [Task](https://taskfile.dev/#/) task runner tool.
6+
7+
## Installation
8+
9+
### Workflow
10+
11+
Install the [check-poetry-task.yml](check-poetry-task.yml) GitHub Actions workflow to `.github/workflows/`
12+
13+
### Assets
14+
15+
- [`Taskfile.yml`](assets/check-poetry-task/Taskfile.yml) - Validation tasks.
16+
- Install to: repository root (or merge into the existing `Taskfile.yml`).
17+
- [`Taskfile.yml`](assets/poetry-task/Taskfile.yml) - Installation task.
18+
- Merge into `Taskfile.yml`
19+
20+
## Readme badge
21+
22+
Markdown badge:
23+
24+
```markdown
25+
[![Check Poetry status](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/check-poetry-task.yml/badge.svg)](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/check-poetry-task.yml)
26+
```
27+
28+
Replace the `REPO_OWNER` and `REPO_NAME` placeholders in the URLs with the final repository owner and name ([example](https://raw.githubusercontent.com/arduino-libraries/ArduinoIoTCloud/master/README.md)).
29+
30+
---
31+
32+
Asciidoc badge:
33+
34+
```adoc
35+
image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-poetry-task.yml/badge.svg["Check YAML status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-poetry-task.yml"]
36+
```
37+
38+
Define the `{repository-owner}` and `{repository-name}` attributes and use them throughout the readme ([example](https://raw.githubusercontent.com/arduino-libraries/WiFiNINA/master/README.adoc)).
39+
40+
## Commit message
41+
42+
```
43+
Add infrastructure for checking Poetry configuration files
44+
45+
The project's Python package dependencies are managed using the "Poetry" tool.
46+
47+
Tasks and a GitHub Actions workflow are added to maintain and check for problems in the Poetry configuration files.
48+
49+
The tasks provide the following operations:
50+
51+
* Check for problems with the data structure of the `pyproject.toml` Python project file
52+
* Update the `poetry.lock` file as may be required following manual modifications to `pyproject.toml`, or update of the
53+
"Poetry" application
54+
55+
These tasks are executed by the GitHub Actions workflow on any push or pull request that modifies relevant files, and
56+
periodically to check for breakage caused by external changes.
57+
```
58+
59+
## PR message
60+
61+
```markdown
62+
The project's Python package dependencies are managed using the [**Poetry**](https://python-poetry.org/) tool.
63+
64+
[Tasks](https://taskfile.dev/) and a GitHub Actions workflow are added to maintain and check for problems in the **Poetry** configuration files.
65+
66+
The tasks provide the following operations:
67+
68+
- Check for problems with the data structure of the [`pyproject.toml`](https://python-poetry.org/docs/pyproject/) Python project file
69+
- Update the `poetry.lock` file as may be required following manual modifications to `pyproject.toml`, or update of the **Poetry** application
70+
71+
These tasks are executed by the GitHub Actions workflow on any push or pull request that modifies relevant files, and periodically to check for breakage caused by external changes.
72+
```

0 commit comments

Comments
 (0)