Skip to content

Commit

Permalink
move building and testing jobs to GitHub Actions (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktr0731 authored Apr 12, 2020
1 parent 8d0a3b2 commit c130b0e
Show file tree
Hide file tree
Showing 16 changed files with 265 additions and 131 deletions.
76 changes: 0 additions & 76 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,5 @@
version: 2
jobs:
common:
working_directory: /go/src/github.com/ktr0731/evans
docker:
- image: ktr0731/circleci-evans
environment:
- GOCACHE: "/tmp/go/cache"
- GO111MODULE: "on"

steps:
- checkout

- restore_cache:
keys:
- mod-{{ checksum "go.sum" }}

- run:
name: install dependencies
command: make deps

- save_cache:
key: mod-{{ checksum "go.sum" }}
paths:
- /go/pkg/mod
when: always

- restore_cache:
keys:
- tool-{{ checksum "gotool.sum" }}

- run:
name: install tools
command: make tools

- save_cache:
key: tool-{{ checksum "gotool.sum" }}
paths:
- /go/pkg/dept
when: always

- restore_cache:
keys:
- build-cache-{{ .Branch }}--
- build-cache-master--

- persist_to_workspace:
root: /go
paths:
- "pkg/dept/*"
- "pkg/mod/*"
- "src/github.com/ktr0731/evans/_tools/*"

- run:
name: build
command: make build

- run:
name: coverage
command: make coverage-circleci

- run:
name: test
command: make test

- save_cache:
key: build-cache-{{ .Branch }}--{{ .Revision }}
paths:
- /tmp/go/cache
when: always

- run:
name: codecov
command: bash <(curl -s https://codecov.io/bash)

update-release:
working_directory: /go/src/github.com/ktr0731/evans
docker:
Expand All @@ -92,10 +19,7 @@ workflows:
version: 2
build_and_deploy:
jobs:
- common
- update-release:
requires:
- common
filters:
branches:
only:
Expand Down
27 changes: 22 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, windows-2019, macOS-10.14]
os: [ubuntu-latest, windows-latest, macOS-latest]
go: ['1.14']
steps:
- name: Set up Go ${{ matrix.go }}
Expand All @@ -18,12 +18,29 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Get dependencies
run: |
go mod tidy
- name: Cache modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.OS }}-go-${{ hashFiles('**/go.sum') }}

- name: Build
run: go build

- name: Lint
uses: actions-contrib/golangci-lint@v1
if: matrix.os == 'ubuntu-latest'
env:
GOROOT: ''
with:
args: run ./...

- name: Test
run: go test -v -race ./...
run: go test -p 1 -coverpkg ./... -covermode atomic -coverprofile coverage.txt ./...

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
if: matrix.os == 'ubuntu-latest'
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
44 changes: 35 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,40 @@ linters-settings:
simplify: false

linters:
enable-all: true
disable:
- gochecknoinits
- gochecknoglobals
enable:
- bodyclose
- deadcode
- dogsled
- dupl
- errcheck
- goconst
- gocritic
- gofmt
- goimports
- golint
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- prealloc
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
- interfacer
- lll
- scopelint
- maligned
- gocyclo
- funlen
- godox

issues:
exclude:
- G307 # gosec
exclude-rules:
- path: _test\.go
linters:
- interfacer
14 changes: 1 addition & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ deps: dep

.PHONY: dept
dept:
@go get github.com/ktr0731/dept@v0.1.1
@go get github.com/ktr0731/dept@v0.1.3
@go build -o _tools/dept github.com/ktr0731/dept

.PHONY: tools
Expand Down Expand Up @@ -53,18 +53,6 @@ gotest: lint
lint:
golangci-lint run ./...

.PHONY: coverage
coverage:
go test -coverpkg ./... -covermode=atomic -coverprofile=coverage.txt -race ./...

.PHONY: coverage-circleci
coverage-circleci:
go test -p 1 -coverpkg ./... -covermode=atomic -coverprofile=coverage.txt ./...

.PHONY: coverage-web
coverage-web: coverage
go tool cover -html=coverage.txt

.PHONY: brew-update
release:
bash .circleci/scripts/release.bash $(shell _tools/bump show meta/meta.go)
Expand Down
2 changes: 1 addition & 1 deletion config/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Test_migration(t *testing.T) {
t.Fatalf("failed to read a config file, but got '%s'", err)
}

