-
Notifications
You must be signed in to change notification settings - Fork 105
update ci for v1beta3 #1870
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
update ci for v1beta3 #1870
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: 'Setup Go Environment' | ||
description: 'Setup Go with caching and common environment variables' | ||
inputs: | ||
go-version-file: | ||
description: 'Path to go.mod file' | ||
required: false | ||
default: 'go.mod' | ||
outputs: | ||
go-version: | ||
description: 'The Go version that was installed' | ||
value: ${{ steps.setup-go.outputs.go-version }} | ||
cache-hit: | ||
description: 'Whether the Go cache was hit' | ||
value: ${{ steps.setup-go.outputs.cache-hit }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Setup Go | ||
id: setup-go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: ${{ inputs.go-version-file }} | ||
cache: true | ||
|
||
- name: Set Go environment variables | ||
shell: bash | ||
run: | | ||
echo "GOMAXPROCS=2" >> $GITHUB_ENV | ||
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV | ||
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV | ||
- name: Print Go environment | ||
shell: bash | ||
run: | | ||
echo "Go version: $(go version)" | ||
echo "GOOS: $(go env GOOS)" | ||
echo "GOARCH: $(go env GOARCH)" | ||
echo "Cache directory: $(go env GOCACHE)" | ||
echo "Module cache: $(go env GOMODCACHE)" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,145 +2,161 @@ name: build-test | |
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- ready_for_review | ||
branches: | ||
- v1beta3 | ||
types: [opened, reopened, synchronize, ready_for_review] | ||
branches: [v1beta3] | ||
push: | ||
branches: | ||
- "v1beta3" | ||
branches: [v1beta3] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
fail_if_pull_request_is_draft: | ||
if: github.event.pull_request.draft == true | ||
# Detect changes to optimize test execution | ||
changes: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
go-files: ${{ steps.filter.outputs.go-files }} | ||
preflight: ${{ steps.filter.outputs.preflight }} | ||
support-bundle: ${{ steps.filter.outputs.support-bundle }} | ||
examples: ${{ steps.filter.outputs.examples }} | ||
steps: | ||
- name: Fails in order to indicate that pull request needs to be marked as ready to review and unit tests workflow needs to pass. | ||
run: exit 1 | ||
- uses: actions/checkout@v5 | ||
- uses: dorny/paths-filter@v3 | ||
id: filter | ||
with: | ||
filters: | | ||
go-files: | ||
- '**/*.go' | ||
- 'go.{mod,sum}' | ||
- 'Makefile' | ||
preflight: | ||
- 'cmd/preflight/**' | ||
- 'pkg/preflight/**' | ||
support-bundle: | ||
- 'cmd/troubleshoot/**' | ||
- 'pkg/supportbundle/**' | ||
examples: | ||
- 'examples/**' | ||
- 'test/run-examples.sh' | ||
|
||
test-integration: | ||
# Validation jobs | ||
validate: | ||
if: needs.changes.outputs.go-files == 'true' | ||
needs: changes | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v5 | ||
- uses: actions/setup-go@v6 | ||
with: | ||
go-version-file: 'go.mod' | ||
- uses: replicatedhq/action-k3s@main | ||
id: k3s | ||
with: | ||
version: v1.31.2-k3s1 | ||
# test-integration includes unit tests | ||
- run: make test-integration | ||
- uses: ./.github/actions/setup-go | ||
|
||
- name: Check go mod tidy | ||
run: | | ||
go mod tidy | ||
git diff --exit-code go.mod go.sum || { | ||
echo "::error::Please run 'go mod tidy' and commit changes" | ||
exit 1 | ||
} | ||
|
||
compile-preflight: | ||
- name: Format and vet | ||
run: | | ||
make fmt | ||
git diff --exit-code || { | ||
echo "::error::Please run 'make fmt' and commit changes" | ||
exit 1 | ||
} | ||
make vet | ||
|
||
# Unit and integration tests | ||
test: | ||
if: needs.changes.outputs.go-files == 'true' | ||
needs: [changes, validate] | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
steps: | ||
- uses: actions/checkout@v5 | ||
- uses: actions/setup-go@v6 | ||
with: | ||
go-version-file: 'go.mod' | ||
- run: make preflight | ||
- uses: actions/upload-artifact@v4 | ||
- uses: ./.github/actions/setup-go | ||
|
||
- name: Setup K3s | ||
uses: replicatedhq/action-k3s@main | ||
with: | ||
name: preflight | ||
path: bin/preflight | ||
version: v1.31.2-k3s1 | ||
|
||
- name: Run tests | ||
run: make test-integration | ||
|
||
validate-preflight-e2e: | ||
# Build binaries | ||
build: | ||
if: needs.changes.outputs.go-files == 'true' | ||
needs: [changes, validate] | ||
runs-on: ubuntu-latest | ||
needs: compile-preflight | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v5 | ||
- uses: replicatedhq/action-k3s@main | ||
id: k3s | ||
with: | ||
version: v1.31.2-k3s1 | ||
- name: Download preflight binary | ||
uses: actions/download-artifact@v5 | ||
- uses: ./.github/actions/setup-go | ||
- run: make build | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: preflight | ||
name: binaries | ||
path: bin/ | ||
- run: chmod +x bin/preflight | ||
- run: make preflight-e2e-test | ||
retention-days: 1 | ||
|
||
run-examples: | ||
# Examples validation | ||
examples: | ||
if: needs.changes.outputs.examples == 'true' || needs.changes.outputs.go-files == 'true' | ||
needs: changes | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v5 | ||
- run: make run-examples | ||
|
||
compile-supportbundle: | ||
# E2E tests | ||
e2e: | ||
if: needs.changes.outputs.go-files == 'true' || github.event_name == 'push' | ||
needs: [changes, build] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: E2E Job Runs Without Build JobThe |
||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- name: preflight | ||
target: preflight-e2e-test | ||
needs-k3s: true | ||
- name: support-bundle-shell | ||
target: support-bundle-e2e-test | ||
needs-k3s: true | ||
- name: support-bundle-go | ||
target: support-bundle-e2e-go-test | ||
needs-k3s: false | ||
steps: | ||
- uses: actions/checkout@v5 | ||
- uses: actions/setup-go@v6 | ||
with: | ||
go-version-file: 'go.mod' | ||
- run: make support-bundle | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: support-bundle | ||
path: bin/support-bundle | ||
|
||
validate-supportbundle-e2e: | ||
runs-on: ubuntu-latest | ||
needs: compile-supportbundle | ||
steps: | ||
- uses: actions/checkout@v5 | ||
- uses: replicatedhq/action-k3s@main | ||
id: k3s | ||
- name: Setup K3s | ||
if: matrix.needs-k3s | ||
uses: replicatedhq/action-k3s@main | ||
with: | ||
version: v1.31.2-k3s1 | ||
- name: Download support bundle binary | ||
uses: actions/download-artifact@v5 | ||
with: | ||
name: support-bundle | ||
path: bin/ | ||
- run: chmod +x bin/support-bundle | ||
- run: make support-bundle-e2e-test | ||
|
||
# Additional e2e tests for support bundle that run in Go, these create a Kind cluster | ||
validate-supportbundle-e2e-go: | ||
runs-on: ubuntu-latest | ||
needs: compile-supportbundle | ||
steps: | ||
- uses: actions/checkout@v5 | ||
- name: Download support bundle binary | ||
uses: actions/download-artifact@v5 | ||
with: | ||
name: support-bundle | ||
path: bin/ | ||
- run: chmod +x bin/support-bundle | ||
- name: Download preflight binary | ||
uses: actions/download-artifact@v5 | ||
|
||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: preflight | ||
name: binaries | ||
path: bin/ | ||
- run: chmod +x bin/preflight | ||
- run: make support-bundle-e2e-go-test | ||
|
||
# Summary job - all tests must pass for this to succeed | ||
validate-success: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- tidy-check | ||
- test-integration | ||
- run-examples | ||
- validate-preflight-e2e | ||
- validate-supportbundle-e2e | ||
- validate-supportbundle-e2e-go | ||
- run: chmod +x bin/* | ||
- run: make ${{ matrix.target }} | ||
|
||
# Success summary | ||
success: | ||
if: always() | ||
needs: [validate, test, build, examples, e2e] | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Check if all required jobs succeeded | ||
- name: fail if any required job failed | ||
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') | ||
run: exit 1 | ||
# Success message | ||
- name: All tests passed | ||
run: echo "All build and test jobs completed successfully" | ||
- name: Check results | ||
run: | | ||
if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then | ||
echo "::error::Some jobs failed or were cancelled" | ||
exit 1 | ||
fi | ||
echo "✅ All tests passed!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Go Version Downgrade Causes Compatibility Issues
The composite action uses
actions/setup-go@v5
, which is a downgrade fromv6
used in previous workflows. This could introduce compatibility issues or miss features and bug fixes from the newer version.