Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .github/workflows/check-poetry-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-poetry-task.md
name: Check Poetry

on:
create:
push:
paths:
- ".github/workflows/check-poetry-task.ya?ml"
- "go.mod"
- "go.sum"
- "poetry.lock"
- "pyproject.toml"
- "Taskfile.ya?ml"
pull_request:
paths:
- ".github/workflows/check-poetry-task.ya?ml"
- "go.mod"
- "go.sum"
- "poetry.lock"
- "pyproject.toml"
- "Taskfile.ya?ml"
schedule:
# Run periodically to catch breakage caused by external changes.
- cron: "0 11 * * THU"
workflow_dispatch:
repository_dispatch:

jobs:
run-determination:
runs-on: ubuntu-latest
permissions: {}
outputs:
result: ${{ steps.determination.outputs.result }}
steps:
- name: Determine if the rest of the workflow should run
id: determination
run: |
RELEASE_BRANCH_REGEX="^refs/heads/((v[0-9]+)|([0-9]+\.[0-9]+\.x))$"
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
if [[
"${{ github.event_name }}" != "create" ||
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
]]; then
# Run the other jobs.
RESULT="true"
else
# There is no need to run the other jobs.
RESULT="false"
fi

echo "result=$RESULT" >>$GITHUB_OUTPUT

validate:
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Install Python
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml

- name: Install Task
uses: arduino/setup-task@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Validate configuration
run: |
task \
--silent \
poetry:validate

check-sync:
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Install Python
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml

- name: Install Task
uses: arduino/setup-task@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Sync lockfile
run: |
task \
--silent \
poetry:sync

- name: Check if lockfile was out of sync
run: |
git diff \
--color \
--exit-code \
poetry.lock
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[![Publish Tester Build status](https://github.com/arduino/arduino-lint/actions/workflows/publish-go-tester-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/publish-go-tester-task.yml)
[![Publish Nightly Build status](https://github.com/arduino/arduino-lint/actions/workflows/publish-go-nightly-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/publish-go-nightly-task.yml)
[![Check npm status](https://github.com/arduino/arduino-lint/actions/workflows/check-npm-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-npm-task.yml)
[![Check Poetry status](https://github.com/arduino/arduino-lint/actions/workflows/check-poetry-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-poetry-task.yml)
[![Check Python status](https://github.com/arduino/arduino-lint/actions/workflows/check-python-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-python-task.yml)
[![Check Markdown status](https://github.com/arduino/arduino-lint/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-markdown-task.yml)
[![Spell Check status](https://github.com/arduino/arduino-lint/actions/workflows/spell-check-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/spell-check-task.yml)
Expand Down
23 changes: 23 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ tasks:
GO_MODULE_PATH: ./ruledocsgen
- task: markdown:lint
- task: markdown:check-links
- task: poetry:validate
- task: python:lint
- task: shell:check
vars:
Expand Down Expand Up @@ -142,6 +143,7 @@ tasks:
GO_MODULE_PATH: ./ruledocsgen
- task: markdown:fix
- task: npm:fix-config
- task: poetry:sync
- task: python:format
- task: shell:format
vars:
Expand Down Expand Up @@ -664,6 +666,16 @@ tasks:
poetry install \
{{if .POETRY_GROUPS}} --only {{.POETRY_GROUPS}} {{end}}

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-poetry-task/Taskfile.yml
poetry:sync:
desc: Sync Poetry lockfile
deps:
- task: poetry:install
cmds:
- |
poetry lock \
--no-cache

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
poetry:update-deps:
desc: Update all dependencies managed by Poetry to their newest versions
Expand All @@ -672,6 +684,17 @@ tasks:
cmds:
- poetry update

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-poetry-task/Taskfile.yml
poetry:validate:
desc: Validate Poetry configuration
deps:
- task: poetry:install
cmds:
- |
poetry check \
--lock \
--strict

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-python-task/Taskfile.yml
python:format:
desc: Format Python files
Expand Down
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ poetry = "2.1.4"
[tool.poetry.dependencies]
python = "~3.9"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
black = "^25.1"
codespell = "^2.4.1"
flake8 = "^7.3.0"
Expand Down
Loading