Skip to content

Commit aad48b0

Browse files
committed
Apply update of workflows from asset repo
1 parent 8967c37 commit aad48b0

22 files changed

+1459
-449
lines changed

.github/workflows/check-go-dependencies-task.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ on:
3737
jobs:
3838
run-determination:
3939
runs-on: ubuntu-latest
40+
permissions: {}
4041
outputs:
4142
result: ${{ steps.determination.outputs.result }}
4243
steps:
@@ -56,19 +57,27 @@ jobs:
5657
RESULT="false"
5758
fi
5859
59-
echo "::set-output name=result::$RESULT"
60+
echo "result=$RESULT" >> $GITHUB_OUTPUT
6061
6162
check-cache:
6263
needs: run-determination
6364
if: needs.run-determination.outputs.result == 'true'
6465
runs-on: ubuntu-latest
66+
permissions:
67+
contents: read
6568

6669
steps:
6770
- name: Checkout repository
6871
uses: actions/checkout@v4
6972
with:
7073
submodules: recursive
7174

75+
# This is required to allow jonabc/setup-licensed to install licensed via Ruby gem.
76+
- name: Install Ruby
77+
uses: ruby/setup-ruby@v1
78+
with:
79+
ruby-version: ruby # Install latest version
80+
7281
- name: Install licensed
7382
uses: jonabc/setup-licensed@v1
7483
with:
@@ -112,13 +121,21 @@ jobs:
112121
needs: run-determination
113122
if: needs.run-determination.outputs.result == 'true'
114123
runs-on: ubuntu-latest
124+
permissions:
125+
contents: read
115126

116127
steps:
117128
- name: Checkout repository
118129
uses: actions/checkout@v4
119130
with:
120131
submodules: recursive
121132

133+
# This is required to allow jonabc/setup-licensed to install licensed via Ruby gem.
134+
- name: Install Ruby
135+
uses: ruby/setup-ruby@v1
136+
with:
137+
ruby-version: ruby # Install latest version
138+
122139
- name: Install licensed
123140
uses: jonabc/setup-licensed@v1
124141
with:

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

Lines changed: 82 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,68 @@ env:
55
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
66
GO_VERSION: "1.18.5"
77

8-
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
8+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
99
on:
10+
create:
1011
push:
1112
paths:
1213
- ".github/workflows/check-go-task.ya?ml"
1314
- "Taskfile.ya?ml"
14-
- "go.mod"
15-
- "go.sum"
15+
- ".golangci.ya?ml"
16+
- "**/go.mod"
17+
- "**/go.sum"
1618
- "**.go"
1719
pull_request:
1820
paths:
1921
- ".github/workflows/check-go-task.ya?ml"
2022
- "Taskfile.ya?ml"
21-
- "go.mod"
22-
- "go.sum"
23+
- ".golangci.ya?ml"
24+
- "**/go.mod"
25+
- "**/go.sum"
2326
- "**.go"
2427
workflow_dispatch:
2528
repository_dispatch:
2629

2730
jobs:
28-
check-errors:
31+
run-determination:
2932
runs-on: ubuntu-latest
30-
33+
permissions: {}
34+
outputs:
35+
result: ${{ steps.determination.outputs.result }}
3136
steps:
32-
- name: Checkout repository
33-
uses: actions/checkout@v4
34-
35-
- name: Install Go
36-
uses: actions/setup-go@v5
37-
with:
38-
go-version: ${{ env.GO_VERSION }}
39-
40-
- name: Install Task
41-
uses: arduino/setup-task@v2
42-
with:
43-
repo-token: ${{ secrets.GITHUB_TOKEN }}
44-
version: 3.x
45-
46-
- name: Check for errors
47-
run: task go:vet
37+
- name: Determine if the rest of the workflow should run
38+
id: determination
39+
run: |
40+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
41+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
42+
if [[
43+
"${{ github.event_name }}" != "create" ||
44+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
45+
]]; then
46+
# Run the other jobs.
47+
RESULT="true"
48+
else
49+
# There is no need to run the other jobs.
50+
RESULT="false"
51+
fi
52+
53+
echo "result=$RESULT" >> $GITHUB_OUTPUT
4854
4955
check-outdated:
56+
name: check-outdated (${{ matrix.module.path }})
57+
needs: run-determination
58+
if: needs.run-determination.outputs.result == 'true'
5059
runs-on: ubuntu-latest
60+
permissions:
61+
contents: read
62+
63+
strategy:
64+
fail-fast: false
65+
66+
matrix:
67+
module:
68+
# TODO: add paths of all Go modules here
69+
- path: ./
5170

