Skip to content

Commit

Permalink
use GitHub Actions (#19)
Browse files Browse the repository at this point in the history
* fix to use GitHub Actions

* use Go 1.21

* disable Reviewdog
  • Loading branch information
ktr0731 authored Aug 17, 2023
1 parent 2c8e7c9 commit a9b6dc8
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 258 deletions.
75 changes: 0 additions & 75 deletions .circleci/config.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: main
on:
push:
branches:
- '**'
jobs:
test:
permissions:
contents: read
runs-on: ubuntu-latest
defaults:
run:
shell: bash -eu -o pipefail {0}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup go
id: setup-go
uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: Download dependencies
if: ${{ steps.setup-go.outputs.cache-hit != 'true' }}
run: |
go mod download
- name: Run test
run: |
make test
lint:
permissions:
contents: read
runs-on: ubuntu-latest
defaults:
run:
shell: bash -eu -o pipefail {0}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup go
id: setup-go
uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: Download dependencies
if: ${{ steps.setup-go.outputs.cache-hit != 'true' }}
run: |
go mod download
- name: Run lint tools
run: |
make lint
10 changes: 2 additions & 8 deletions .reviewdog.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
runner:
# https://golang.org/cmd/vet/
govet:
cmd: go vet $(go list ./...)

# https://github.com/golang/lint
golint:
cmd: golint $(go list ./...)
errorformat:
- "%f:%l:%c: %m"
format: govet

# https://github.com/client9/misspell
misspell:
Expand All @@ -17,7 +11,7 @@ runner:

# https://github.com/kisielk/errcheck
errcheck:
cmd: errcheck -exclude .errcheck_excludes -ignore 'fmt:.*,io:.*,ioutil:.*,net/http:.*' -ignoretests $(go list ./...)
cmd: errcheck -ignore 'fmt:.*,io:.*,ioutil:.*,net/http:.*' -ignoretests $(go list ./...)
errorformat:
- "%f:%l:%c:%m"

Expand Down
14 changes: 5 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ export GO111MODULE = on

REPOSITORY = go.mercari.io/go-emv-code
PACKAGES ?= $(shell go list ./...)
ifneq ($(CIRCLECI),)
PACKAGES=$(shell go list ./... | circleci tests split)
endif

GO_TEST ?= go test
GO_TEST_TARGET ?= .

REVIEWDOG_ARG ?= -diff="git diff master"

LINT_TOOLS=$(shell cat tools/tools.go | egrep '^\s_ ' | awk '{ print $$2 }')

GOPATH := $(shell go env GOPATH)
Expand All @@ -28,14 +23,15 @@ bootstrap-lint-tools:
test: ## Run go test
${GO_TEST} -v -race -mod=readonly -run=$(GO_TEST_TARGET) $(PACKAGES)

.PHONY: lint
lint: bootstrap-lint-tools ## Run lint tools
go vet ./...
staticcheck ./...

.PHONY: coverage
coverage: ## Collect test coverage
${GO_TEST} -v -race -mod=readonly -run=$(GO_TEST_TARGET) -covermode=atomic -coverpkg=${REPOSITORY}/... -coverprofile=$@.out $(PACKAGES)

.PHONY: reviewdog
reviewdog: bootstrap-lint-tools ## Run reviewdog
reviewdog -conf=.reviewdog.yml $(REVIEWDOG_ARG)

.PHONY: help
help: ## Show this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[33m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z\/_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# go-emv-code [![CircleCI][circleci-badge]][circleci] [![GoDoc][godoc-badge]][godoc] [![Go Report Card][goreport-badge]][goreport]
# go-emv-code [![GitHub Actions][gh-actions-badge]][gh-actions] [![GoDoc][godoc-badge]][godoc] [![Go Report Card][goreport-badge]][goreport]

[circleci]: https://circleci.com/gh/mercari/go-emv-code/tree/master
[circleci-badge]: https://circleci.com/gh/mercari/go-emv-code/tree/master.svg?style=svg
[gh-actions]: https://github.com/mercari/go-emv-code/actions/workflows/main.yml
[gh-actions-badge]: https://github.com/mercari/go-emv-code/actions/workflows/main.yml/badge.svg
[godoc]: https://godoc.org/go.mercari.io/go-emv-code
[godoc-badge]: https://godoc.org/go.mercari.io/go-emv-code?status.svg
[goreport]: https://goreportcard.com/report/go.mercari.io/go-emv-code
Expand Down Expand Up @@ -29,21 +29,15 @@ https://www.mercari.com/cla/
* requirements
* Go version must be at least 1.12 (Modules)

1. Testing in local
Testing in local

```
$ make test
```

2. Testing with [Circle CI CLI](https://circleci.com/docs/2.0/local-jobs/)

```
$ circleci build --job test
```

## License

Copyright 2019 Mercari, Inc.
Copyright 2019-2023 Mercari, Inc.

Licensed under the MIT License.

Expand Down
2 changes: 1 addition & 1 deletion crc16/crc16.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (d *digest) Sum16() uint16 { return d.crc }

func (d *digest) Sum(in []byte) []byte {
s := d.Sum16()
return append(in, byte(s>>16), byte(s>>8), byte(s))
return append(in, 0, byte(s>>8), byte(s))
}

// Hash16 is the common interface implemented by all 16-bit hash functions.
Expand Down
17 changes: 9 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
module go.mercari.io/go-emv-code

go 1.12
go 1.21

require honnef.co/go/tools v0.4.3

require (
github.com/client9/misspell v0.3.4
github.com/kisielk/errcheck v1.2.0
github.com/reviewdog/reviewdog v0.9.12
golang.org/x/lint v0.0.0-20190409202823-959b441ac422
golang.org/x/tools v0.0.0-20190918214516-5a1a30219888
gotest.tools/gotestsum v0.3.5
honnef.co/go/tools v0.0.0-2019.2.1
github.com/BurntSushi/toml v1.2.1 // indirect
golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/tools v0.6.0 // indirect
)
Loading

0 comments on commit a9b6dc8

Please sign in to comment.