Skip to content

Commit 454754f

Browse files
authored
Merge branch 'main' into remove-post-approval-flag
2 parents 194ce29 + cac36cb commit 454754f

21 files changed

+930
-297
lines changed

.flake8

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-python/.flake8
2+
# See: https://flake8.pycqa.org/en/latest/user/configuration.html
3+
# The code style defined in this file is the official standardized style to be used in all Arduino tooling projects and
4+
# should not be modified.
5+
6+
[flake8]
7+
doctests = True
8+
# W503 and W504 are mutually exclusive. PEP 8 recommends line break before.
9+
ignore = W503
10+
max-complexity = 10
11+
max-line-length = 120
12+
select = E,W,F,C,N

.github/dependabot.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,28 @@ updates:
55
# Configure check for outdated GitHub Actions actions in workflows.
66
# See: https://docs.github.com/en/code-security/supply-chain-security/keeping-your-actions-up-to-date-with-dependabot
77
- package-ecosystem: github-actions
8+
assignees:
9+
- per1234
810
directory: / # Check the repository's workflows under /.github/workflows/
911
schedule:
1012
interval: daily
1113
labels:
1214
- "topic: infrastructure"
15+
16+
- package-ecosystem: npm
17+
assignees:
18+
- per1234
19+
directory: /
20+
schedule:
21+
interval: daily
22+
labels:
23+
- "topic: infrastructure"
24+
25+
- package-ecosystem: pip
26+
assignees:
27+
- per1234
28+
directory: /
29+
schedule:
30+
interval: daily
31+
labels:
32+
- "topic: infrastructure"
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Check Category Order Metadata
2+
3+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
4+
on:
5+
create:
6+
push:
7+
paths:
8+
- ".github/workflows/check-order-metadata-task.ya?ml"
9+
- "poetry.lock"
10+
- "pyproject.toml"
11+
- "Taskfile.ya?ml"
12+
- "assets/generate-category-order-metadata/*"
13+
- "content/categories/order.md"
14+
pull_request:
15+
paths:
16+
- ".github/workflows/check-order-metadata-task.ya?ml"
17+
- "poetry.lock"
18+
- "pyproject.toml"
19+
- "Taskfile.ya?ml"
20+
- "assets/generate-category-order-metadata/*"
21+
- "content/categories/order.md"
22+
schedule:
23+
# Run periodically to catch breakage caused by external changes.
24+
- cron: "0 3 * * FRI"
25+
workflow_dispatch:
26+
repository_dispatch:
27+
28+
jobs:
29+
run-determination:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
result: ${{ steps.determination.outputs.result }}
33+
steps:
34+
- name: Determine if the rest of the workflow should run
35+
id: determination
36+
run: |
37+
if [[ "${{ secrets.ARDUINO_FORUM_API_KEY }}" == "" ]]; then
38+
# Required API key secret is not defined.
39+
RESULT="false"
40+
else
41+
RESULT="true"
42+
fi
43+
44+
echo "result=$RESULT" >> $GITHUB_OUTPUT
45+
46+
check-order-metadata:
47+
needs: run-determination
48+
if: needs.run-determination.outputs.result == 'true'
49+
runs-on: ubuntu-latest
50+
env:
51+
ARTIFACT_NAME: category-order-metadata
52+
CATEGORY_ORDER_METADATA_FILE_PATH: content/categories/order.md
53+
steps:
54+
- name: Checkout repository
55+
uses: actions/checkout@v3
56+
57+
- name: Install Poetry
58+
run: |
59+
pipx install \
60+
--python "$(which python)" \
61+
poetry
62+
63+
- name: Install Task
64+
uses: arduino/setup-task@v1
65+
with:
66+
repo-token: ${{ secrets.GITHUB_TOKEN }}
67+
version: 3.x
68+
69+
- name: Generate category order metadata
70+
env:
71+
ARDUINO_FORUM_API_KEY: ${{ secrets.ARDUINO_FORUM_API_KEY }}
72+
run: |
73+
task \
74+
--silent \
75+
forum:generate-category-order-metadata
76+
77+
- name: Check category order metadata
78+
id: check-category-order-metadata
79+
run: git diff --color --exit-code
80+
81+
- name: Upload corrected file to workflow artifact
82+
if: failure() && steps.check-category-order-metadata.outcome == 'failure'
83+
uses: actions/upload-artifact@v3
84+
with:
85+
if-no-files-found: error
86+
name: ${{ env.ARTIFACT_NAME }}
87+
path: ${{ env.CATEGORY_ORDER_METADATA_FILE_PATH }}
88+
89+
- name: Add artifact availability notice
90+
if: failure() && steps.check-category-order-metadata.outcome == 'failure'
91+
run: |
92+
echo "::notice file=${{ env.CATEGORY_ORDER_METADATA_FILE_PATH }}::Corrected file was saved to the ${{ env.ARTIFACT_NAME }} workflow artifact"
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-python-task.md
2+
name: Check Python
3+
4+
env:
5+
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
6+
PYTHON_VERSION: "3.9"
7+
8+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
9+
on:
10+
create:
11+
push:
12+
paths:
13+
- ".github/workflows/check-python-task.ya?ml"
14+
- "**/.flake8"
15+
- "**/poetry.lock"
16+
- "**/pyproject.toml"
17+
- "**/setup.cfg"
18+
- "Taskfile.ya?ml"
19+
- "**/tox.ini"
20+
- "**.py"
21+
pull_request:
22+
paths:
23+
- ".github/workflows/check-python-task.ya?ml"
24+
- "**/.flake8"
25+
- "**/poetry.lock"
26+
- "**/pyproject.toml"
27+
- "**/setup.cfg"
28+
- "Taskfile.ya?ml"
29+
- "**/tox.ini"
30+
- "**.py"
31+
schedule:
32+
# Run periodically to catch breakage caused by external changes.
33+
- cron: "0 8 * * WED"
34+
workflow_dispatch:
35+
repository_dispatch:
36+
37+
jobs:
38+
run-determination:
39+
runs-on: ubuntu-latest
40+
outputs:
41+
result: ${{ steps.determination.outputs.result }}
42+
steps:
43+
- name: Determine if the rest of the workflow should run
44+
id: determination
45+
run: |
46+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
47+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
48+
if [[
49+
"${{ github.event_name }}" != "create" ||
50+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
51+
]]; then
52+
# Run the other jobs.
53+
RESULT="true"
54+
else
55+
# There is no need to run the other jobs.
56+
RESULT="false"
57+
fi
58+
59+
echo "result=$RESULT" >> $GITHUB_OUTPUT
60+
61+
lint:
62+
needs: run-determination
63+
if: needs.run-determination.outputs.result == 'true'
64+
runs-on: ubuntu-latest
65+
66+
steps:
67+
- name: Checkout repository
68+
uses: actions/checkout@v3
69+
70+
- name: Install Python
71+
uses: actions/setup-python@v4
72+
with:
73+
python-version: ${{ env.PYTHON_VERSION }}
74+
75+
- name: Install Poetry
76+
run: pip install poetry
77+
78+
- name: Install Task
79+
uses: arduino/setup-task@v1
80+
with:
81+
repo-token: ${{ secrets.GITHUB_TOKEN }}
82+
version: 3.x
83+
84+
- name: Run flake8
85+
uses: liskin/gh-problem-matcher-wrap@v2
86+
with:
87+
linters: flake8
88+
run: task python:lint
89+
90+
formatting:
91+
needs: run-determination
92+
if: needs.run-determination.outputs.result == 'true'
93+
runs-on: ubuntu-latest
94+
95+
steps:
96+
- name: Checkout repository
97+
uses: actions/checkout@v3
98+
99+
- name: Install Python
100+
uses: actions/setup-python@v4
101+
with:
102+
python-version: ${{ env.PYTHON_VERSION }}
103+
104+
- name: Install Poetry
105+
run: pip install poetry
106+
107+
- name: Install Task
108+
uses: arduino/setup-task@v1
109+
with:
110+
repo-token: ${{ secrets.GITHUB_TOKEN }}
111+
version: 3.x
112+
113+
- name: Format Python code
114+
run: task python:format
115+
116+
- name: Check formatting
117+
run: git diff --color --exit-code

