Skip to content

Commit 0d31416

Browse files
Fixing go tools installations (#20)
* Fixing go tools installations Signed-off-by: Ricardo Zanini <zanini@redhat.com> * Use golangci-lint for GH Actions Signed-off-by: Ricardo Zanini <zanini@redhat.com> * Use alternate go.mod for tools Signed-off-by: Ricardo Zanini <zanini@redhat.com> * Adding tools.sum to ignored list of changed files Signed-off-by: Ricardo Zanini <zanini@redhat.com> * Fixing tools cache path Signed-off-by: Ricardo Zanini <zanini@redhat.com>
1 parent 8764f37 commit 0d31416

File tree

6 files changed

+81
-26
lines changed

6 files changed

+81
-26
lines changed

.github/workflows/Go-SDK-PR-Check.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ on:
2424
- master
2525
env:
2626
GO_VERSION: 1.14
27+
GOLANGLINT_CI_VERSION: v1.33.0
2728
jobs:
2829
basic_checks:
2930
name: Basic Checks
3031
runs-on: ubuntu-latest
31-
env:
32-
GOLANG_LINT_VERSION: v1.27.0
3332
steps:
3433
- name: Checkout Code
3534
uses: actions/checkout@v2
@@ -45,26 +44,29 @@ jobs:
4544
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
4645
restore-keys: |
4746
${{ runner.os }}-go-cache-
47+
- name: Cache tools
48+
uses: actions/cache@v2
49+
with:
50+
path: ~/go/bin
51+
key: ${{ runner.os }}-go-tools-${{ hashFiles('**/tools.sum') }}
52+
restore-keys: |
53+
${{ runner.os }}-go-tools-
4854
- name: Check Headers
4955
run: |
5056
make addheaders
51-
changed_files=$(git status -s | grep -v 'go.mod\|go.sum' || :)
57+
changed_files=$(git status -s | grep -v 'go.mod\|go.sum\|tools.mod\|tools.sum' || :)
5258
[[ -z "$changed_files" ]] || (printf "Some files are missing the headers: \n$changed_files\n Did you run 'make lint' before sending the PR" && exit 1)
5359
- name: Check Formatting
5460
run: |
5561
make fmt
56-
changed_files=$(git status -s | grep -v 'go.mod\|go.sum' || :)
62+
changed_files=$(git status -s | grep -v 'go.mod\|go.sum\|tools.mod\|tools.sum' || :)
5763
[[ -z "$changed_files" ]] || (printf "Some files are not formatted properly: \n$changed_files\n Did you run 'make test' before sending the PR?" && exit 1)
58-
- name: Install golinters
59-
run: |
60-
go get -u golang.org/x/lint/golint
61-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin $GOLANG_LINT_VERSION
6264
- name: Check lint
63-
run: |
64-
make lint
65+
uses: golangci/golangci-lint-action@v2
66+
with:
67+
version: ${{ env.GOLANGLINT_CI_VERSION }}
6568
- name: Install cover
66-
run: go get golang.org/x/tools/cmd/cover
67-
- run: go mod tidy
69+
run: go get -modfile=tools.mod golang.org/x/tools/cmd/cover
6870
- name: Validate codcov yaml file
6971
run: curl -vvv --data-binary @codecov.yml https://codecov.io/validate
7072
- name: Run Unit Tests

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ gen-types:
33
./hack/generate-spec-types.sh
44

55
addheaders:
6-
@which addlicense > /dev/null || go get -u github.com/google/addlicense
6+
@command -v addlicense > /dev/null || go install -modfile=tools.mod -v github.com/google/addlicense
77
@addlicense -c "The Serverless Workflow Specification Authors" -l apache .
88

99
fmt:
10-
go vet ./...
11-
go fmt ./...
10+
@go vet ./...
11+
@go fmt ./...
1212

1313
lint:
14-
go mod tidy
14+
@command -v golint > /dev/null || go install -modfile=tools.mod -v golang.org/x/lint/golint
15+
@command -v golangci-lint > /dev/null || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GOPATH}/bin"
1516
make addheaders
1617
make fmt
1718
./hack/go-lint.sh
@@ -20,4 +21,4 @@ lint:
2021
coverage="false"
2122
test:
2223
make lint
23-
go test ./...
24+
@go test ./...

hack/generate-spec-types.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
17-
command -v ./bin/gojsonschema >/dev/null || go build -o ./bin/gojsonschema github.com/atombender/go-jsonschema/cmd/gojsonschema && go mod tidy
16+
command -v gojsonschema >/dev/null || go install -modfile=tools.mod -v github.com/atombender/go-jsonschema/cmd/gojsonschema
1817

1918
echo "--> Generating specification types"
2019

@@ -37,13 +36,13 @@ sed -i 's/$id/id/g' "${targetdir}/schema/workflow.json"
3736

