added test and makes new relevant tests run tests

This commit is contained in:
Noah Campbell
2025-10-11 11:17:26 -07:00
parent 3f069125a2
commit a2a424b201
6 changed files with 338 additions and 29 deletions
+51
View File
@@ -35,6 +35,18 @@ jobs:
- name: Go Mod Download
run: go mod download
# 1) Build and compile tests only (no execution)
- name: Build (compile-only)
run: go build ./...
- name: Compile tests (no execution)
shell: bash
run: |
set -euo pipefail
while read -r pkg; do
go test -c -o /dev/null "$pkg" || exit 1
done < <(go list ./...)
- name: Get PR Base SHA
id: pr-info
env:
@@ -49,6 +61,7 @@ jobs:
echo "BASE_SHA=${BASE_SHA}" >> "$GITHUB_OUTPUT"
echo "Base SHA: ${BASE_SHA}"
# 2) Detect relevant unit packages and e2e tests
- name: Compute affected packages
id: affected
env:
@@ -71,6 +84,22 @@ jobs:
echo "has_changes=false" >> "$GITHUB_OUTPUT"
fi
- name: Compute affected e2e tests
id: affected_e2e
env:
BASE_SHA: ${{ steps.pr-info.outputs.BASE_SHA }}
run: |
set -euo pipefail
go run ./scripts/affected-packages.go -mode=suites -base "${BASE_SHA}" > /tmp/affected-e2e.txt
awk -F: '$1=="preflight"{print $2}' /tmp/affected-e2e.txt > /tmp/preflight-tests.txt
awk -F: '$1=="support-bundle"{print $2}' /tmp/affected-e2e.txt > /tmp/support-tests.txt
if [ -s /tmp/preflight-tests.txt ] || [ -s /tmp/support-tests.txt ]; then
echo "has_changes=true" >> "$GITHUB_OUTPUT"
else
echo "has_changes=false" >> "$GITHUB_OUTPUT"
fi
# 3) Run filtered tests only
- name: Run unit tests for affected packages
if: steps.affected.outputs.has_changes == 'true'
run: |
@@ -85,6 +114,28 @@ jobs:
xargs -a /tmp/affected.txt go test -race -count=1 -v
fi
- name: Run preflight e2e (filtered)
if: steps.affected_e2e.outputs.has_changes == 'true'
run: |
set -euo pipefail
if [ -s /tmp/preflight-tests.txt ]; then
regex="$(tr '\n' '|' < /tmp/preflight-tests.txt | sed 's/|$//')"
go test -v -count=1 ./test/e2e/preflight -run "^((${regex}))$"
else
echo "No preflight e2e changes"
fi
- name: Run support-bundle e2e (filtered)
if: steps.affected_e2e.outputs.has_changes == 'true'
run: |
set -euo pipefail
if [ -s /tmp/support-tests.txt ]; then
regex="$(tr '\n' '|' < /tmp/support-tests.txt | sed 's/|$//')"
go test -v -count=1 ./test/e2e/support-bundle -run "^((${regex}))$"
else
echo "No support-bundle e2e changes"
fi
- name: No affected packages — skip tests
if: steps.affected.outputs.has_changes != 'true'
run: echo "No Go packages affected by this PR; skipping tests."
+8 -4
View File
@@ -37,7 +37,8 @@ jobs:
- run: make tidy-diff
test-integration:
runs-on: ubuntu-latest
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
@@ -65,7 +66,8 @@ jobs:
path: bin/preflight
validate-preflight-e2e:
runs-on: ubuntu-latest
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs: compile-preflight
steps:
- uses: actions/checkout@v5
@@ -95,7 +97,8 @@ jobs:
path: bin/support-bundle
validate-supportbundle-e2e:
runs-on: ubuntu-latest
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs: compile-supportbundle
steps:
- uses: actions/checkout@v5
@@ -113,7 +116,8 @@ jobs:
# Additional e2e tests for support bundle that run in Go, these create a Kind cluster
validate-supportbundle-e2e-go:
runs-on: ubuntu-latest
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs: compile-supportbundle
steps:
- uses: actions/checkout@v5
+2 -2
View File
@@ -66,7 +66,7 @@ jobs:
# Unit and integration tests
test:
if: needs.changes.outputs.go-files == 'true'
if: github.event_name == 'push' && needs.changes.outputs.go-files == 'true'
needs: [changes, lint]
runs-on: ubuntu-latest
timeout-minutes: 20
@@ -100,7 +100,7 @@ jobs:
# E2E tests
e2e:
if: needs.changes.outputs.go-files == 'true' || github.event_name == 'push'
if: github.event_name == 'push'
needs: [changes, build]
runs-on: ubuntu-latest
timeout-minutes: 15
+1 -2
View File
@@ -3,8 +3,6 @@ name: Regression Test Suite
on:
push:
branches: [main, v1beta3]
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
inputs:
update_baselines:
@@ -14,6 +12,7 @@ on:
jobs:
regression-test:
if: github.event_name != 'pull_request'
runs-on: ubuntu-22.04
timeout-minutes: 25