-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (102 loc) · 3.84 KB
/
ci.yml
File metadata and controls
119 lines (102 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# CI 静的解析(fmt, lint)、テストのフローを自動化
# トリガー: 全ブランチに対するPR
name: CI
on:
pull_request:
branches:
- '*'
env:
# go.sumに変化がない時にキャッシュを更新したい場合は、変更してください
cache-version: v1
jobs:
# static-check: fmt, lint
static-check:
name: StaticCheck
runs-on: ubuntu-latest
steps:
# set up go
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
# Run fmt
- name: Go fmt
run: |
GO111MODULE=off go get -u golang.org/x/tools/cmd/goimports
gofmt -s -w .
~/go/bin/goimports -w .
# Run lint
- name: Go Lint
run: |
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint
~/go/bin/golangci-lint run
# test go test
test:
name: Test
runs-on: ubuntu-latest
needs: [ static-check ]
steps:
# set up go
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
# Cache
- name: Cache go module
uses: actions/cache@v1
id: cache-go
with:
path: ~/go/pkg/mod
key: ${{ env.cache-version }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ env.cache-version }}-${{ runner.os }}-go-
# Install modules
- name: Get dependencies
if: steps.cache-go.outputs.cache-hit != 'true'
run: |
go get -v -t -d ./...
# Run test
- name: Test
run: go test -v ./...
# slackの通知
slack-notification:
name: Slack Notification
runs-on: ubuntu-latest
needs: [test, static-check]
if: always()
steps:
- uses: actions/checkout@v2
- uses: technote-space/workflow-conclusion-action@v1
# 失敗時
- name: Slack Notification Failure
if: env.WORKFLOW_CONCLUSION == 'failure'
uses: rtCamp/action-slack-notify@v2.0.0
env:
SLACK_CHANNEL: notify-server
SLACK_ICON: https://github.com/actions.png?size=48
SLACK_COLOR: '#ff0000'
SLACK_TITLE: 'static check & test is failure!!!'
SLACK_MESSAGE: |
CI failure!
See more detail to check github.
https://github.com/TechCafeFreedom/Wantum-server/actions
SLACK_USERNAME: GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
# 成功時
- name: Slack Notification Success
if: env.WORKFLOW_CONCLUSION == 'success'
uses: rtCamp/action-slack-notify@v2.0.0
env:
SLACK_CHANNEL: notify-server
SLACK_ICON: https://github.com/actions.png?size=48
SLACK_TITLE: 'static check & test success!'
SLACK_MESSAGE: |
CI Success!
SLACK_USERNAME: GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}