Skip to content

Merge pull request #664 from kubeagi/dependabot/pip/pypi/data-process… #2306

Merge pull request #664 from kubeagi/dependabot/pip/pypi/data-process…

Merge pull request #664 from kubeagi/dependabot/pip/pypi/data-process… #2306

Workflow file for this run

name: KubeagiTests
on:
push:
branches:
- 'main'
pull_request:
branches: [main]
workflow_dispatch:
inputs:
OnlyTestGeneratedSdk:
description: 'only test bff-sdk-generator, but not push'
required: true
default: 'true'
type: boolean
env:
LOG_DIR: "/tmp/kubeagi-example-test/logs"
GOPROXY: https://proxy.golang.org/,direct
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
build-image:
runs-on: ubuntu-latest
steps:
- name: Check whether the operator image of the same commit has been built.
id: cache
uses: actions/cache/restore@v3
with:
key: operator.image-${{ github.sha }}
path: /tmp/operator.image.tar
- name: Checkout code
uses: actions/checkout@v4
# It would be foolish to add the same judgment over and over again, but GitHub action currently does not have
# the syntax to skip all the next steps unless we let the pre step fail, and failure is not what we want.
# see https://github.com/actions/runner/issues/662
if: steps.cache.outputs.cache-hit != 'true'
- name: Setup Golang
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Build operator image
if: steps.cache.outputs.cache-hit != 'true'
run: |
make docker-build
- name: Save operator image to /tmp
if: steps.cache.outputs.cache-hit != 'true'
run: |
docker save controller:latest > /tmp/operator.image.tar
- name: Upload operator image
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
key: operator.image-${{ github.sha }}
path: /tmp/operator.image.tar
example-test:
env:
GRL_SDK_TEST_ONLY: true
needs:
- build-image
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
no: [1, 2, 3]
steps:
- uses: actions/checkout@v4
- name: Download operator image from cache
uses: actions/cache/restore@v3
with:
key: operator.image-${{ github.sha }}
path: /tmp/operator.image.tar
- name: Load component image to /tmp from cache
uses: actions/cache/restore@v3
with:
key: component-image-cache-${{ github.sha }}
restore-keys: component-image-cache-
path: |
/home/runner/work/kubeagi/kubeagi/tmp/images/
/home/runner/work/kubeagi/kubeagi/tmp/all.image.list
- name: Load kubeagi image to docker
run: |
docker load --input /tmp/operator.image.tar
- name: Copy the existing kustomize
# avoid kustomize installation to bypass the rate limit of GitHub.
run: |
mkdir -p ${GITHUB_WORKSPACE}/bin
cp /usr/local/bin/kustomize ${GITHUB_WORKSPACE}/bin/kustomize
- name: Install mc
run: |
command -v mc >/dev/null 2>&1 || (curl https://dl.min.io/client/mc/release/linux-amd64/mc \
--create-dirs -o /usr/local/bin/mc && chmod +x /usr/local/bin/mc )
- name: Example test
run: tests/example-test.sh
- name: Upload logs if test fail
if: failure()
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.no }}.logs
path: ${{ env.LOG_DIR }}
- uses: dorny/paths-filter@v2
if: matrix.no == 1
id: gql-changes
with:
filters: |
gql:
- 'apiserver/graph/schema/*.gql'
- name: setting token to npmrc
if: (( github.event_name == 'push' && steps.gql-changes.outputs.gql == 'true') || github.event_name == 'workflow_dispatch') && matrix.no == 1
run: |
echo '//dev-npm.k8s.com.cn/:_authToken="${{ secrets.TENX_NPM_TOKEN }}"' >> ~/.npmrc
echo '//registry.npmjs.org/:_authToken="${{ secrets.NPM_TOKEN }}"' >> ~/.npmrc
- name: Set variable on Merge pull request
if: github.event_name == 'push' && matrix.no == 1
run: |
echo "GRL_SDK_TEST_ONLY=false" >> $GITHUB_ENV
- name: Set variable on workflow_dispatch
if: github.event_name == 'workflow_dispatch'
run: |
echo "GRL_SDK_TEST_ONLY=$TEST_ONLY" >> $GITHUB_ENV
env:
TEST_ONLY: ${{ inputs.OnlyTestGeneratedSdk }}
- name: make sdk
if: (steps.gql-changes.outputs.gql == 'true' || github.event_name == 'workflow_dispatch') && matrix.no == 1
run: |
kubectl port-forward svc/arcadia-apiserver -n arcadia 8888:8081 --address 0.0.0.0 >/dev/null 2>&1 &
export GRAPH_API_ENDPOINT="http://0.0.0.0:8888/bff"
make bff-sdk-generator
env:
GRL_SDK_TEST_ONLY: ${{ env.GRL_SDK_TEST_ONLY }}