From 86935bd7853c374ebb711da8bba0551f6fda7df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Va=C5=A1ko?= Date: Thu, 21 Nov 2024 14:27:53 +0100 Subject: [PATCH] hotfix: Pipeline does not test all code, just one that it is expected to be released --- .github/workflows/ci.yml | 4 +++- .github/workflows/release-cli.yml | 1 + .github/workflows/release-service-apps-proxy.yml | 1 + .github/workflows/release-service-stream.yml | 3 +++ .github/workflows/release-service-templates.yml | 1 + .github/workflows/test-unit.yml | 12 +++++++++++- scripts/tests.sh | 4 ++++ 7 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5df0e1430..a8bfb1bac7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,9 @@ jobs: name: "Unit Tests" secrets: inherit uses: ./.github/workflows/test-unit.yml - + with: + without-cache: true + test-regex: "./internal/pkg/service/stream|./internal/pkg/service/templates|./internal/pkg/service/apps" test-e2e-cli: name: "E2E: CLI" secrets: inherit diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index c1fc126223..08788181a8 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -57,6 +57,7 @@ jobs: uses: ./.github/workflows/test-unit.yml with: without-cache: true + test-regex: "./internal/pkg/service/stream|./internal/pkg/service/templates|./internal/pkg/service/appsproxy" test-e2e-cli: name: "E2E: CLI" diff --git a/.github/workflows/release-service-apps-proxy.yml b/.github/workflows/release-service-apps-proxy.yml index 8757001664..da05f9e85e 100644 --- a/.github/workflows/release-service-apps-proxy.yml +++ b/.github/workflows/release-service-apps-proxy.yml @@ -35,6 +35,7 @@ jobs: uses: ./.github/workflows/test-unit.yml with: without-cache: true + test-regex: "./internal/pkg/service/stream|./internal/pkg/service/templates|./internal/pkg/service/cli" test-k8s-service-apps-proxy: name: "K8S: Apps Proxy" secrets: inherit diff --git a/.github/workflows/release-service-stream.yml b/.github/workflows/release-service-stream.yml index 0191e756fb..b19dc0aff9 100644 --- a/.github/workflows/release-service-stream.yml +++ b/.github/workflows/release-service-stream.yml @@ -33,6 +33,9 @@ jobs: name: "Unit Tests" secrets: inherit uses: ./.github/workflows/test-unit.yml + with: + without-cache: true + test-regex: "./internal/pkg/service/appsproxy|./internal/pkg/service/templates|./internal/pkg/service/cli" test-e2e-service-stream: name: "E2E: Stream" secrets: inherit diff --git a/.github/workflows/release-service-templates.yml b/.github/workflows/release-service-templates.yml index 08ac164bad..b45f247402 100644 --- a/.github/workflows/release-service-templates.yml +++ b/.github/workflows/release-service-templates.yml @@ -35,6 +35,7 @@ jobs: uses: ./.github/workflows/test-unit.yml with: without-cache: true + test-regex: "./internal/pkg/service/appsproxy|./internal/pkg/service/stream|./internal/pkg/service/cli" test-e2e-service-templates: name: "E2E: Templates" secrets: inherit diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index 76f5ef021a..d3ef9fc0d3 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -7,6 +7,10 @@ on: type: boolean default: false required: false + test-regex: + type: string + default: "" + required: false env: TEST_PARALLELISM: 12 @@ -90,7 +94,12 @@ jobs: if [ "$RUNNER_OS" == "macOS" ]; then export GOFLAGS="-ldflags=-extldflags=-Wl,-ld_classic" fi - + + # Prevent testing unnecessary code for particular release + if [ -n "${{ inputs.test-regex }}" ]; then + export TEST_EXCEPT="go list ./internal/pkg/... | grep -vE '${{ inputs.test-regex }}'" + fi + # ENVs can affect test caching, make sure to only run tests with expected ENVs env -i \ TERM="$TERM" \ @@ -111,6 +120,7 @@ jobs: TEST_KBC_PROJECTS_LOCK_HOST="$TEST_KBC_PROJECTS_LOCK_HOST" \ TEST_KBC_PROJECTS_LOCK_PASSWORD="$TEST_KBC_PROJECTS_LOCK_PASSWORD" \ TEST_KBC_PROJECTS_FILE="$TEST_KBC_PROJECTS_FILE" \ + TEST_EXCEPT="$TEST_EXCEPT" \ make tests-unit env: TEST_KBC_PROJECTS_LOCK_HOST: ${{ vars.TEST_KBC_PROJECTS_LOCK_HOST }} diff --git a/scripts/tests.sh b/scripts/tests.sh index 90651546c4..e7abca2c58 100755 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -18,6 +18,7 @@ TEST_LOG_FORMAT="${TEST_LOG_FORMAT:=testname}" TEST_DETECT_RACE="${TEST_DETECT_RACE:=true}" TEST_COVERAGE="${TEST_COVERAGE:=true}" TEST_PACKAGE="${TEST_PACKAGE:=./...}" +TEST_EXCEPT="${TEST_EXCEPT:=}" TEST_ARGS="${TEST_ARGS:=}" if [[ $TEST_VERBOSE == "true" ]]; then TEST_ARGS="$TEST_ARGS -v" @@ -28,6 +29,9 @@ fi if [[ $TEST_COVERAGE == "true" ]]; then TEST_ARGS="$TEST_ARGS -coverprofile=/tmp/profile.out" fi +if [[ -n $TEST_EXCEPT ]]; then + TEST_PACKAGE="\$($TEST_EXCEPT)" +fi # Run tests, sequentially because the API is shared resource echo "Running tests ..."