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

hotfix: Pipeline does not test all code, just that one that it is expected to be released #2153

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions .github/workflows/release-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-service-apps-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release-service-stream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-service-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
type: boolean
default: false
required: false
test-regex:
type: string
default: ""
required: false

env:
TEST_PARALLELISM: 12
Expand Down Expand Up @@ -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" \
Expand All @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions scripts/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 ..."
Expand Down