Skip to content

Commit b98139c

Browse files
authored
Use nhatthm/gh-actions (#46)
1 parent 63a2df2 commit b98139c

11 files changed

Lines changed: 79 additions & 2336 deletions

File tree

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ indent_style = space
1414

1515
[*.feature]
1616
indent_style = space
17+
18+
[.github/workflows/*.{yml,yaml}]
19+
indent_style = space
20+
indent_size = 2

.github/workflows/lint.yaml

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,21 @@ on:
77
- master
88
pull_request:
99

10-
env:
11-
GO_VERSION: 1.20.x
12-
1310
jobs:
1411
lint:
1512
name: lint
1613
runs-on: ubuntu-latest
1714
steps:
18-
- uses: actions/checkout@v4
19-
20-
- uses: actions/setup-go@v5
21-
with:
22-
go-version: ${{ env.GO_VERSION }}
15+
- name: Checkout code
16+
uses: nhatthm/gh-actions/checkout@master
2317

24-
- id: vars
25-
run: |
26-
make $GITHUB_OUTPUT
18+
- name: Setup
19+
uses: nhatthm/gh-actions/find-go-version@master
2720

28-
- name: lint
29-
uses: golangci/golangci-lint-action@v3
21+
- name: Install Go
22+
uses: nhatthm/gh-actions/setup-go@master
3023
with:
31-
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
32-
version: ${{ steps.vars.outputs.GOLANGCI_LINT_VERSION }}
33-
34-
# Optional: working directory, useful for monorepos
35-
# working-directory: somedir
36-
37-
# Optional: golangci-lint command line arguments.
38-
# args: --issues-exit-code=0
39-
40-
# Optional: show only new issues if it's a pull request. The default value is `false`.
41-
# only-new-issues: true
42-
43-
# Optional: if set to true then the action will use pre-installed Go.
44-
# skip-go-installation: true
45-
46-
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
47-
# skip-pkg-cache: true
24+
go-version: ${{ env.GO_LATEST_VERSION }}
4825

49-
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
50-
# skip-build-cache: true
26+
- name: Lint
27+
uses: nhatthm/gh-actions/golangci-lint@master

.github/workflows/test.yaml

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: test
23

34
on:
@@ -7,54 +8,55 @@ on:
78
pull_request:
89

910
env:
10-
GO111MODULE: on
11-
GO_LATEST_VERSION: 1.20.x
11+
GO111MODULE: "on"
1212

1313
jobs:
14+
setup:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
go-latest-version: ${{ steps.find-go-version.outputs.go-latest-version }}
18+
go-supported-versions: ${{ steps.find-go-version.outputs.go-supported-versions }}
19+
steps:
20+
- name: Checkout code
21+
uses: nhatthm/gh-actions/checkout@master
22+
23+
- id: find-go-version
24+
name: Find Go version
25+
uses: nhatthm/gh-actions/find-go-version@master
26+
1427
test:
1528
strategy:
1629
fail-fast: false
1730
matrix:
1831
os: [ ubuntu-latest, macos-latest ]
19-
go-version: [ 1.18.x, 1.19.x, 1.20.x ]
32+
go-version: ${{ fromJson(needs.setup.outputs.go-supported-versions) }}
2033
runs-on: ${{ matrix.os }}
34+
needs: [setup]
35+
env:
36+
GO_LATEST_VERSION: ${{ needs.setup.outputs.go-latest-version }}
2137
steps:
22-
- name: Install Go
23-
uses: actions/setup-go@v5
24-
with:
25-
go-version: ${{ matrix.go-version }}
26-
2738
- name: Checkout code
28-
uses: actions/checkout@v4
39+
uses: nhatthm/gh-actions/checkout@master
2940

30-
- name: Go cache
31-
uses: actions/cache@v4
41+
- name: Install Go
42+
uses: nhatthm/gh-actions/setup-go@master
3243
with:
33-
# In order:
34-
# * Module download cache
35-
# * Build cache (Linux)
36-
path: |
37-
~/go/pkg/mod
38-
~/.cache/go-build
39-
key: ${{ runner.os }}-go-${{ matrix.go-version }}-cache-${{ hashFiles('**/go.sum') }}
40-
restore-keys: |
41-
${{ runner.os }}-go-${{ matrix.go-version }}-cache
44+
go-version: ${{ matrix.go-version }}
4245

4346
- name: Test
44-
id: test
4547
run: |
4648
make test
4749
4850
- name: Upload code coverage (unit)
4951
if: matrix.go-version == env.GO_LATEST_VERSION
50-
uses: codecov/codecov-action@v3
52+
uses: nhatthm/gh-actions/codecov@master
5153
with:
5254
files: ./unit.coverprofile
5355
flags: unittests-${{ runner.os }}
5456

55-
# - name: Upload code coverage (features)
56-
# if: matrix.go-version == env.GO_LATEST_VERSION
57-
# uses: codecov/codecov-action@v3
58-
# with:
59-
# files: ./features.coverprofile
60-
# flags: featurestests-${{ runner.os }}
57+
#- name: Upload code coverage (features)
58+
# if: matrix.go-version == env.GO_LATEST_VERSION
59+
# uses: nhatthm/gh-actions/codecov@master
60+
# with:
61+
# file: ./features.coverprofile
62+
# flags: featurestests-${{ runner.os }}

.golangci.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ linters-settings:
2020
linters:
2121
enable-all: true
2222
disable:
23-
- ireturn
24-
- nonamedreturns
25-
- exhaustruct
26-
- varnamelen
23+
- deadcode
24+
- depguard
2725
- exhaustivestruct
26+
- exhaustruct
2827
- forbidigo
2928
- forcetypeassert
3029
- gci
@@ -33,14 +32,24 @@ linters:
3332
- gomnd
3433
- ifshort
3534
- interfacer
35+
- ireturn
3636
- lll
3737
- maligned
38+
- nonamedreturns
39+
- nosnakecase
40+
- nolintlint # https://github.com/golangci/golangci-lint/issues/3063
3841
- paralleltest
3942
- scopelint
43+
- structcheck
44+
- tagliatelle
4045
- testpackage
46+
- testifylint
47+
- varcheck
48+
- varnamelen
4149
- wrapcheck
4250

4351
issues:
52+
max-same-issues: 20
4453
exclude-use-default: false
4554
exclude-rules:
4655
- linters:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ VENDOR_DIR = vendor
22

33
GITHUB_OUTPUT ?= /dev/null
44

5-
GOLANGCI_LINT_VERSION ?= v1.51.1
5+
GOLANGCI_LINT_VERSION ?= v1.55.2
66

77
GO ?= go
88
GOLANGCI_LINT ?= $(shell go env GOPATH)/bin/golangci-lint-$(GOLANGCI_LINT_VERSION)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ An installer for [plugin-registry](https://github.com/nhatthm/plugin-registry)
1111

1212
## Prerequisites
1313

14-
- `Go >= 1.16`
14+
- `Go >= 1.18`
1515

1616
## Install
1717

go.mod

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/nhatthm/plugin-registry-github
22

3-
go 1.17
3+
go 1.18
44

55
require (
66
github.com/bool64/ctxd v1.2.1
@@ -19,17 +19,21 @@ require (
1919
github.com/bool64/shared v0.1.5 // indirect
2020
github.com/davecgh/go-spew v1.1.1 // indirect
2121
github.com/fatih/structtag v1.2.0 // indirect
22+
github.com/google/go-cmp v0.6.0 // indirect
2223
github.com/google/go-querystring v1.1.0 // indirect
2324
github.com/iancoleman/orderedmap v0.2.0 // indirect
25+
github.com/kr/pretty v0.3.0 // indirect
26+
github.com/mattn/go-isatty v0.0.17 // indirect
2427
github.com/pmezard/go-difflib v1.0.0 // indirect
28+
github.com/rogpeppe/go-internal v1.9.0 // indirect
2529
github.com/sergi/go-diff v1.3.1 // indirect
26-
github.com/stretchr/objx v0.5.0 // indirect
30+
github.com/stretchr/objx v0.5.1 // indirect
2731
github.com/swaggest/assertjson v1.7.0 // indirect
2832
github.com/yudai/gojsondiff v1.0.0 // indirect
2933
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
3034
go.nhat.io/aferocopy/v2 v2.0.1 // indirect
3135
go.nhat.io/matcher/v2 v2.0.0 // indirect
3236
go.nhat.io/wait v0.1.0 // indirect
33-
golang.org/x/crypto v0.16.0 // indirect
37+
golang.org/x/crypto v0.18.0 // indirect
3438
golang.org/x/text v0.14.0 // indirect
3539
)

0 commit comments

Comments
 (0)