Skip to content

Commit ada2663

Browse files
add the license headers check in go files
1 parent 6de0a54 commit ada2663

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

workflow-templates/assets/check-go-task/Taskfile.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ tasks:
3737
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
3838
cmds:
3939
- go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
40+
41+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
42+
go:check-license-headers:
43+
desc: Check go license headers
44+
cmds:
45+
- go install github.com/google/addlicense@v1.1.1
46+
- addlicense -c "ARDUINO SA (http://www.arduino.cc/)" -f ./license_header.tpl *.go

workflow-templates/check-go-task.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,38 @@ jobs:
226226

227227
- name: Check whether any tidying was needed
228228
run: git diff --color --exit-code
229+
230+
check-license-headers:
231+
name: check-license-headers (${{ matrix.module.path }})
232+
needs: run-determination
233+
if: needs.run-determination.outputs.result == 'true'
234+
runs-on: ubuntu-latest
235+
236+
strategy:
237+
fail-fast: false
238+
239+
matrix:
240+
module:
241+
- path: ./
242+
243+
steps:
244+
- name: Checkout repository
245+
uses: actions/checkout@v3
246+
247+
- name: Install Go
248+
uses: actions/setup-go@v4
249+
with:
250+
go-version: ${{ env.GO_VERSION }}
251+
252+
- name: Install Task
253+
uses: arduino/setup-task@v1
254+
with:
255+
repo-token: ${{ secrets.GITHUB_TOKEN }}
256+
version: 3.x
257+
258+
- name: Check license headers
259+
env:
260+
GO_MODULE_PATH: ${{ matrix.module.path }}
261+
run: |
262+
task go:check-license-headers
263+
git diff --color --exit-code

0 commit comments

Comments
 (0)