-
Notifications
You must be signed in to change notification settings - Fork 12
202 lines (173 loc) · 6.72 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: CI
on:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
branches:
- main
- release*
# path filter won't work bcz PR status check will be 'pending' if workflow is
# skipped due to path filtering, i.e. blocked
#paths:
workflow_dispatch:
jobs:
# JOB to run change detection
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
run: ${{ steps.filter.outputs.code }}
steps:
# For pull requests it's not necessary to checkout the code
# but it's useful to see the effect of the path filter in current PR
- uses: actions/checkout@v4
with:
# This may save additional git fetch roundtrip if
# merge-base is found within latest 20 commits
fetch-depth: 20
- uses: dorny/paths-filter@v3.0.2
id: filter
with:
# Path to file where filters are defined
filters: .github/filters.yaml
#predicate-quantifier: 'every' # check dorny/paths-filter#225
test:
needs: changes
# only run only if there are changes and non-draft PRs
if: ${{ needs.changes.outputs.run == 'true' && !github.event.pull_request.draft}}
runs-on: ubuntu-latest
services:
postgres:
image: kwildb/postgres:16.2-1
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 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.23.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 generate antlr Go code is up-to-date
run: |
./scripts/kuneiform/check_tidy
- name: Compile packages, apps, and specs
run: | # enter workspace mode to do this on one line
go work init . ./test ./core ./parse
go build -mod=readonly ./... ./core/... ./parse/... ./test/specifications/
- name: Lint
uses: golangci/golangci-lint-action@v6.1.0
with:
install-mode: "binary"
version: "latest"
args: ./... ./core/... ./parse/... ./test/... --timeout=10m --config=.golangci.yml
# 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 # both restore and save
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: compile the core/client/example app
run: GOWORK=off go build -o /dev/null
working-directory: core/client/example
- name: compile the core/gatewayclient/example app
run: GOWORK=off go build -o /dev/null
working-directory: core/gatewayclient/example
- 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
- 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
run: |
testUserID=$(id -u)
testGroupID=$(id -g)
cp test/integration/docker-compose.override.yml.example test/integration/docker-compose.override.yml
cp test/integration/docker-compose-migration.override.yml.example test/integration/docker-compose-migration.override.yml
sed -i "s/\${UID}:\${GID}/${testUserID}:${testGroupID}/g" test/integration/docker-compose.override.yml
sed -i "s/\${UID}:\${GID}/${testUserID}:${testGroupID}/g" test/integration/docker-compose-migration.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