Debian Codegraph @

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

raw symbols SCIP
1 # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md
2 name: Check Go Dependencies
3
4 env:
5 # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
6 GO_VERSION: "1.16"
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-go-dependencies-task.ya?ml"
14 - ".licenses/**"
15 - ".licensed.json"
16 - ".licensed.ya?ml"
17 - "Taskfile.ya?ml"
18 - "**/.gitmodules"
19 - "**/go.mod"
20 - "**/go.sum"
21 pull_request:
22 paths:
23 - ".github/workflows/check-go-dependencies-task.ya?ml"
24 - ".licenses/**"
25 - ".licensed.json"
26 - ".licensed.ya?ml"
27 - "Taskfile.ya?ml"
28 - "**/.gitmodules"
29 - "**/go.mod"
30 - "**/go.sum"
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 "::set-output name=result::$RESULT"
60
61 check-cache:
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@v7
69 with:
70 submodules: recursive
71
72 - name: Install licensed
73 uses: jonabc/setup-licensed@v1
74 with:
75 github_token: ${{ secrets.GITHUB_TOKEN }}
76 version: 3.x
77
78 - name: Install Go
79 uses: actions/setup-go@v7
80 with:
81 go-version: ${{ env.GO_VERSION }}
82
83 - name: Install Task
84 uses: arduino/setup-task@v3
85 with:
86 repo-token: ${{ secrets.GITHUB_TOKEN }}
87 version: 3.x
88
89 - name: Update dependencies license metadata cache
90 run: task --silent general:cache-dep-licenses
91
92 - name: Check for outdated cache
93 id: diff
94 run: |
95 git add .
96 if ! git diff --cached --color --exit-code; then
97 echo
98 echo "::error::Dependency license metadata out of sync. See: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md#metadata-cache"
99 exit 1
100 fi
101
102 # Some might find it convenient to have CI generate the cache rather than setting up for it locally
103 - name: Upload cache to workflow artifact
104 if: failure() && steps.diff.outcome == 'failure'
105 uses: actions/upload-artifact@v7
106 with:
107 if-no-files-found: error
108 include-hidden-files: true
109 name: dep-licenses-cache
110 path: .licenses/
111
112 check-deps:
113 needs: run-determination
114 if: needs.run-determination.outputs.result == 'true'
115 runs-on: ubuntu-latest
116
117 steps:
118 - name: Checkout repository
119 uses: actions/checkout@v7
120 with:
121 submodules: recursive
122
123 - name: Install licensed
124 uses: jonabc/setup-licensed@v1
125 with:
126 github_token: ${{ secrets.GITHUB_TOKEN }}
127 version: 3.x
128
129 - name: Install Go
130 uses: actions/setup-go@v7
131 with:
132 go-version: ${{ env.GO_VERSION }}
133
134 - name: Install Task
135 uses: arduino/setup-task@v3
136 with:
137 repo-token: ${{ secrets.GITHUB_TOKEN }}
138 version: 3.x
139
140 - name: Check for dependencies with unapproved licenses
141 run: task --silent general:check-dep-licenses