Skip to content

Commit c3ac387

Browse files
committed
add github actions
1 parent 05cffbc commit c3ac387

File tree

4 files changed

+180
-0
lines changed

4 files changed

+180
-0
lines changed

.github/.golangci.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
linters-settings:
2+
dupl:
3+
threshold: 100
4+
errcheck:
5+
check-type-assertions: true
6+
ignore: fmt:.*,io/ioutil:^Read.*,io:Close,os:Close,io/fs:Close
7+
goconst:
8+
min-len: 2
9+
min-occurrences: 2
10+
goimports:
11+
local-prefixes: github.com/golangci/golangci-lint
12+
golint:
13+
min-confidence: 0
14+
govet:
15+
check-shadowing: true
16+
misspell:
17+
locale: US
18+
ignore-words: []
19+
20+
linters:
21+
disable-all: true
22+
enable:
23+
# HTTPリクエストで閉じられていないものを検出
24+
- bodyclose
25+
# 使われていないコードを検出
26+
- deadcode
27+
# _, _ := x() のようなものを検出
28+
- dogsled
29+
# 同一コードの検出
30+
- dupl
31+
# エラーを未チェックのものを検出
32+
- errcheck
33+
# 定数化できるものを検出
34+
- goconst
35+
# gofmt
36+
- gofmt
37+
# goimports
38+
- goimports
39+
# golint
40+
- golint
41+
# 引数がフォーマット文字列と一致しないものを検出
42+
- govet
43+
# 意味のない再代入を検出
44+
- ineffassign
45+
# スペルチェック
46+
- misspell
47+
# for中などで固定されてない変数を検出
48+
- scopelint
49+
# 構造体の未使用フィールドを検出
50+
- structcheck
51+
# 不要な型変換を検出
52+
- unconvert
53+
# 未使用のものを検出
54+
- unused
55+
# 未使用のグローバル変数・定数を検出
56+
- varcheck
57+
# 前後の余計な空白を検出
58+
- whitespace
59+
60+
issues:
61+
exclude:
62+
- declaration of "(err|ctx)" shadows declaration at
63+
exclude-use-default: false
64+
exclude-rules:
65+
- path: _test\.go
66+
linters:
67+
- gomnd
68+
- dupl
69+
70+
- linters:
71+
- lll
72+
source: "//go:generate "
73+
74+
run:
75+
skip-dirs:
76+
- test/testdata_etc
77+
- internal/cache
78+
- internal/renameio
79+
- internal/robustio
80+
81+
service:
82+
golangci-lint-version: 1.23.x
83+
prepare:
84+
- echo "here I can run custom commands, but no preparation needed for this repo"

.github/workflows/go.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Go
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- develop
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
env:
14+
GO111MODULE: on
15+
16+
steps:
17+
- name: Set up Go 1.16
18+
uses: actions/setup-go@v2
19+
with:
20+
go-version: 1.16
21+
id: go
22+
23+
- uses: actions/checkout@v2
24+
25+
- uses: actions/cache@v1
26+
with:
27+
path: ~/go/pkg/mod
28+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
29+
restore-keys: |
30+
${{ runner.os }}-go-
31+
32+
- name: Run tests
33+
run: |
34+
make test

.github/workflows/linter.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: linter
2+
on: [pull_request]
3+
jobs:
4+
golangci-lint:
5+
name: runner / golangci-lint
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Check out code into the Go module directory
9+
uses: actions/checkout@v2
10+
- uses: actions/setup-go@v2
11+
with:
12+
go-version: 1.16
13+
- name: Install dependencies
14+
working-directory: /tmp
15+
run: |
16+
go get golang.org/x/tools/cmd/goimports
17+
- name: Ensure samples are generated
18+
env:
19+
TZ: Asia/Tokyo
20+
run: |
21+
make gen_samples
22+
23+
clean=$(git status | grep "nothing to commit" || true)
24+
if [ -z "$clean" ]; then
25+
git diff
26+
echo 'Please run "make gen_samples"'
27+
exit 1
28+
fi
29+
- name: golangci-lint
30+
uses: golangci/golangci-lint-action@v2
31+
with:
32+
args: "--config=.github/.golangci.yml"
33+
skip-go-installation: true

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+*"
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 1
16+
17+
- name: Setup Go
18+
uses: actions/setup-go@v2
19+
with:
20+
go-version: 1.17
21+
22+
- name: Run GoReleaser for fti
23+
uses: goreleaser/goreleaser-action@v1
24+
with:
25+
version: latest
26+
args: release --rm-dist
27+
workdir: cmd/fti
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)