Skip to content

Commit 8ef1fd4

Browse files
committed
fmt: introduce golangci-lint and go vet
1 parent 297ad41 commit 8ef1fd4

File tree

11 files changed

+552
-6
lines changed

11 files changed

+552
-6
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
branches:
7+
- dev
8+
pull_request:
9+
permissions:
10+
contents: read
11+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
12+
# pull-requests: read
13+
jobs:
14+
createlinterworkspace:
15+
name: "Create linter workspace"
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v5
19+
- name: "Create by calling 'make linter_workspace'"
20+
run: make linter_workspace
21+
- name: "Debug the workspace content"
22+
run: |
23+
echo "The packages in workspace are ..."
24+
ls -lRa ./
25+
working-directory: ${{ github.workspace }}/build/linter
26+
27+
golangci:
28+
needs: createlinterworkspace
29+
runs-on: ubuntu-latest
30+
name: "lint all in linter workspace '${{ github.workspace }}/build/linter'"
31+
defaults:
32+
run:
33+
working-directory: ${{ github.workspace }}/build/linter
34+
steps:
35+
- uses: actions/checkout@v5
36+
- uses: actions/setup-go@v6
37+
with:
38+
go-version: '1.22'
39+
cache: false
40+
- name: golangci-lint
41+
uses: golangci/golangci-lint-action@v8
42+
with:
43+
version: v2.5.0
44+
45+
# Optional: golangci-lint command line arguments.
46+
# Note: exclude arguments, e.g. --exclude-files="my_file", will not affect the "typecheck" linter,
47+
# at least since v1.61.0 - use build tags instead.
48+
#args: --exclude-files="aht20/aht20.go"
49+
50+
# Optional: show only new issues if it's a pull request. The default value is `false`.
51+
# only-new-issues: true
52+
53+
# Optional: if set to true then the all caching functionality will be complete disabled,
54+
# takes precedence over all other caching options.
55+
# skip-cache: true
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
branches:
7+
- dev
8+
pull_request:
9+
permissions:
10+
contents: read
11+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
12+
# pull-requests: read
13+
jobs:
14+
collectpackages:
15+
name: "Collect all packages to a list"
16+
runs-on: ubuntu-latest
17+
outputs:
18+
packages: "${{ steps.create-package-list.outputs.packages }}"
19+
steps:
20+
- uses: actions/checkout@v5
21+
- name: "Collect by calling 'make print_collected_packages'"
22+
id: create-package-list
23+
run: |
24+
pkgs=$(make print_collected_packages)
25+
# replace space by comma, add double quotes and copy to output
26+
echo "packages=[\"${pkgs// /\",\"}\"]" >> $GITHUB_OUTPUT
27+
- name: "Debug the collected packages as JSON array"
28+
run: echo "The collected packages are ${{ steps.create-package-list.outputs.packages }}"
29+
30+
golangci:
31+
needs: collectpackages
32+
runs-on: ubuntu-latest
33+
strategy:
34+
matrix:
35+
package: "${{ fromJson(needs.collectpackages.outputs.packages) }}"
36+
name: "lint ${{ matrix.package }}"
37+
steps:
38+
- uses: actions/checkout@v5
39+
- uses: actions/setup-go@v6
40+
with:
41+
go-version: '1.22'
42+
cache: false
43+
- name: "Debug the workspace and package"
44+
run: echo "The package ${{ matrix.package }} is in workspace ${{ github.workspace }}"
45+
- name: golangci-lint
46+
uses: golangci/golangci-lint-action@v8
47+
with:
48+
version: v2.5.0
49+
working-directory: ${{ matrix.package }}
50+
51+
# Optional: golangci-lint command line arguments.
52+
# Note: exclude arguments, e.g. --exclude-files="my_file", will not affect the "typecheck" linter,
53+
# at least since v1.61.0 - use build tags instead.
54+
#args: --exclude-files="platforms/digispark/digispark_adaptor.go"
55+
56+
# Optional: show only new issues if it's a pull request. The default value is `false`.
57+
# only-new-issues: true
58+
59+
# Optional: if set to true then the all caching functionality will be complete disabled,
60+
# takes precedence over all other caching options.
61+
# skip-cache: true

0 commit comments

Comments
 (0)