5271
steps:
5372
- name: Checkout repository
@@ -65,13 +84,28 @@ jobs:
6584
version: 3.x
6685

6786
- name: Modernize usages of outdated APIs
87+
env:
88+
GO_MODULE_PATH: ${{ matrix.module.path }}
6889
run: task go:fix
6990

7091
- name: Check if any fixes were needed
7192
run: git diff --color --exit-code
7293

7394
check-style:
95+
name: check-style (${{ matrix.module.path }})
96+
needs: run-determination
97+
if: needs.run-determination.outputs.result == 'true'
7498
runs-on: ubuntu-latest
99+
permissions:
100+
contents: read
101+
102+
strategy:
103+
fail-fast: false
104+
105+
matrix:
106+
module:
107+
# TODO: add paths of all Go modules here
108+
- path: ./
75109

76110
steps:
77111
- name: Checkout repository
@@ -88,14 +122,31 @@ jobs:
88122
repo-token: ${{ secrets.GITHUB_TOKEN }}
89123
version: 3.x
90124

91-
- name: Install golint
92-
run: go install golang.org/x/lint/golint@latest
125+
- name: Install golangci-lint
126+
uses: golangci/golangci-lint-action@v3
127+
with:
128+
version: v1.54
93129

94130
- name: Check style
131+
env:
132+
GO_MODULE_PATH: ${{ matrix.module.path }}
95133
run: task --silent go:lint
96134

97135
check-formatting:
136+
name: check-formatting (${{ matrix.module.path }})
137+
needs: run-determination
138+
if: needs.run-determination.outputs.result == 'true'
98139
runs-on: ubuntu-latest
140+
permissions:
141+
contents: read
142+
143+
strategy:
144+
fail-fast: false
145+
146+
matrix:
147+
module:
148+
# TODO: add paths of all Go modules here
149+
- path: ./
99150

100151
steps:
101152
- name: Checkout repository
@@ -113,14 +164,20 @@ jobs:
113164
version: 3.x
114165

115166
- name: Format code
167+
env:
168+
GO_MODULE_PATH: ${{ matrix.module.path }}
116169
run: task go:format
117170

118171
- name: Check formatting
119172
run: git diff --color --exit-code
120173

121174
check-config:
122175
name: check-config (${{ matrix.module.path }})
176+
needs: run-determination
177+
if: needs.run-determination.outputs.result == 'true'
123178
runs-on: ubuntu-latest
179+
permissions:
180+
contents: read
124181

125182
strategy:
126183
fail-fast: false

.github/workflows/check-license.yml

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-license.md
22
name: Check License
33

4-
env:
5-
# TODO: Define the project's license file name here:
6-
EXPECTED_LICENSE_FILENAME: LICENSE.txt
7-
# SPDX identifier: https://spdx.org/licenses/
8-
# TODO: Define the project's license type here
9-
EXPECTED_LICENSE_TYPE: GPL-3.0
10-
11-
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
125
on:
6+
create:
137
push:
148
paths:
159
- ".github/workflows/check-license.ya?ml"
@@ -31,8 +25,50 @@ on:
3125
repository_dispatch:
3226

3327
jobs:
28+
run-determination:
29+
runs-on: ubuntu-latest
30+
permissions: {}
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+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
38+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
39+
if [[
40+
"${{ github.event_name }}" != "create" ||
41+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
42+
]]; then
43+
# Run the other jobs.
44+
RESULT="true"
45+
else
46+
# There is no need to run the other jobs.
47+
RESULT="false"
48+
fi
49+
50+
echo "result=$RESULT" >> $GITHUB_OUTPUT
51+
3452
check-license:
53+
name: ${{ matrix.check-license.path }}
54+
needs: run-determination
55+
if: needs.run-determination.outputs.result == 'true'
3556
runs-on: ubuntu-latest
57+
permissions:
58+
contents: read
59+
60+
strategy:
61+
fail-fast: false
62+
63+
matrix:
64+
check-license:
65+
# TODO: Add additional paths where license files should be
66+
- path: ./
67+
# TODO: Define the project's license file name here:
68+
expected-filename: LICENSE.txt
69+
# SPDX identifier: https://spdx.org/licenses/
70+
# TODO: Define the project's license type here
71+
expected-type: GPL-3.0
3672

