From 613838570e39a98e150d6a335429b6f86c9b9de7 Mon Sep 17 00:00:00 2001 From: David Grove Date: Fri, 16 Aug 2024 17:22:54 -0400 Subject: [PATCH 1/2] Add CI configuration for dev-mode controller Fixes #67. --- .github/workflows/CI-devmode.yaml | 54 +++++++++++++++++++++++++++++++ hack/run-dev-mode-tests.sh | 46 ++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 .github/workflows/CI-devmode.yaml create mode 100755 hack/run-dev-mode-tests.sh diff --git a/.github/workflows/CI-devmode.yaml b/.github/workflows/CI-devmode.yaml new file mode 100644 index 0000000..20afce2 --- /dev/null +++ b/.github/workflows/CI-devmode.yaml @@ -0,0 +1,54 @@ +name: CI-devmode +on: + push: + branches: [main, rhoai-2.10] + paths-ignore: + - 'site/**' + pull_request: + branches: [main, rhoai-2.10] + +jobs: + CI: + runs-on: ubuntu-latest + + steps: + - name: checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set latest tag and branch name + run: | + echo "GIT_BRANCH=gha-ci" >> $GITHUB_ENV + echo "TAG=$GITHUB_RUN_ID" >> $GITHUB_ENV + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: './go.mod' + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Run pre-commit checks + run: | + pip install pre-commit + pre-commit run --show-diff-on-failure --color=always --all-files + + - name: Build + run: make build + + - name: Run Unit Tests + run: make test + + - name: Create and configure cluster + run: ./hack/create-test-cluster.sh + + - name: Install CRDs + run: | + make install -e GIT_BRANCH=${{ env.GIT_BRANCH }} TAG=${{ env.GIT_BRANCH }}-${{ env.TAG }} + + - name: Run E2E tests using dev mode controller + run: ./hack/run-dev-mode-tests.sh diff --git a/hack/run-dev-mode-tests.sh b/hack/run-dev-mode-tests.sh new file mode 100755 index 0000000..dcb7c16 --- /dev/null +++ b/hack/run-dev-mode-tests.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Run backgrounded dev mode controller with e2e tests in foreground + +export ROOT_DIR="$(dirname "$(dirname "$(readlink -fn "$0")")")" +export GORACE=1 +export CLEANUP_CLUSTER=${CLEANUP_CLUSTER:-"false"} +export CLUSTER_STARTED="true" + +source ${ROOT_DIR}/hack/e2e-util.sh + +trap cleanup EXIT + +# run background_services_gpid test_command +run () { + PID=$1 + shift + CODE=0 + "$@" || CODE=$? + kill -- -$PID || true + sleep 1 + return $CODE +} + +make run & +run $! go run github.com/onsi/ginkgo/v2/ginkgo -v -fail-fast --procs 1 -timeout 130m --label-filter=Kueue ./test/e2e + +RC=$? +if [ ${RC} -eq 0 ] +then + DUMP_LOGS="false" +fi +echo "End to end test script return code set to ${RC}" +exit ${RC} From 3d7c50b0e67e5a5d46c82b18f0da600bb630dfc2 Mon Sep 17 00:00:00 2001 From: David Grove Date: Fri, 16 Aug 2024 17:39:36 -0400 Subject: [PATCH 2/2] adjust script --- .github/workflows/CI-devmode.yaml | 3 +++ hack/run-dev-mode-tests.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI-devmode.yaml b/.github/workflows/CI-devmode.yaml index 20afce2..66fc90c 100644 --- a/.github/workflows/CI-devmode.yaml +++ b/.github/workflows/CI-devmode.yaml @@ -46,6 +46,9 @@ jobs: - name: Create and configure cluster run: ./hack/create-test-cluster.sh + - name: Deploy Kueue + run: ./hack/deploy-kueue.sh + - name: Install CRDs run: | make install -e GIT_BRANCH=${{ env.GIT_BRANCH }} TAG=${{ env.GIT_BRANCH }}-${{ env.TAG }} diff --git a/hack/run-dev-mode-tests.sh b/hack/run-dev-mode-tests.sh index dcb7c16..a3b0399 100755 --- a/hack/run-dev-mode-tests.sh +++ b/hack/run-dev-mode-tests.sh @@ -34,7 +34,7 @@ run () { return $CODE } -make run & +NAMESPACE=dev go run ./cmd/main.go & run $! go run github.com/onsi/ginkgo/v2/ginkgo -v -fail-fast --procs 1 -timeout 130m --label-filter=Kueue ./test/e2e RC=$?