-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (85 loc) · 2.56 KB
/
ci.yaml
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
name: ci
on:
push:
branches:
- "feat/**"
- "refactor/**"
- "fix/**"
pull_request:
branches:
- "main"
workflow_call:
permissions: write-all
jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
goversion: [">=1.21.0"]
env:
AWS_ACCESS_KEY_ID: ABC1234567890
AWS_SECRET_ACCESS_KEY: ABC1234567890
AWS_DEFAULT_REGION: ap-northeast-1
DYNAMODB_ENDPOINT: http://localhost:8000
services:
dynamodb:
image: amazon/dynamodb-local:latest
ports:
- 8000:8000
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.goversion }}
cache: true
cache-dependency-path: go.sum
- name: Setup mockgen
run: |
go install go.uber.org/mock/mockgen@latest
- name: Go Generate
run: |
go mod tidy
go generate ./...
git diff --exit-code
- name: Setup reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
- name: Setup staticcheck
run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
- name: staticcheck with reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
staticcheck ./... | reviewdog -f=staticcheck -reporter=github-pr-check -level warning
- name: Unit Test
run: |
TARGET=$(go list ./... | grep -v "mock")
go test $TARGET -v -coverpkg=$TARGET -coverprofile=coverage.out
- name: Upload unit test coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out
fail_ci_if_error: false
verbose: true
flags: unit
- name: Create Table
working-directory: ./.github
run: |
aws dynamodb create-table --cli-input-json file://table-def.json --endpoint-url ${{ env.DYNAMODB_ENDPOINT }}
- name: Integration Test
working-directory: ./integrationtest
run: |
go mod tidy
go test -v -coverpkg=${{ format('github.com/{0}', github.repository) }} -coverprofile=coverage.out
- name: Upload integration test coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./integrationtest/coverage.out
fail_ci_if_error: false
verbose: true
flags: integration