diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5df0e1430..66ddce2727 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,8 @@ jobs: name: "Unit Tests" secrets: inherit uses: ./.github/workflows/test-unit.yml + with: + test-regex: ./internal/pkg/service/stream test-e2e-cli: name: "E2E: CLI" diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index c1fc126223..99772b015e 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 test-e2e-cli: name: "E2E: CLI" diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index 76f5ef021a..1c915f3aa0 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,9 @@ jobs: if [ "$RUNNER_OS" == "macOS" ]; then export GOFLAGS="-ldflags=-extldflags=-Wl,-ld_classic" fi - + + echo $TEST_EXCEPT + # ENVs can affect test caching, make sure to only run tests with expected ENVs env -i \ TERM="$TERM" \ @@ -111,10 +117,13 @@ 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 }} TEST_KBC_PROJECTS_LOCK_PASSWORD: ${{ secrets.TEST_KBC_PROJECTS_LOCK_PASSWORD }} TEST_KBC_PROJECTS_FILE: '${{ github.workspace }}/${{ vars.TEST_KBC_PROJECTS_FILE }}' UNIT_ETCD_ENABLED: ${{ matrix.name == 'linux' && 'true' || 'false' }} + # Prevent testing unnecessary code for particular release + TEST_EXCEPT: "go list ./internal/pkg/... | grep -v '${{ inputs.test-regex }}'" diff --git a/scripts/tests.sh b/scripts/tests.sh index 90651546c4..6e1d4c55d7 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,9 +29,13 @@ 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 ..." +echo $TEST_EXCEPT export KBC_VERSION_CHECK=false # do not check the latest version in the tests cmd="gotestsum --no-color=false --format \"$TEST_LOG_FORMAT\" -- -timeout 1200s -p $TEST_PARALLELISM_PKG -parallel $TEST_PARALLELISM $TEST_ARGS "$TEST_PACKAGE" $@" echo $cmd