Skip to content

Commit 9bedf8f

Browse files
authored
Merge pull request #75 from arduino/sync-workflows
Apply update of workflows from asset repo
2 parents c3e900b + 992bb50 commit 9bedf8f

27 files changed

+3117
-234
lines changed

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

+18-1
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

+79-25
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,67 @@ env:
55
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
66
GO_VERSION: "1.19"
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+
- path: ./
5169

5270
steps:
5371
- name: Checkout repository
@@ -65,13 +83,27 @@ jobs:
6583
version: 3.x
6684

6785
- name: Modernize usages of outdated APIs
86+
env:
87+
GO_MODULE_PATH: ${{ matrix.module.path }}
6888
run: task go:fix
6989

7090
- name: Check if any fixes were needed
7191
run: git diff --color --exit-code
7292

7393
check-style:
94+
name: check-style (${{ matrix.module.path }})
95+
needs: run-determination
96+
if: needs.run-determination.outputs.result == 'true'
7497
runs-on: ubuntu-latest
98+
permissions:
99+
contents: read
100+
101+
strategy:
102+
fail-fast: false
103+
104+
matrix:
105+
module:
106+
- path: ./
75107

76108
steps:
77109
- name: Checkout repository
@@ -88,14 +120,30 @@ jobs:
88120
repo-token: ${{ secrets.GITHUB_TOKEN }}
89121
version: 3.x
90122

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

94128
- name: Check style
129+
env:
130+
GO_MODULE_PATH: ${{ matrix.module.path }}
95131
run: task --silent go:lint
96132

97133
check-formatting:
134+
name: check-formatting (${{ matrix.module.path }})
135+
needs: run-determination
136+
if: needs.run-determination.outputs.result == 'true'
98137
runs-on: ubuntu-latest
138+
permissions:
139+
contents: read
140+
141+
strategy:
142+
fail-fast: false
143+
144+
matrix:
145+
module:
146+
- path: ./
99147

100148
steps:
101149
- name: Checkout repository
@@ -113,14 +161,20 @@ jobs:
113161
version: 3.x
114162

115163
- name: Format code
164+
env:
165+
GO_MODULE_PATH: ${{ matrix.module.path }}
116166
run: task go:format
117167

118168
- name: Check formatting
119169
run: git diff --color --exit-code
120170

121171
check-config:
122172
name: check-config (${{ matrix.module.path }})
173+
needs: run-determination
174+
if: needs.run-determination.outputs.result == 'true'
123175
runs-on: ubuntu-latest
176+
permissions:
177+
contents: read
124178

125179
strategy:
126180
fail-fast: false

.github/workflows/check-license.yml

+56-13
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

0 commit comments

Comments
 (0)