3837
./bin/gojsonschema -v \
3938
--schema-package=https://serverlessworkflow.org/core/common.json=github.com/serverlessworkflow/sdk-go/model \
40-
--schema-output=https://serverlessworkflow.org/core/common.json=zz_generated.types_common.go \
39+
--schema-output=https://serverlessworkflow.org/core/common.json=zz_generated.types_common.go \
4140
--schema-package=https://serverlessworkflow.org/core/events.json=github.com/serverlessworkflow/sdk-go/model \
42-
--schema-output=https://serverlessworkflow.org/core/events.json=zz_generated.types_events.go \
41+
--schema-output=https://serverlessworkflow.org/core/events.json=zz_generated.types_events.go \
4342
--schema-package=https://serverlessworkflow.org/core/functions.json=github.com/serverlessworkflow/sdk-go/model \
44-
--schema-output=https://serverlessworkflow.org/core/functions.json=zz_generated.types_functions.go \
43+
--schema-output=https://serverlessworkflow.org/core/functions.json=zz_generated.types_functions.go \
4544
--schema-package=https://serverlessworkflow.org/core/workflow.json=github.com/serverlessworkflow/sdk-go/model \
46-
--schema-output=https://serverlessworkflow.org/core/workflow.json=zz_generated.types_workflow.go \
45+
--schema-output=https://serverlessworkflow.org/core/workflow.json=zz_generated.types_workflow.go \
4746
"${targetdir}"/schema/common.json "${targetdir}"/schema/events.json "${targetdir}"/schema/functions.json "${targetdir}"/schema/workflow.json
4847

4948
sed -i '/type Workflow/d' zz_generated.types_workflow.go
@@ -53,7 +52,7 @@ mv -v zz_generated.types_*.go "./${package}/"
5352
cp -v ./hack/zz_generated.types_state_impl.go.template "./${package}/zz_generated.types_state_impl.go"
5453
declare operations=("Delaystate" "Eventstate" "Operationstate" "Parallelstate" "Subflowstate" "Injectstate" "Foreachstate" "Callbackstate" "Databasedswitch" "Eventbasedswitch")
5554
for op in "${operations[@]}"; do
56-
sed "s/{state}/${op}/g" ./hack/state_interface_impl.template >> "./${package}/zz_generated.types_state_impl.go"
55+
sed "s/{state}/${op}/g" ./hack/state_interface_impl.template >>"./${package}/zz_generated.types_state_impl.go"
5756
done
5857

5958
go fmt ./...

hack/go-lint.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ if [ -s golint_errors ] ; then
1818
code=1
1919
fi
2020
rm -f golint_errors
21-
# The command in or will fetch the latest tag available for golangci-lint and install in $GOPATH/bin/
22-
command -v golangci-lint > /dev/null || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(go env GOPATH)/bin"
2321
golangci-lint run ./... --enable golint --timeout 2m0s
2422

2523
exit ${code:0}

tools.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/serverlessworkflow/sdk-go
2+
3+
go 1.14
4+
5+
require (
6+
github.com/atombender/go-jsonschema v0.8.0 // indirect
7+
github.com/google/addlicense v0.0.0-20200906110928-a0294312aa76 // indirect
8+
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
9+
golang.org/x/tools v0.0.0-20201204135511-a679dec0fd5a // indirect
10+
)

tools.sum

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
github.com/atombender/go-jsonschema v0.8.0 h1:9RVTd3onlQeWKi8nlEpEu/pjMfh2VzsYKnrctrEC6Mk=
2+
github.com/atombender/go-jsonschema v0.8.0/go.mod h1:zZmis2esEBmF5nHEjJcZjyl+OBmOUVY5Zlbgdr9f6rc=
3+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/google/addlicense v0.0.0-20200906110928-a0294312aa76 h1:JypWNzPMSgH5yL0NvFoAIsDRlKFgL0AsS3GO5bg4Pto=
5+
github.com/google/addlicense v0.0.0-20200906110928-a0294312aa76/go.mod h1:EMjYTRimagHs1FwlIqKyX3wAM0u3rA+McvlIIWmSamA=
6+
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
7+
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
8+
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
9+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
10+
github.com/sanity-io/litter v1.1.0 h1:BllcKWa3VbZmOZbDCoszYLk7zCsKHz5Beossi8SUcTc=
11+
github.com/sanity-io/litter v1.1.0/go.mod h1:CJ0VCw2q4qKU7LaQr3n7UOSHzgEMgcGco7N/SkZQPjw=
12+
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
13+
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
14+
github.com/spf13/pflag v1.0.2 h1:Fy0orTDgHdbnzHcsOgfCN4LtHf0ec3wwtiwJqwvf3Gc=
15+
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
16+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
17+
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
18+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
19+
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
20+
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
21+
golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
22+
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
23+
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
24+
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
25+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
26+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
27+
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
28+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
29+
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
30+
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
31+
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
32+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
33+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
34+
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
35+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
36+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
37+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
38+
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
39+
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7 h1:EBZoQjiKKPaLbPrbpssUfuHtwM6KV/vb4U85g/cigFY=
40+
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
41+
golang.org/x/tools v0.0.0-20201204135511-a679dec0fd5a h1:X8E+lCxtnGR1LTQPdTb8OXe9ZtczFBQiiq37K3aBlmc=
42+
golang.org/x/tools v0.0.0-20201204135511-a679dec0fd5a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
43+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
44+
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
45+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

0 commit comments

Comments
 (0)