3773
steps:
3874
- name: Checkout repository
@@ -46,21 +82,28 @@ jobs:
4682
- name: Install licensee
4783
run: gem install licensee
4884

49-
- name: Check license file
85+
- name: Check license file for ${{ matrix.check-license.path }}
5086
run: |
5187
EXIT_STATUS=0
88+
89+
# Go into folder path
90+
cd ./${{ matrix.check-license.path }}
91+
5292
# See: https://github.com/licensee/licensee
5393
LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)"
94+
5495
DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')"
5596
echo "Detected license file: $DETECTED_LICENSE_FILE"
56-
if [ "$DETECTED_LICENSE_FILE" != "\"${EXPECTED_LICENSE_FILENAME}\"" ]; then
57-
echo "::error file=${DETECTED_LICENSE_FILE}::detected license file $DETECTED_LICENSE_FILE doesn't match expected: $EXPECTED_LICENSE_FILENAME"
97+
if [ "$DETECTED_LICENSE_FILE" != "\"${{ matrix.check-license.expected-filename }}\"" ]; then
98+
echo "::error file=${DETECTED_LICENSE_FILE}::detected license file $DETECTED_LICENSE_FILE doesn't match expected: ${{ matrix.check-license.expected-filename }}"
5899
EXIT_STATUS=1
59100
fi
101+
60102
DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')"
61103
echo "Detected license type: $DETECTED_LICENSE_TYPE"
62-
if [ "$DETECTED_LICENSE_TYPE" != "\"${EXPECTED_LICENSE_TYPE}\"" ]; then
63-
echo "::error file=${DETECTED_LICENSE_FILE}::detected license type $DETECTED_LICENSE_TYPE doesn't match expected \"${EXPECTED_LICENSE_TYPE}\""
104+
if [ "$DETECTED_LICENSE_TYPE" != "\"${{ matrix.check-license.expected-type }}\"" ]; then
105+
echo "::error file=${DETECTED_LICENSE_FILE}::detected license type $DETECTED_LICENSE_TYPE doesn't match expected \"${{ matrix.check-license.expected-type }}\""
64106
EXIT_STATUS=1
65107
fi
108+
66109
exit $EXIT_STATUS

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ env:
55
# See: https://github.com/actions/setup-node/#readme
66
NODE_VERSION: 16.x
77

8-
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
8+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
99
on:
10+
create:
1011
push:
1112
paths:
1213
- ".github/workflows/check-markdown-task.ya?ml"
@@ -38,8 +39,36 @@ on:
3839
repository_dispatch:
3940

4041
jobs:
42+
run-determination:
43+
runs-on: ubuntu-latest
44+
permissions: {}
45+
outputs:
46+
result: ${{ steps.determination.outputs.result }}
47+
steps:
48+
- name: Determine if the rest of the workflow should run
49+
id: determination
50+
run: |
51+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
52+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
53+
if [[
54+
"${{ github.event_name }}" != "create" ||
55+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
56+
]]; then
57+
# Run the other jobs.
58+
RESULT="true"
59+
else
60+
# There is no need to run the other jobs.
61+
RESULT="false"
62+
fi
63+
64+
echo "result=$RESULT" >> $GITHUB_OUTPUT
65+
4166
lint:
67+
needs: run-determination
68+
if: needs.run-determination.outputs.result == 'true'
4269
runs-on: ubuntu-latest
70+
permissions:
71+
contents: read
4372

4473
steps:
4574
- name: Checkout repository
@@ -63,7 +92,11 @@ jobs:
6392
run: task markdown:lint
6493

6594
links:
95+
needs: run-determination
96+
if: needs.run-determination.outputs.result == 'true'
6697
runs-on: ubuntu-latest
98+
permissions:
99+
contents: read
67100

68101
steps:
69102
- name: Checkout repository

0 commit comments

Comments
 (0)