-
Notifications
You must be signed in to change notification settings - Fork 12
172 lines (145 loc) · 5.48 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
name: CI
on:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }} # only run on non-draft PRs
services:
postgres:
image: kwildb/postgres:latest
env:
POSTGRES_PORT: 5432
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
# shared setup for all tests
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: '23.4'
- name: Install Taskfile
uses: arduino/setup-task@v2
#ubuntu-latest has go 1.21 installed https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md#go
#self-hosted also has go 1.21 installed
#the default behavior here will load pre-installed go version
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
check-latest: true
#cache: false
- name: Install dependencies
run: |
go version
task install:deps
# checks
- name: Check tidiness of go.mod and go.sum
run: |
./scripts/mods/check_tidy
- name: Ensure generated protobuf Go source is up-to-date
run: |
./scripts/proto/check_up
- name: Ensure generated swagger Go code is up-to-date
run: |
./scripts/swagger/check_up
- name: Compile packages, apps, and specs
run: | # enter workspace mode to do this on one line
go work init && go work use . ./parse ./test ./core
go build -mod=readonly ./... ./parse/... ./core/... ./test/specifications/
- name: Lint
uses: golangci/[email protected]
with:
install-mode: "binary"
version: "latest"
skip-pkg-cache: true
args: ./... ./core/... ./test/... ./parse/... --timeout=10m --config=.golangci.yml --skip-dirs ./core/rpc/protobuf
# unit test
- name: Run unit test
run: |
task test:unit
# integration test
- name: Generate go vendor
#for faster builds and private repos, need to run this after pb:compile:v1
run: |
task vendor
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers for kwild
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache-kwild
key: ${{ runner.os }}-buildx-kwild-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-kwild
- name: manual git tag
run: |
version=`echo ${{ github.sha }} | cut -c 1-7`
echo "GIT_TAG=$version" >> $GITHUB_ENV
#run: echo "GIT_TAG=`git describe --match 'v[0-9]*' --dirty --always --tags | sed 's/^v//'`" >> $GITHUB_ENV
- name: manual build time
run: |
build_time=`TZ=UTC date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +"%Y-%m-%dT%H:%M:%SZ"`
echo "BUILD_TIME=$build_time" >> $GITHUB_ENV
- name: Build cli binaries
run: |
task build:cli
task build:admin
- name: Pull math extension docker image
run: |
docker pull kwilbrennan/extensions-math:multi-arch --platform linux/amd64
- name: Build kwild image
id: docker_build_kwild
uses: docker/build-push-action@v5
with:
context: .
load: true
builder: ${{ steps.buildx.outputs.name }}
build-args: |
git_commit=${{ github.sha }}
version=${{ env.GIT_TAG }}
build_time=${{ env.BUILD_TIME }}
# go_race=-race
file: ./build/package/docker/kwild.dockerfile
push: false
tags: kwild:latest
cache-from: type=local,src=/tmp/.buildx-cache-kwild
cache-to: type=local,dest=/tmp/.buildx-cache-kwild-new
# maybe no need
- name: Run acceptance test
run: |
testUserID=$(id -u)
testGroupID=$(id -g)
cp test/acceptance/docker-compose.override.yml.example test/acceptance/docker-compose.override.yml
sed -i "s/\${UID}:\${GID}/${testUserID}:${testGroupID}/g" test/acceptance/docker-compose.override.yml
KACT_LOG_LEVEL=warn task test:act:nb
- name: Run integration test
# without kgw test, probably should disable this ?
run: |
testUserID=$(id -u)
testGroupID=$(id -g)
cp test/integration/docker-compose.override.yml.example test/integration/docker-compose.override.yml
sed -i "s/\${UID}:\${GID}/${testUserID}:${testGroupID}/g" test/integration/docker-compose.override.yml
KIT_LOG_LEVEL=warn task test:it:nb
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache-kwild
mv /tmp/.buildx-cache-kwild-new /tmp/.buildx-cache-kwild
- name: Prune Docker
if: ${{ always() }}
run: docker rm $(docker ps -a -q) -f ; docker network prune -f ; docker volume prune -f || true
- name: Show error log
if: ${{ failure() }}
run: grep -C 20 -s -i -r -e 'kwild version' -e 'error' -e 'warn' /tmp/TestKwilAct*/*.log /tmp/TestKwilInt*/*.log /tmp/TestKwilInt*/*/*.log