Skip to content

Commit 4fe19b4

Browse files
committed
ci(emailsender): optimize compatibility test
1 parent 4e29d2f commit 4fe19b4

2 files changed

Lines changed: 8 additions & 21 deletions

File tree

.github/workflows/emailsender-central-compatibility.yaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
2-
name: emailsender-central-compatibility
1+
name: Emailsender-Central Compatibility Tests
32

43
on:
54
push:
65
branches:
76
- main
87
paths:
98
- 'emailsender/**'
9+
- 'deploy/charts/emailsender/**'
1010
- 'scripts/**'
1111
- '.github/workflows/emailsender-central-compatibility.yaml'
1212

1313
pull_request:
1414
types: [opened, synchronize, reopened, ready_for_review]
1515
paths:
1616
- 'emailsender/**'
17+
- 'deploy/charts/emailsender/**'
1718
- 'scripts/**'
1819
- '.github/workflows/emailsender-central-compatibility.yaml'
1920

@@ -54,13 +55,6 @@ jobs:
5455
with:
5556
path: acs-fleet-manager
5657
fetch-depth: 0
57-
- name: Checkout stackrox/stackrox repository
58-
uses: actions/checkout@v4
59-
with:
60-
repository: stackrox/stackrox
61-
path: stackrox
62-
fetch-tags: true
63-
fetch-depth: 0
6458
- name: Create Kind cluster"
6559
uses: helm/kind-action@v1
6660
with:

scripts/ci/central_compatibility/run_compatibility_test.sh

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ set -eu
77
# 2. acs-fleet-manager repo to be available at the execution path with directory name acs-fleet-manager
88
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../../.. && pwd)"
99
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10-
STACKROX_DIR="$(cd "$ROOT_DIR/../stackrox" && pwd)"
1110

1211
EMAILSENDER_NS="rhacs"
1312
CENTRAL_NS="rhacs-tenant"
@@ -48,13 +47,13 @@ log "Emailsender deployed to Kind."
4847
log "Starting to deploy central services..."
4948
# use nightly if GH action running for acs-fleet-manager
5049
# use the stackrox tag otherwise
50+
GITHUB_REPOSITORY=${GITHUB_REPOSITORY:-stackrox/acs-fleet-manager}
5151
log "Running for repository: $GITHUB_REPOSITORY"
5252
if [ "$GITHUB_REPOSITORY" = "stackrox/stackrox" ]; then
53+
STACKROX_DIR="$(cd "$ROOT_DIR/../stackrox" && pwd)"
5354
ACS_VERSION="$(make --no-print-directory -C "$STACKROX_DIR" tag)"
5455
else
55-
git -C "$STACKROX_DIR" fetch --tags
56-
ACS_VERSION="$(git -C "$STACKROX_DIR" tag | grep -E '.*-nightly-[0-9]{8}$' | tail -n 1)"
57-
git -C "$STACKROX_DIR" checkout "$ACS_VERSION"
56+
ACS_VERSION="$(git ls-remote --tags https://github.com/stackrox/stackrox | grep -E '.*-nightly-[0-9]{8}$' | tail -n 1 | awk '{print $2}' | sed 's|refs/tags/||')"
5857
fi
5958

6059
log "ACS version: $ACS_VERSION"
@@ -74,13 +73,9 @@ for img in "${IMAGES_TO_PULL[@]}"; do
7473
pull_to_kind "$img"
7574
done
7675

77-
TAG="$ACS_VERSION" make --no-print-directory -C "$STACKROX_DIR" cli_host-arch
78-
GOARCH="$(go env GOARCH)"
79-
GOOS="$(go env GOOS)"
80-
81-
ROXCTL="$STACKROX_DIR/bin/${GOOS}_${GOARCH}/roxctl"
76+
ROXCTL="docker run --rm --user $(id -u):$(id -g) -v $(pwd):/tmp/stackrox-charts/ $MAIN_IMG_NAME:$ACS_VERSION"
8277
# --remove to make this script rerunnable on a local machine
83-
$ROXCTL helm output central-services --remove --output-dir ./central-chart
78+
$ROXCTL helm output central-services --image-defaults opensource --remove --output-dir /tmp/stackrox-charts/central-chart
8479

8580
# Using ACS_VERSION explicitly here since it would otherwise not use the nightly build tag
8681
helm upgrade --install -n $CENTRAL_NS stackrox-central-services ./central-chart \
@@ -91,12 +86,10 @@ helm upgrade --install -n $CENTRAL_NS stackrox-central-services ./central-chart
9186
--set "scannerV4.disable=true" \
9287
--set "scanner.disable=true" # Disabling scanner to reduce resource usage, it is not important for this test
9388

94-
KUBECTL="$(which kubectl)"
9589
wait_for_container_to_become_ready "$CENTRAL_NS" "app=central" "central"
9690
wait_for_container_to_become_ready "$EMAILSENDER_NS" "app=emailsender" "emailsender"
9791

9892
kubectl port-forward -n "$CENTRAL_NS" svc/central 8443:443 >/dev/null &
9993
echo $! >> /tmp/pids-port-forward
10094

101-
cd "$ROOT_DIR"
10295
go test -tags=test_central_compatibility ./emailsender/compatibility

0 commit comments

Comments
 (0)