-
Notifications
You must be signed in to change notification settings - Fork 3
54 lines (44 loc) · 1.36 KB
/
build-and-test.yml
File metadata and controls
54 lines (44 loc) · 1.36 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
name: 'Build and test code'
on:
push:
branches: [main]
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
go-version: 1.18
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Generate code
run: |
docker run --rm -v ${GITHUB_WORKSPACE}:/local openapitools/openapi-generator-cli:v7.0.0 generate -i /local/api/notification-service.yaml -g go-server -o /local/ -p sourceFolder=internal/server -p packageName=server --git-user-id=commitdev --git-repo-id=zero-notification-service
sudo chmod -R a+rw ${GITHUB_WORKSPACE}
go install golang.org/x/tools/cmd/goimports@latest
goimports -w ${GITHUB_WORKSPACE}/internal/server/
- name: Run go vet
id: go_vet
run: |
go vet ${GITHUB_WORKSPACE}/...
- name: Run go fmt
id: go_fmt
run: |
BAD_FILES=$(gofmt -l ${GITHUB_WORKSPACE})
[[ "${BAD_FILES}" == "" ]] || (echo "Formatting errors detected: ${BAD_FILES}" && exit 1)
- name: Build project
id: build
run: |
make build
- name: Run tests
id: test
run: |
make test