err = ioutil.WriteFile(filepath.Join(cfgDir, "config.toml"), b, 0644)
err = ioutil.WriteFile(filepath.Join(cfgDir, "config.toml"), b, 0600)
if err != nil {
t.Fatalf("failed to copy a config file to a temp config dir, but got '%s'", err)
}
Expand Down
2 changes: 2 additions & 0 deletions cui/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func TestWriter(t *testing.T) {
}

for name, c := range cases {
c := c
t.Run(name, func(t *testing.T) {
ui := &basicUI{}
Writer(c.w)(ui)
Expand All @@ -40,6 +41,7 @@ func TestErrWriter(t *testing.T) {
}

for name, c := range cases {
c := c
t.Run(name, func(t *testing.T) {
ui := &basicUI{}
ErrWriter(c.ew)(ui)
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestMain(m *testing.M) {

b, err := exec.Command("git", "rev-parse", "--show-cdup").Output()
if err != nil {
panic(fmt.Sprintf("failed to execute 'git rev-parse --show-cdup'"))
panic(fmt.Sprintf("failed to execute 'git rev-parse --show-cdup': %s", err))
}
projRoot := strings.TrimSpace(string(b))
os.Remove(filepath.Join(projRoot, ".evans.toml"))
Expand Down
2 changes: 1 addition & 1 deletion e2e/old_repl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func compareWithGolden(t *testing.T, actual string) {
fname := normalizeFilename(name)

if *update {
if err := ioutil.WriteFile(fname, []byte(actual), 0644); err != nil {
if err := ioutil.WriteFile(fname, []byte(actual), 0600); err != nil {
t.Fatalf("failed to update the golden file: %s", err)
}
return
Expand Down
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls=
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
Expand Down Expand Up @@ -248,8 +246,6 @@ github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.6 h1:breEStsVwemnKh2/s6gMvSdMEkwW0sK8vGStnlVBMCs=
github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v0.0.7 h1:FfTH+vuMXOas8jmfb5/M7dzEYx7LpcLb7a0LPe34uOU=
github.com/spf13/cobra v0.0.7/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
Expand Down Expand Up @@ -368,10 +364,6 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.1 h1:zvIju4sqAGvwKspUQOhwnpcqSbzi7/H6QomNNjTL4sk=
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.28.0 h1:bO/TA4OxCOummhSf10siHuG7vJOiwh7SpRpFZDkOgl4=
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
google.golang.org/grpc v1.28.1 h1:C1QC6KzgSiLyBabDi87BbjaGreoRgGUF5nOyvfrAZ1k=
google.golang.org/grpc v1.28.1/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
Expand Down
30 changes: 28 additions & 2 deletions gotool.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
module tools

require (
github.com/bombsimon/wsl/v2 v2.2.0 // indirect
github.com/fatih/color v1.9.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-critic/go-critic v0.4.3 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/protobuf:/protoc-gen-go v1.3.2
github.com/golangci/golangci-lint:/cmd/golangci-lint v1.19.1
github.com/golangci/gocyclo v0.0.0-20180528144436-0a533e8fa43d // indirect
github.com/golangci/golangci-lint:/cmd/golangci-lint v1.24.0
github.com/golangci/revgrep v0.0.0-20180812185044-276a5c0a1039 // indirect
github.com/goreleaser/goreleaser v0.108.0
github.com/gostaticanalysis/analysisutil v0.0.3 // indirect
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect
github.com/kisielk/godepgraph v0.0.0-20190626013829-57a7e4a651a9
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/ktr0731/bump v0.1.0
github.com/matryer/moq v0.0.0-20200125112110-7615cbe60268
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mitchellh/mapstructure v1.2.2 // indirect
github.com/pelletier/go-toml v1.7.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/securego/gosec v0.0.0-20200401082031-e946c8c39989 // indirect
github.com/sirupsen/logrus v1.5.0 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v0.0.7 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.6.2 // indirect
github.com/stretchr/testify v1.5.1 // indirect
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890 // indirect
golang.org/x/tools v0.0.0-20200204230316-67a4523381ef // indirect
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d // indirect
golang.org/x/tools v0.0.0-20200403190813-44a64ad78b9b // indirect
google.golang.org/appengine v1.4.0 // indirect
gopkg.in/ini.v1 v1.55.0 // indirect
mvdan.cc/unparam v0.0.0-20200314162735-0ac8026f7d06 // indirect
sourcegraph.com/sqs/pbtypes v1.0.0 // indirect
)

go 1.13
Loading

0 comments on commit c130b0e

Please sign in to comment.