-
Notifications
You must be signed in to change notification settings - Fork 6
159 lines (152 loc) · 4.39 KB
/
ci.yml
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# SPDX-FileCopyrightText: 2023 Siemens AG
#
# SPDX-License-Identifier: Apache-2.0
#
# Author: Michael Adler <[email protected]>
---
name: CI
on: [push, pull_request, workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["stable", "1.18"]
name: Build (Go ${{ matrix.go }})
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- uses: korandoru/setup-zig@v1
with:
zig-version: 0.10.1
- run: |
# goreleaser requires an absolute path to the compiler
install -m0755 .ci/zcc /usr/local/bin/zcc
- name: build
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: build --clean --single-target --snapshot
env:
CC: /usr/local/bin/zcc
test:
runs-on: ubuntu-latest
name: Test
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: stable
- run: make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out
test-postgres:
runs-on: ubuntu-latest
name: Test PostgreSQL
container: golang:latest
services:
postgres:
image: postgres:15
env:
# see https://hub.docker.com/_/postgres
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
POSTGRES_DB: wfx
POSTGRES_USER: wfx
POSTGRES_PASSWORD: secret
POSTGRES_HOST_AUTH_METHOD: trust
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 3s
--health-timeout 5s
--health-retries 20
steps:
- uses: actions/checkout@v3
- run: go test -race -coverprofile=coverage.out -covermode=atomic -tags testing,integration,postgres,sqlite ./...
env:
PGHOST: postgres
PGPORT: 5432
PGDATABASE: wfx
PGUSER: wfx
PGPASSWORD: secret
PGSSLMODE: disable
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out
test-mysql:
runs-on: ubuntu-latest
name: Test MySQL
container: golang:latest
services:
mysql:
image: mysql:8-debian
env:
# see https://hub.docker.com/_/mysql
MYSQL_DATABASE: wfx
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: wfx
MYSQL_PASSWORD: secret
MYSQL_HOST: mysql
# Set health checks to wait until mysql has started
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval 3s
--health-timeout 5s
--health-retries 20
steps:
- uses: actions/checkout@v3
- run: go test -race -coverprofile=coverage.out -covermode=atomic -tags testing,integration,mysql,sqlite ./...
env:
MYSQL_DATABASE: wfx
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: wfx
MYSQL_PASSWORD: secret
MYSQL_HOST: mysql
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out
lint:
runs-on: ubuntu-latest
name: Lint
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: stable
- name: "Install staticcheck"
run: .ci/setup/staticcheck.sh
- name: "Run staticcheck"
run: staticcheck -tags=sqlite,testing ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: "v1.52.2"
args: --build-tags=sqlite,testing
skip-cache: true
generate:
runs-on: ubuntu-latest
name: Generate Code
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: stable
- name: "Install just"
run: .ci/setup/just.sh
- name: "Install go-swagger"
run: .ci/setup/swagger.sh
- run: sudo apt-get update -q && sudo apt-get install -y python3-yaml
- run: just generate
- run: git diff --exit-code