mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-08-27 00:37:20 +00:00
Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a2b0e0f30 | ||
|
|
1013f2a160 | ||
|
|
e73e1375cc | ||
|
|
9278d50252 | ||
|
|
e084c0a46a | ||
|
|
f7a941c220 | ||
|
|
8920a9d09a | ||
|
|
a677646b17 | ||
|
|
c84ea20b88 | ||
|
|
409a02a125 | ||
|
|
78af9208cf | ||
|
|
fb0983480c | ||
|
|
1aa74db81d | ||
|
|
8f7cf26cc9 | ||
|
|
a6d3e3e423 | ||
|
|
6ea8cbcb09 | ||
|
|
bf1dfa0318 |
@@ -12,6 +12,9 @@ jobs:
|
||||
if: github.event.pull_request.draft == false
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
outputs:
|
||||
unit_has_changes: ${{ steps.affected.outputs.has_changes }}
|
||||
e2e_has_changes: ${{ steps.affected_e2e.outputs.has_changes }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -27,6 +30,7 @@ jobs:
|
||||
- name: Go Mod Download
|
||||
run: go mod download
|
||||
|
||||
|
||||
- name: Compute base ref
|
||||
id: pr-info
|
||||
run: |
|
||||
@@ -86,60 +90,103 @@ jobs:
|
||||
fi;
|
||||
} | tee -a "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
# Provision a Kubernetes cluster for e2e that depend on it (safe no-op for kind-based Go e2e)
|
||||
- name: Setup K3s
|
||||
if: steps.affected_e2e.outputs.has_changes == 'true'
|
||||
uses: replicatedhq/action-k3s@main
|
||||
- name: Upload affected unit packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
version: v1.31.2-k3s1
|
||||
name: affected-unit
|
||||
path: /tmp/affected.txt
|
||||
if-no-files-found: warn
|
||||
|
||||
# 3) Run filtered tests only
|
||||
- name: Run unit tests for affected packages
|
||||
if: steps.affected.outputs.has_changes == 'true'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# If the script output contains './...' then run all tests
|
||||
if grep -qx "./..." /tmp/affected.txt; then
|
||||
echo "Module files changed; running all tests"
|
||||
make test
|
||||
else
|
||||
echo "Running tests for affected packages"
|
||||
pkgs=$(tr '\n' ' ' < /tmp/affected.txt)
|
||||
PACKAGES="$pkgs" make test-packages
|
||||
fi
|
||||
- name: Upload affected e2e artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: affected-e2e
|
||||
path: |
|
||||
/tmp/affected-e2e.txt
|
||||
/tmp/preflight-tests.txt
|
||||
/tmp/support-tests.txt
|
||||
if-no-files-found: warn
|
||||
|
||||
- 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="$(grep -v '^$' /tmp/preflight-tests.txt | tr '\n' '|' | sed 's/|$//')"
|
||||
if [ -n "$regex" ]; then
|
||||
RUN="^(${regex})$" make preflight-e2e-go-only-test
|
||||
else
|
||||
echo "No valid preflight tests matched after filtering"
|
||||
fi
|
||||
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="$(grep -v '^$' /tmp/support-tests.txt | tr '\n' '|' | sed 's/|$//')"
|
||||
if [ -n "$regex" ]; then
|
||||
RUN="^(${regex})$" make support-bundle-e2e-go-only-test
|
||||
else
|
||||
echo "No valid support-bundle tests matched after filtering"
|
||||
fi
|
||||
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."
|
||||
|
||||
e2e-affected:
|
||||
needs: test-affected
|
||||
if: github.event.pull_request.draft == false
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
suite: [unit, preflight, support-bundle]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
|
||||
- name: Go Mod Download
|
||||
run: go mod download
|
||||
|
||||
- name: Download affected unit packages
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: affected-unit
|
||||
path: /tmp
|
||||
|
||||
- name: Download affected e2e artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: affected-e2e
|
||||
path: /tmp
|
||||
|
||||
- name: Run unit tests (filtered)
|
||||
if: matrix.suite == 'unit' && needs.test-affected.outputs.unit_has_changes == 'true'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if grep -qx "./..." /tmp/affected.txt; then
|
||||
echo "Module files changed; running all unit tests"
|
||||
make test
|
||||
else
|
||||
echo "Running unit tests for affected packages"
|
||||
pkgs=$(tr '\n' ' ' < /tmp/affected.txt)
|
||||
PACKAGES="$pkgs" make test-packages
|
||||
fi
|
||||
|
||||
|
||||
- name: Run e2e (filtered) - ${{ matrix.suite }}
|
||||
if: matrix.suite != 'unit' && needs.test-affected.outputs.e2e_has_changes == 'true'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker rm -f kind-cluster-control-plane 2>/dev/null || true
|
||||
if [ "${{ matrix.suite }}" = "preflight" ]; then
|
||||
file=/tmp/preflight-tests.txt
|
||||
path=./test/e2e/preflight
|
||||
else
|
||||
file=/tmp/support-tests.txt
|
||||
path=./test/e2e/support-bundle
|
||||
fi
|
||||
if [ -s "$file" ]; then
|
||||
regex="$(grep -v '^$' "$file" | tr '\n' '|' | sed 's/|$//')"
|
||||
if [ -n "$regex" ]; then
|
||||
if [ "${{ matrix.suite }}" = "preflight" ]; then
|
||||
E2EPATHS="$path" RUN="^(${regex})$" make preflight-e2e-go-test
|
||||
else
|
||||
E2EPATHS="$path" RUN="^(${regex})$" make support-bundle-e2e-go-test
|
||||
fi
|
||||
else
|
||||
echo "No valid ${{ matrix.suite }} tests matched after filtering"
|
||||
fi
|
||||
else
|
||||
echo "No ${{ matrix.suite }} e2e changes"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ name: Regression Test Suite
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
update_baselines:
|
||||
@@ -12,7 +14,6 @@ on:
|
||||
|
||||
jobs:
|
||||
regression-test:
|
||||
if: github.event_name != 'pull_request'
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 25
|
||||
|
||||
@@ -288,4 +289,4 @@ jobs:
|
||||
continue-on-error: true
|
||||
with:
|
||||
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
|
||||
cluster-id: ${{ steps.create-cluster.outputs.cluster-id }}
|
||||
cluster-id: ${{ steps.create-cluster.outputs.cluster-id }}
|
||||
@@ -37,7 +37,7 @@ endef
|
||||
BUILDTAGS = "netgo containers_image_ostree_stub exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp"
|
||||
BUILDFLAGS = -tags ${BUILDTAGS} -installsuffix netgo
|
||||
BUILDPATHS = ./pkg/... ./cmd/... ./internal/...
|
||||
E2EPATHS = ./test/e2e/...
|
||||
E2EPATHS ?= ./test/e2e/...
|
||||
TESTFLAGS ?= -v -coverprofile cover.out
|
||||
|
||||
.DEFAULT_GOAL := all
|
||||
@@ -49,8 +49,8 @@ ffi: fmt vet
|
||||
|
||||
.PHONY: test
|
||||
test: generate fmt vet
|
||||
if [ -n $(RUN) ]; then \
|
||||
go test ${BUILDFLAGS} ${BUILDPATHS} ${TESTFLAGS} -run $(RUN); \
|
||||
if [ -n "$(RUN)" ]; then \
|
||||
go test ${BUILDFLAGS} ${BUILDPATHS} ${TESTFLAGS} -run "$(RUN)"; \
|
||||
else \
|
||||
go test ${BUILDFLAGS} ${BUILDPATHS} ${TESTFLAGS}; \
|
||||
fi
|
||||
@@ -84,10 +84,18 @@ run-examples:
|
||||
support-bundle-e2e-test:
|
||||
./test/validate-support-bundle-e2e.sh
|
||||
|
||||
.PHONY: preflight-e2e-go-test
|
||||
preflight-e2e-go-test: bin/preflight
|
||||
if [ -n "$(RUN)" ]; then \
|
||||
go test ${BUILDFLAGS} ${E2EPATHS} -v -run "$(RUN)"; \
|
||||
else \
|
||||
go test ${BUILDFLAGS} ${E2EPATHS} -v; \
|
||||
fi
|
||||
|
||||
.PHONY: support-bundle-e2e-go-test
|
||||
support-bundle-e2e-go-test:
|
||||
if [ -n $(RUN) ]; then \
|
||||
go test ${BUILDFLAGS} ${E2EPATHS} -v -run $(RUN); \
|
||||
support-bundle-e2e-go-test: bin/support-bundle
|
||||
if [ -n "$(RUN)" ]; then \
|
||||
go test ${BUILDFLAGS} ${E2EPATHS} -v -run "$(RUN)"; \
|
||||
else \
|
||||
go test ${BUILDFLAGS} ${E2EPATHS} -v; \
|
||||
fi
|
||||
|
||||
@@ -53,11 +53,15 @@ SB="$( echo "${E2E_OUT}" | awk -F: '$1=="support-bundle"{print $2}' | paste -sd'
|
||||
# Use direct go test with the same build tags as the Makefile to avoid RUN quoting issues locally
|
||||
BUILD_TAGS='netgo containers_image_ostree_stub exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp'
|
||||
|
||||
overall=0
|
||||
|
||||
if [ -n "${PRE}" ]; then
|
||||
echo "Running preflight e2e: ${PRE}"
|
||||
go test -tags "${BUILD_TAGS}" -installsuffix netgo -v -count=1 ./test/e2e/preflight -run "^(("${PRE}")$)" || true
|
||||
go test -tags "${BUILD_TAGS}" -installsuffix netgo -v -count=1 ./test/e2e/preflight -run "^(${PRE})$" || overall=1
|
||||
fi
|
||||
if [ -n "${SB}" ]; then
|
||||
echo "Running support-bundle e2e: ${SB}"
|
||||
go test -tags "${BUILD_TAGS}" -installsuffix netgo -v -count=1 ./test/e2e/support-bundle -run "^(("${SB}")$)" || true
|
||||
fi
|
||||
go test -tags "${BUILD_TAGS}" -installsuffix netgo -v -count=1 ./test/e2e/support-bundle -run "^(${SB})$" || overall=1
|
||||
fi
|
||||
|
||||
exit $overall
|
||||
Reference in New Issue
Block a user