Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add more triggers #1440

Merged
merged 3 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 0 additions & 200 deletions .github/workflows/ci-release.yaml

This file was deleted.

140 changes: 140 additions & 0 deletions .github/workflows/integration-test-reuse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: integration-test-reuse

on:
workflow_call:
inputs:
# for logging purpose, if kdb-ref is from PR.
kdb-repo:
type: string
# for workflow_run trigger, we need to check out to the SHA, bcz most of
# the pr come from forked repo, and we can't access the branch, but we can
# access the sha(i.e, pull/xxx/head)
# In that case, use SHA as the input.
kdb-ref: # can be branch/tag/SHA
required: true
type: string

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:
- 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/[email protected]
id: filter
with:
filters: .github/filters.yaml
#predicate-quantifier: 'every'

integration-test:
needs: changes
# only run only if there are changes, or manually triggered
if: ${{ needs.changes.outputs.run == 'true' || github.event_name == 'workflow_dispatch'}}
runs-on: ubuntu-latest
steps:
- name: Show references
run: |
echo "====== integration test references ======"
echo "kdb repo: ${{ inputs.kdb-repo }}"
echo "kdb reference: ${{ inputs.kdb-ref }}"

- name: checkout kwil-db using ref from input
if: ${{ inputs.kdb-ref != '' }}
uses: actions/checkout@v4
with:
ref: ${{ inputs.kdb-ref }}
submodules: true

- name: checkout kwil-db using the reference or SHA for this event
if: ${{ inputs.kdb-ref == '' }}
uses: actions/checkout@v4
with:
submodules: true

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23.x'
check-latest: true

- name: Install Taskfile
uses: arduino/setup-task@v2

- name: Init workspace
run: |
task work

- name: Generate go vendor
run: |
go version
task vendor

- name: Build cli binaries
run: |
task build:cli

- 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

- 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@v6
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: ./contrib/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 integration test
run: |
testUserID=$(id -u)
testGroupID=$(id -g)
KINT_LOG_LEVEL=warn task test:it:nb -- -ugid "$testUserID:$testGroupID"

- 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/TestKwil*/*.log /tmp/TestKwil*/*/*.log
17 changes: 11 additions & 6 deletions .github/workflows/kgw-test-reuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:

- name: Init workspace
run: |
go work init . ./test ./core
task work

- name: Generate go vendor
run: |
Expand Down Expand Up @@ -194,7 +194,8 @@ jobs:
run: |
cd contrib/docker/compose/kwil
echo "run kwild in docker"
docker compose up -d
# NOTE: we use the default hardhat signer address
KWIL_DB_OWNER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 docker compose up -d
# clone kwil-js
git clone https://github.com/kwilteam/kwil-js.git /tmp/kwil-js
cd /tmp/kwil-js
Expand All @@ -214,19 +215,23 @@ jobs:
-b "http://kwild:8484" \
--chain-id $chain_id \
--allow-adhoc-query \
--log-level debug
--log-level debug \
--ip-request-rate-authn 0
echo "run KWIL-JS TEST against kwild(http://localhost:8484), with $chain_id"
PRIVATE_KEY=0000000000000000000000000000000000000000000000000000000000000001 CHAIN_ID=$chain_id GATEWAY_ON=false GAS_ON=false KWIL_PROVIDER=http://localhost:8484 npm run integration
# NOTE: we use the default hardhat private key
PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 CHAIN_ID=$chain_id KWIL_PROVIDER=http://localhost:8484 npm run integration
echo "run KWIL-JS TEST against kgw(http://localhost:8090), with $chain_id"
# assume the test above will drop the database, so we can deploy again
PRIVATE_KEY=0000000000000000000000000000000000000000000000000000000000000001 CHAIN_ID=$chain_id GATEWAY_ON=true GAS_ON=false KWIL_PROVIDER=http://localhost:8090 npm run integration
PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 CHAIN_ID=$chain_id GATEWAY_ON=TRUE KWIL_PROVIDER=http://localhost:8090 npm run integration
echo "stop running kwild & kgw"
docker rm -f kgwcontainer
cd -
docker compose down

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache-kwild
mv /tmp/.buildx-cache-kwild-new /tmp/.buildx-cache-kwild
rm -rf /tmp/.buildx-cache-kgw
mv /tmp/.buildx-cache-kgw-new /tmp/.buildx-cache-kgw

Expand All @@ -236,4 +241,4 @@ jobs:

- 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
run: grep -C 20 -s -i -r -e 'kwild version' -e 'error' -e 'warn' /tmp/TestKwil*/*.log /tmp/TestKwil*/*/*.log
Loading
Loading