VoteStore refactor #2338
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |