Skip to content

[WIP] CI: try kgw test on main branch update #22

[WIP] CI: try kgw test on main branch update

[WIP] CI: try kgw test on main branch update #22

Workflow file for this run

name: main
# for testing before merge to main
on:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
workflow_dispatch:
#on:
# branch:
# - main
# workflow_dispatch:
jobs:
kgw-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
check-latest: true
- name: Install Taskfile
uses: arduino/setup-task@v2
- name: Init workspace
run: |
pwd
go work init && go work use . ./parse ./test ./core
- name: Generate go vendor
run: | # should build the vendor using `go work vendor`?
go version
task vendor
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers for kgw # both restore and save
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache-kgw
key: ${{ runner.os }}-buildx-kgw-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-kgw
- name: Pull kgw repo & create vendor
env:
GH_ACCESS_TOKEN: ${{ secrets.KGW_MACH_SECRET_FOR_KWILDB }}
# vendor is used to bypass private repo issues
run: |
cat ~/.gitconfig
git config --global url."https://${GH_ACCESS_TOKEN}:[email protected]/kwilteam/".insteadOf "https://github.com/kwilteam/"
rm -rf /tmp/kgw
git clone https://github.com/kwilteam/kgw.git /tmp/kgw
cd /tmp/kgw
go work init && go work use . /home/runner/work/kwil-db/kwil-db/core
go work vendor
cd -
- name: Build kgw image
id: docker_build_kgw
uses: docker/build-push-action@v5
with:
context: /tmp/kgw
load: true
builder: ${{ steps.buildx.outputs.name }}
file: /tmp/kgw/Dockerfile
push: false
tags: kgw:latest
cache-from: type=local,src=/tmp/.buildx-cache-kgw
cache-to: type=local,dest=/tmp/.buildx-cache-kgw-new
- 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
- 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 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 }}
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: Build cli binaries
run: |
task build:cli
- name: Pull math extension docker image
run: |
docker pull kwilbrennan/extensions-math:multi-arch --platform linux/amd64
- name: Run kgw integration test
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 go test -count=1 -timeout 0 ./test/integration -run ^TestKGW$ -v
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache-kgw
mv /tmp/.buildx-cache-kgw-new /tmp/.buildx-cache-kgw
- 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/TestKwilInt*/*.log /tmp/TestKwilInt*/*/*.log