Skip to content

Commit 34f8235

Browse files
authored
Merge pull request #17 from per1234/sync-labels
Add template workflow to synchronize with shared repository labels
2 parents 744868a + 0a16b48 commit 34f8235

File tree

10 files changed

+640
-0
lines changed

10 files changed

+640
-0
lines changed

.github/workflows/check-configs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ on:
77
- ".github/workflows/check-configs.yml"
88
- "Taskfile.ya?ml"
99
- "**/dependabot.ya?ml"
10+
- "workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json"
11+
- "workflow-templates/assets/sync-labels/*.ya?ml"
1012
pull_request:
1113
paths:
1214
- ".github/workflows/check-configs.yml"
1315
- "Taskfile.ya?ml"
1416
- "**/dependabot.ya?ml"
17+
- "workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json"
18+
- "workflow-templates/assets/sync-labels/*.ya?ml"
1519
schedule:
1620
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
1721
- cron: "0 8 * * TUE"

.github/workflows/sync-labels.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md
2+
name: Sync Labels
3+
4+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
paths:
8+
- ".github/workflows/sync-labels.ya?ml"
9+
- ".github/label-configuration-files/*.ya?ml"
10+
pull_request:
11+
paths:
12+
- ".github/workflows/sync-labels.ya?ml"
13+
- ".github/label-configuration-files/*.ya?ml"
14+
schedule:
15+
# Run daily at 8 AM UTC to sync with changes to shared label configurations.
16+
- cron: "0 8 * * *"
17+
workflow_dispatch:
18+
repository_dispatch:
19+
20+
env:
21+
CONFIGURATIONS_FOLDER: .github/label-configuration-files
22+
CONFIGURATIONS_ARTIFACT: label-configuration-files
23+
24+
jobs:
25+
check:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v2
31+
32+
- name: Download JSON schema for labels configuration file
33+
id: download-schema
34+
uses: carlosperate/download-file-action@v1.0.3
35+
with:
36+
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json
37+
location: ${{ runner.temp }}/label-configuration-schema
38+
39+
- name: Install JSON schema validator
40+
run: sudo npm install --global ajv-cli
41+
42+
- name: Validate local labels configuration
43+
run: |
44+
# See: https://github.com/ajv-validator/ajv-cli#readme
45+
ajv validate \
46+
-s "${{ steps.download-schema.outputs.file-path }}" \
47+
-d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}"
48+
49+
download:
50+
needs: check
51+
runs-on: ubuntu-latest
52+
53+
strategy:
54+
matrix:
55+
filename:
56+
# Filenames of the shared configurations to apply to the repository in addition to the local configuration.
57+
# https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels
58+
- universal.yml
59+
60+
steps:
61+
- name: Download
62+
uses: carlosperate/download-file-action@v1.0.3
63+
with:
64+
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }}
65+
66+
- name: Pass configuration files to next job via workflow artifact
67+
uses: actions/upload-artifact@v2
68+
with:
69+
path: "*.ya?ml"
70+
if-no-files-found: error
71+
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
72+
73+
sync:
74+
needs: download
75+
runs-on: ubuntu-latest
76+
77+
steps:
78+
- name: Set environment variables
79+
run: |
80+
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
81+
echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV"
82+
83+
- name: Determine whether to dry run
84+
id: dry-run
85+
if: >
86+
github.event == 'pull_request' ||
87+
github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
88+
run: |
89+
# Use of this flag in the github-label-sync command will cause it to only check the validity of the
90+
# configuration.
91+
echo "::set-output name=flag::--dry-run"
92+
93+
- name: Checkout repository
94+
uses: actions/checkout@v2
95+
96+
- name: Download configuration files artifact
97+
uses: actions/download-artifact@v2
98+
with:
99+
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
100+
path: ${{ env.CONFIGURATIONS_FOLDER }}
101+
102+
- name: Remove unneeded artifact
103+
uses: geekyeggo/delete-artifact@v1
104+
with:
105+
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
106+
107+
- name: Merge label configuration files
108+
run: |
109+
# Merge all configuration files
110+
cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.{yml,yaml} > "${{ env.MERGED_CONFIGURATION_PATH }}"
111+
112+
- name: Install github-label-sync
113+
run: sudo npm install --global github-label-sync
114+
115+
- name: Sync labels
116+
env:
117+
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118+
run: |
119+
# See: https://github.com/Financial-Times/github-label-sync
120+
github-label-sync \
121+
--labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
122+
${{ steps.dry-run.outputs.flag }} \
123+
${{ github.repository }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
[![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)
1111
[![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)
1212
[![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)
13+
[![Sync Labels status](https://github.com/arduino/tooling-project-assets/actions/workflows/sync-labels.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/sync-labels.yml)
1314

1415
The [Arduino](https://www.arduino.cc/) Tooling Team's collection of reusable project infrastructure assets.
1516

Taskfile.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ tasks:
4949
"{{.WORKFLOW_TEMPLATES_PATH}}/check-prettier-formatting-task.yml" \
5050
"{{.WORKFLOW_TEMPLATES_PATH}}/check-taskfiles.yml" \
5151
"{{.WORKFLOW_TEMPLATES_PATH}}/check-yaml-task.yml" \
52+
"{{.WORKFLOW_TEMPLATES_PATH}}/sync-labels.yml" \
5253
"{{.WORKFLOWS_PATH}}"
5354
5455
config:sync:
@@ -91,9 +92,12 @@ tasks:
9192
DEPENDABOT_SCHEMA_PATH:
9293
sh: mktemp -t dependabot-schema-XXXXXXXXXX.json
9394
DEPENDABOT_DATA_PATH: "**/dependabot.yml"
95+
LABEL_CONFIG_SCHEMA_PATH: workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json
96+
LABEL_CONFIG_DATA_PATH: "workflow-templates/assets/sync-labels/*.{yml,yaml}"
9497
cmds:
9598
- wget --quiet --output-document="{{.DEPENDABOT_SCHEMA_PATH}}" {{.DEPENDABOT_SCHEMA_URL}}
9699
- npx ajv-cli@{{.AJV_CLI_VERSION}} validate -s "{{.DEPENDABOT_SCHEMA_PATH}}" -d "{{.DEPENDABOT_DATA_PATH}}"
100+
- npx ajv-cli validate -s "{{.LABEL_CONFIG_SCHEMA_PATH}}" -d "{{.LABEL_CONFIG_DATA_PATH}}"
97101

98102
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
99103
markdown:lint:
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json",
4+
"title": "Arduino tooling repository label configuration file JSON schema",
5+
"description": "Required structure of the configuration file used to define GitHub issue/PR labels, as well as the standardized format for Arduino's tooling labels. See: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md",
6+
"type": "array",
7+
"uniqueItems": true,
8+
"items": {
9+
"type": "object",
10+
"properties": {
11+
"name": {
12+
"type": "string",
13+
"maxLength": 50,
14+
"anyOf": [
15+
{
16+
"$comment": "Standardized label format",
17+
"pattern": "^.+: .+$"
18+
},
19+
{
20+
"$comment": "Allowed exceptions to the standardized format",
21+
"enum": ["help wanted"]
22+
}
23+
]
24+
},
25+
"color": {
26+
"enum": [
27+
"940404",
28+
"ff0000",
29+
"ffa200",
30+
"ffff00",
31+
"00ff00",
32+
"92a600",
33+
"008000",
34+
"00ba9e",
35+
"00ffff",
36+
"0000ff",
37+
"800080",
38+
"d876e3",
39+
"ff00ff",
40+
"c0c0c0"
41+
]
42+
},
43+
"description": {
44+
"type": "string",
45+
"maxLength": 100
46+
},
47+
"aliases": {
48+
"type": "array"
49+
},
50+
"notes": {
51+
"type": "string",
52+
"minLength": 1
53+
}
54+
},
55+
"additionalProperties": false,
56+
"required": ["name", "color", "description"]
57+
}
58+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels/tooling.yml
2+
# See: https://github.com/Financial-Times/github-label-sync#label-config-file
3+
4+
- name: "os: windows"
5+
color: "800080"
6+
description: Specific to Windows operating system
7+
- name: "os: linux"
8+
color: "800080"
9+
description: Specific to Linux operating system
10+
- name: "os: macos"
11+
color: "800080"
12+
description: Specific to macOS operating system
13+
- name: "architecture: arm"
14+
color: ff00ff
15+
description: Specific to ARM host architecture
16+
- name: "topic: security"
17+
color: ff0000
18+
description: Related to the protection of user data
19+
notes: |
20+
Vulnerability disclosures are made following the procedure at:
21+
https://github.com/arduino/.github/blob/master/SECURITY.md
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels/universal.yml
2+
# See: https://github.com/Financial-Times/github-label-sync#label-config-file
3+
# Maximum lengths:
4+
# name: 50
5+
# description: 100
6+
7+
- name: "conclusion: declined"
8+
color: "940404"
9+
description: Will not be worked on
10+
aliases:
11+
- wontfix
12+
- name: "conclusion: duplicate"
13+
color: "ff0000"
14+
description: Has already been submitted
15+
aliases:
16+
- duplicate
17+
- name: "conclusion: invalid"
18+
color: "ff0000"
19+
description: Issue/PR not valid
20+
aliases:
21+
- invalid
22+
- name: "conclusion: off topic"
23+
color: "ff0000"
24+
description: Off topic for this repository
25+
- name: "conclusion: moved"
26+
color: "940404"
27+
description: Issue/PR moved to another repository
28+
notes: |
29+
For use when it's not possible to do a true transfer
30+
(PRs, different organizations, or maintainer doesn't have write permissions in target repo).
31+
- name: "conclusion: resolved"
32+
color: "00ff00"
33+
description: Issue was resolved
34+
- name: "priority: high"
35+
color: "ffa200"
36+
description: Resolution is a high priority
37+
- name: "priority: medium"
38+
color: "ffff00"
39+
description: Resolution is a medium priority
40+
- name: "priority: low"
41+
color: "c0c0c0"
42+
description: Resolution is a low priority
43+
- name: "status: changes requested"
44+
color: "ffa200"
45+
description: Changes to PR are required before merge
46+
- name: "status: in progress"
47+
color: "0000ff"
48+
description: Work is in progress on this
49+
- name: "status: on hold"
50+
color: "940404"
51+
description: Do not proceed at this time
52+
- name: "status: waiting for information"
53+
color: "ffff00"
54+
aliases:
55+
- Waiting for feedback
56+
- waiting for feedback
57+
description: More information must be provided before work can proceed
58+
- name: "status: blocked"
59+
color: "940404"
60+
description: Progress on this prevented by an external cause
61+
- name: help wanted
62+
color: "ffa200"
63+
description: Assistance from the community is especially welcome
64+
notes: |
65+
Ideally this would be "status: help wanted", but GitHub gives this label special treatment so it's best to leave it
66+
stock.
67+
- name: "topic: infrastructure"
68+
color: "00ffff"
69+
description: Related to repository infrastructure
70+
- name: "topic: code"
71+
color: "00ffff"
72+
description: Related to content of the project itself
73+
- name: "topic: documentation"
74+
color: "00ffff"
75+
description: Related to documentation for the project
76+
aliases:
77+
- documentation
78+
- name: "type: imperfection"
79+
color: "ff0000"
80+
description: Perceived defect in any part of project
81+
aliases:
82+
- bug
83+
notes: This includes bugs, but avoids confusion for use in non-code contexts.
84+
- name: "type: enhancement"
85+
color: "008000"
86+
description: Proposed improvement
87+
aliases:
88+
- enhancement
89+
- name: "type: support"
90+
color: "ff0000"
91+
description: "OT: Request for help using the project"
92+
aliases:
93+
- question
94+
notes: |
95+
All support request issues must be closed as "conclusion: invalid", redirecting the user to the Arduino forum, but
96+
it's still useful to label the closed issues and this type doesn't fit into the imperfection/enhancement dichotomy.

0 commit comments

Comments
 (0)