Skip to content

Commit

Permalink
Use go.nhat.io packages (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm authored Aug 25, 2022
1 parent 819bacc commit a030243
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
name: lint

on:
push:
tags:
- v*
branches:
- master
- main
pull_request:

env:
GO_VERSION: "1.19.x"

jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2.5.2
- uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- id: get-lint-version
run: |
make golangci-lint-version
- name: lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.42.0
version: ${{ steps.get-lint-version.outputs.GOLANGCI_LINT_VERSION }}

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ on:

env:
GO111MODULE: "on"
GO_LATEST_VERSION: "1.17.x"
GO_LATEST_VERSION: "1.19.x"

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
go-version: [ 1.16.x, 1.17.x ]
go-version: [ 1.17.x, 1.18.x, 1.19.x ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2

- name: Go cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
# In order:
# * Module download cache
Expand Down
7 changes: 7 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ linters:
enable-all: true
disable:
- exhaustivestruct
- exhaustruct
- forbidigo
- forcetypeassert
- gci
Expand All @@ -29,11 +30,17 @@ linters:
- gomnd
- ifshort
- interfacer
- ireturn
- lll
- maligned
- nonamedreturns
- nosnakecase
- nolintlint # https://github.com/golangci/golangci-lint/issues/3063
- paralleltest
- scopelint
- tagliatelle
- testpackage
- varnamelen
- wrapcheck

issues:
Expand Down
24 changes: 19 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
VENDOR_DIR = vendor

GO ?= go
GOLANGCI_LINT ?= golangci-lint
GOLANGCI_LINT_VERSION ?= v1.48.0

.PHONY: $(VENDOR_DIR) lint test test-unit test-integration
GO ?= go
GOLANGCI_LINT ?= $(shell go env GOPATH)/bin/golangci-lint-$(GOLANGCI_LINT_VERSION)

.PHONY: $(VENDOR_DIR)
$(VENDOR_DIR):
@mkdir -p $(VENDOR_DIR)
@$(GO) mod vendor
@$(GO) mod tidy

lint:
@$(GOLANGCI_LINT) run
.PHONY: lint
lint: $(GOLANGCI_LINT) $(VENDOR_DIR)
@$(GOLANGCI_LINT) run -c .golangci.yaml

.PHONY: test
test: test-unit test-integration

## Run unit tests
.PHONY: test-unit
test-unit:
@echo ">> unit test"
@$(GO) test -gcflags=-l -coverprofile=unit.coverprofile -covermode=atomic -race ./...

.PHONY: test-integration
test-integration:
@echo ">> integration test"
@$(GO) test ./features/... -gcflags=-l -coverprofile=features.coverprofile -coverpkg ./... -godog -race

.PHONY: golangci-lint-version
golangci-lint-version:
@echo "::set-output name=GOLANGCI_LINT_VERSION::$(GOLANGCI_LINT_VERSION)"

$(GOLANGCI_LINT):
@echo "$(OK_COLOR)==> Installing golangci-lint $(GOLANGCI_LINT_VERSION)$(NO_COLOR)"; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin "$(GOLANGCI_LINT_VERSION)"
@mv ./bin/golangci-lint $(GOLANGCI_LINT)
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Interacting with multiple filesystems in [`cucumber/godog`](https://github.com/c

## Prerequisites

- `Go >= 1.16`
- `Go >= 1.17`

## Install

Expand Down Expand Up @@ -102,7 +102,7 @@ Feature: OS FS
Then there should be only these files:
"""
- workflows:
- golangci-lint.yaml
- lint.yaml
- test.yaml
"""
Expand All @@ -113,7 +113,7 @@ Feature: OS FS
Then there should be only these files:
"""
- workflows:
- golangci-lint.yaml
- lint.yaml
- test.yaml
"""
```
Expand All @@ -134,7 +134,7 @@ Feature: OS FS
Then there should be only these files:
"""
- workflows:
- golangci-lint.yaml
- lint.yaml
- test.yaml
"""
```
Expand Down Expand Up @@ -421,7 +421,7 @@ For examples:
Then there should be only these files in "$TEST_DIR/../../.github":
"""
- workflows:
- golangci-lint.yaml
- lint.yaml
- test.yaml
"""
```
Expand Down
4 changes: 2 additions & 2 deletions features/bootstrap/godog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
Expand Down Expand Up @@ -56,7 +56,7 @@ func RunSuite(t *testing.T, path string, featureContext func(t *testing.T, ctx *

var paths []string

files, err := ioutil.ReadDir(filepath.Clean(path))
files, err := os.ReadDir(filepath.Clean(path))
assert.NoError(t, err)

paths = make([]string, 0, len(files))
Expand Down
14 changes: 7 additions & 7 deletions features/os.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Feature: OS FS
"""
- .github:
- workflows:
- golangci-lint.yaml
- lint.yaml
- test.yaml
- dependabot.yml
"""
Expand All @@ -73,7 +73,7 @@ Feature: OS FS
"""
- .github:
- workflows:
- golangci-lint.yaml
- lint.yaml
- test.yaml
- dependabot.yml
"""
Expand All @@ -85,7 +85,7 @@ Feature: OS FS
"""
- .github:
- workflows:
- golangci-lint.yaml
- lint.yaml
- test.yaml
- dependabot.yml
"""
Expand All @@ -97,7 +97,7 @@ Feature: OS FS
"""
- .github:
- workflows:
- golangci-lint.yaml
- lint.yaml
- test.yaml
- dependabot.yml
"""
Expand All @@ -109,7 +109,7 @@ Feature: OS FS
Then there should be only these files:
"""
- workflows:
- golangci-lint.yaml
- lint.yaml
- test.yaml
- dependabot.yml
"""
Expand All @@ -121,7 +121,7 @@ Feature: OS FS
Then there should be only these files:
"""
- workflows:
- golangci-lint.yaml
- lint.yaml
- test.yaml
- dependabot.yml
"""
Expand All @@ -130,7 +130,7 @@ Feature: OS FS
Then there should be only these files in "$TEST_DIR/../../.github":
"""
- workflows:
- golangci-lint.yaml
- lint.yaml
- test.yaml
- dependabot.yml
"""
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ go 1.17
require (
github.com/cucumber/godog v0.12.5
github.com/godogx/expandvars v0.1.1
github.com/nhatthm/aferoassert v0.1.6
github.com/nhatthm/aferomock v0.3.1
github.com/spf13/afero v1.9.2
github.com/stretchr/testify v1.8.0
go.nhat.io/aferoassert v0.2.0
go.nhat.io/aferomock v0.4.0
)

require (
github.com/cucumber/gherkin-go/v19 v19.0.3 // indirect
github.com/cucumber/messages-go/v16 v16.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/gofrs/uuid v4.1.0+incompatible // indirect
github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-memdb v1.3.2 // indirect
github.com/hashicorp/go-memdb v1.3.3 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me
github.com/godogx/expandvars v0.1.1 h1:akTQTzanoPG6QBGI5M9GhY7obzgQOLbRFoOWkUDbxCs=
github.com/godogx/expandvars v0.1.1/go.mod h1:V9sevK3sRDOMlxNUqDNx1qoqAiOxpXcMPhBMmwKllsk=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v4.1.0+incompatible h1:sIa2eCvUTwgjbqXrPLfNwUf9S3i3mpH1O1atV+iL/Wk=
github.com/gofrs/uuid v4.1.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
Expand Down Expand Up @@ -172,8 +172,9 @@ github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh
github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-memdb v1.3.0/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g=
github.com/hashicorp/go-memdb v1.3.2 h1:RBKHOsnSszpU6vxq80LzC2BaQjuuvoyaQbkLTf7V7g8=
github.com/hashicorp/go-memdb v1.3.2/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g=
github.com/hashicorp/go-memdb v1.3.3 h1:oGfEWrFuxtIUF3W2q/Jzt6G85TrMk9ey6XfYLvVe1Wo=
github.com/hashicorp/go-memdb v1.3.3/go.mod h1:uBTr1oQbtuMgd1SSGoR8YV27eT3sBHbYiNm53bMpgSg=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
Expand Down Expand Up @@ -230,9 +231,6 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nhatthm/aferoassert v0.1.6 h1:qsGm9fTB7aj1B5zvUftzNyo+bNFba/6dPiRT2wBjM7s=
github.com/nhatthm/aferoassert v0.1.6/go.mod h1:Oirgw+hWRqCSg+p+lDhg2uKpcXMRM2DOi8JlTT6MNeg=
github.com/nhatthm/aferomock v0.3.0/go.mod h1:/oTcy0NDM+qQJEEOWiuiKuogilXvv/KZcdaXaP/rX3g=
github.com/nhatthm/aferomock v0.3.1 h1:L6oGPOdm+GoJ0HDoo2XZpVq++JieZs5PBUdM/8hO8aY=
github.com/nhatthm/aferomock v0.3.1/go.mod h1:mev14Kms7DBCX/djc5zmf57EgLgmA6k2654EzvRq1vM=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
Expand Down Expand Up @@ -301,6 +299,10 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.nhat.io/aferoassert v0.2.0 h1:mKPpr3Fo1UMZf/EbBrRxwBiim3UX5lyVPSGTktGL4r4=
go.nhat.io/aferoassert v0.2.0/go.mod h1:nvq2Y4ZM+DrrYF0ZkQse46FUGZRcvxnDe+xdWR7uZG4=
go.nhat.io/aferomock v0.4.0 h1:gs3nJzIqAezglUuaPfautAmZwulwRWLcfSSzdK4YCC0=
go.nhat.io/aferomock v0.4.0/go.mod h1:msi5MDOtJ/AroUa/lDc3jVGOILM4SKP//4yBRImOvkI=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
Expand Down Expand Up @@ -453,7 +455,6 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -614,7 +615,6 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
2 changes: 1 addition & 1 deletion manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/cucumber/godog"
"github.com/godogx/expandvars"
"github.com/nhatthm/aferoassert"
"github.com/spf13/afero"
"go.nhat.io/aferoassert"
)

const defaultFs = "_default"
Expand Down
6 changes: 3 additions & 3 deletions manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"testing"

"github.com/cucumber/godog"
"github.com/nhatthm/aferomock"
"github.com/spf13/afero"
"github.com/spf13/afero/mem"
"github.com/stretchr/testify/assert"
"go.nhat.io/aferomock"
)

func newManager(t *testing.T, mockFs aferomock.FsMocker) *Manager {
Expand Down Expand Up @@ -764,7 +764,7 @@ func TestManager_AssertFileTreeEqual(t *testing.T) {

expected := `
- workflows:
- golangci-lint.yaml
- lint.yaml
- test.yaml
- dependabot.yml
`
Expand Down Expand Up @@ -810,7 +810,7 @@ func TestManager_AssertFileTreeContains(t *testing.T) {

expected := `
- workflows:
- golangci-lint.yaml
- lint.yaml
- test.yaml
`

Expand Down

0 comments on commit a030243

Please sign in to comment.