-
Notifications
You must be signed in to change notification settings - Fork 3
175 lines (168 loc) · 5.06 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: CI
on:
push:
branches:
- 'main'
paths-ignore:
- 'dashboard/**'
- 'docs/**'
- 'README.md'
- '.github/**'
- '!.github/workflows/ci.yaml'
pull_request:
paths-ignore:
- 'dashboard/**'
- 'docs/**'
- 'README.md'
- '.github/**'
- '!.github/workflows/ci.yaml'
jobs:
mod:
name: Modules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- run: go mod download
build:
name: Build
runs-on: ubuntu-latest
needs: [mod]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- run: go build -o ns ./cmd
lint:
name: Lint
runs-on: ubuntu-latest
needs: [mod]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Install reviewdog
run: curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
- name: Install golangci-lint
run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin
- name: Run golangci-lint
run: golangci-lint run --out-format=line-number | reviewdog -f=golangci-lint -name=golangci-lint -reporter=github-check
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test:
name: Test
runs-on: ubuntu-latest
needs: [mod]
strategy:
matrix:
race:
- ''
- -race
env:
ENABLE_DB_TESTS: 'true'
ENABLE_DOCKER_TESTS: 'true'
DOCKER_API_VERSION: '1.43'
services:
mysql:
image: mysql:8
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=3s --health-retries=10
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: neoshowcase
ports:
- 5004:3306
mongo:
image: mongo
env:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
ports:
- 5010:27017
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Run migration
run: |
go install github.com/sqldef/sqldef/cmd/mysqldef@latest
DB_PORT=5004 ./migrations/entrypoint.sh ./migrations/schema.sql
- name: Run tests
run: go test ./... -v ${{ matrix.race }} -coverprofile=coverage.out -covermode=atomic -vet=off
- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash)
if: matrix.race == ''
k8s-test:
name: K8s Test
runs-on: ubuntu-latest
needs: [mod]
strategy:
matrix:
race:
- ''
- -race
env:
ENABLE_K8S_TESTS: 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Create single cluster
uses: AbsaOSS/k3d-action@v2
id: single-cluster
with:
cluster-name: 'test-cluster'
args: >-
--agents 1
--no-lb
--k3s-arg "--disable=traefik,servicelb,metrics-server@server:0"
- name: Show cluster info
run: |
echo ${{ steps.single-cluster.outputs.network }}
echo ${{ steps.single-cluster.outputs.subnet-CIDR }}
docker ps -a
kubectl cluster-info --context k3d-test-cluster
kubectl config use-context k3d-test-cluster
kubectl get nodes -o wide
- name: Create namespace
run: kubectl create ns neoshowcase-apps
- name: Install CRDs
run: |
kubectl apply -f https://raw.githubusercontent.com/traefik/traefik/v3.0.0/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml
- name: Run tests
run: go test ./pkg/infrastructure/backend/k8simpl -v ${{ matrix.race }} -coverprofile=coverage.out -covermode=atomic -vet=off
- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash)
if: matrix.race == ''
tbls:
name: TBLS
runs-on: ubuntu-latest
services:
mysql:
image: mariadb:10.8.3
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: neoshowcase
ports:
- 5004:3306
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Run migration
run: |
go install github.com/sqldef/sqldef/cmd/mysqldef@latest
DB_PORT=5004 ./migrations/entrypoint.sh ./migrations/schema.sql
- uses: k1low/setup-tbls@v1
with:
version: v1.65.3
- run: tbls lint
env:
TBLS_DSN: 'mariadb://root:password@127.0.0.1:5004/neoshowcase'