.github/workflows/check-toc-task.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ on:
1313
- ".github/workflows/check-toc-task.ya?ml"
1414
- "package.json"
1515
- "package-lock.json"
16+
- "Taskfile.ya?ml"
1617
- "content/categories/staff/moderation/_topics/moderator-instructions/1.md"
1718
pull_request:
1819
paths:
1920
- ".github/workflows/check-toc-task.ya?ml"
2021
- "package.json"
2122
- "package-lock.json"
23+
- "Taskfile.ya?ml"
2224
- "content/categories/staff/moderation/_topics/moderator-instructions/1.md"
2325
schedule:
2426
# Run periodically to catch breakage caused by external changes.

.markdown-link-check.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
{
3030
"pattern": "^https://forum\\.arduino\\.cc/c/hardware/mkr-boards/mkr1000-old/"
3131
},
32+
{
33+
"pattern": "^https://forum\\.arduino\\.cc/c/hardware/uno-r4/"
34+
},
3235
{
3336
"pattern": "^https://forum\\.arduino\\.cc/c/software/cloud/"
3437
},
@@ -80,6 +83,9 @@
8083
{
8184
"pattern": "^https://forum\\.arduino\\.cc/t/about-the-test-category/847511$"
8285
},
86+
{
87+
"pattern": "^https://forum\\.arduino\\.cc/t/about-the-uno-r4-category/1114082$"
88+
},
8389
{
8490
"pattern": "^https://forum\\.arduino\\.cc/t/about-the-windows-remote-arduino-category/847512$"
8591
},
@@ -89,6 +95,9 @@
8995
{
9096
"pattern": "^https://forum\\.arduino\\.cc/t/hi-welcome-to-maker-faire-rome-the-european-edition/158299$"
9197
},
98+
{
99+
"pattern": "^https://forum\\.arduino\\.cc/t/how-to-get-the-best-out-of-this-forum/1114083$"
100+
},
92101
{
93102
"pattern": "^https://forum\\.arduino\\.cc/t/moderation-guidelines/54905$"
94103
},

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Arduino Forum Assets
22

3+
[![Check Category Order Metadata](https://github.com/arduino/forum-assets/actions/workflows/check-order-metadata-task.yml/badge.svg)](https://github.com/arduino/forum-assets/actions/workflows/check-order-metadata-task.yml)
34
[![Check General Formatting status](https://github.com/arduino/forum-assets/actions/workflows/check-general-formatting-task.yml/badge.svg)](https://github.com/arduino/forum-assets/actions/workflows/check-general-formatting-task.yml)
45
[![Check Files status](https://github.com/arduino/forum-assets/actions/workflows/check-files-task.yml/badge.svg)](https://github.com/arduino/forum-assets/actions/workflows/check-files-task.yml)
56
[![Check License status](https://github.com/arduino/forum-assets/actions/workflows/check-license.yml/badge.svg)](https://github.com/arduino/forum-assets/actions/workflows/check-license.yml)
67
[![Check Markdown status](https://github.com/arduino/forum-assets/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/forum-assets/actions/workflows/check-markdown-task.yml)
78
[![Check Prettier Formatting status](https://github.com/arduino/forum-assets/actions/workflows/check-prettier-formatting-task.yml/badge.svg)](https://github.com/arduino/forum-assets/actions/workflows/check-prettier-formatting-task.yml)
9+
[![Check Python status](https://github.com/arduino/forum-assets/actions/workflows/check-python-task.yml/badge.svg)](https://github.com/arduino/forum-assets/actions/workflows/check-python-task.yml)
810
[![Check Taskfiles status](https://github.com/arduino/forum-assets/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/arduino/forum-assets/actions/workflows/check-taskfiles.yml)
911
[![Check ToC status](https://github.com/arduino/forum-assets/actions/workflows/check-toc-task.yml/badge.svg)](https://github.com/arduino/forum-assets/actions/workflows/check-toc-task.yml)
1012
[![Check Workflows status](https://github.com/arduino/forum-assets/actions/workflows/check-workflows-task.yml/badge.svg)](https://github.com/arduino/forum-assets/actions/workflows/check-workflows-task.yml)

Taskfile.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ tasks:
5454
# This is an "umbrella" task used to call any documentation generation processes the project has.
5555
# It can be left empty if there are none.
5656

57+
forum:generate-category-order-metadata:
58+
desc: Generate the category order metadata file
59+
deps:
60+
- task: poetry:install-deps
61+
cmds:
62+
- |
63+
if [[ "$ARDUINO_FORUM_API_KEY" == "" ]]; then
64+
echo "ARDUINO_FORUM_API_KEY environment variable not set."
65+
echo "This task requires a forum.arduino.cc Discourse API key with \"categories > list\" scope."
66+
exit 1
67+
fi
68+
69+
poetry run \
70+
python assets/generate-category-order-metadata/generate-category-order-metadata.py
71+
5772
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-files-task/Taskfile.yml
5873
general:check-filenames:
5974
desc: Check for non-portable filenames
@@ -287,6 +302,22 @@ tasks:
287302
cmds:
288303
- poetry install --no-root
289304

305+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-python-task/Taskfile.yml
306+
python:format:
307+
desc: Format Python files
308+
deps:
309+
- task: poetry:install-deps
310+
cmds:
311+
- poetry run black .
312+
313+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-python-task/Taskfile.yml
314+
python:lint:
315+
desc: Lint Python code
316+
deps:
317+
- task: poetry:install-deps
318+
cmds:
319+
- poetry run flake8 --show-source
320+
290321
# Make a temporary file named according to the passed TEMPLATE variable and print the path passed to stdout
291322
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
292323
utility:mktemp-file:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Category Order Metadata Generator
2+
3+
This Python script uses the Arduino Forum's [Discourse API](https://docs.discourse.org/#tag/Categories/operation/listCategories) to generate the forum category order metadata file (`order.md`).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[186]

0 commit comments

Comments
 (0)