chore(deps): update dependency kubectl to v1.34.2 (#103) #293
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI Build & Test | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - docs/** | |
| - "**.md" | |
| - .github/workflows/docs-website.yaml | |
| - .github/workflows/validations.yaml | |
| - .github/workflows/release.yaml | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| branches: | |
| - main | |
| paths-ignore: | |
| - docs/** | |
| - "**.md" | |
| - .github/workflows/docs-website.yaml | |
| - .github/workflows/validations.yaml | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| validate: | |
| name: Quality Validations | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout code | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| # Set up Go environment | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: "go.mod" | |
| cache: true | |
| cache-dependency-path: "**/*.sum" | |
| # Cache Go build cache - reusing same cache key across all jobs | |
| - name: Cache Go build cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/*.go') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}- | |
| ${{ runner.os }}-go-build- | |
| - name: GolangCI Lint | |
| uses: golangci/golangci-lint-action@v9 | |
| with: | |
| version: latest | |
| - name: Run format-check | |
| run: | | |
| UNFORMATTED=$(gofmt -l .) | |
| if [ -n "$UNFORMATTED" ]; then | |
| echo "The following files are not formatted according to gofmt:" | |
| echo "$UNFORMATTED" | |
| exit 1 | |
| fi | |
| test: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout code | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 # Needed for changed files detection | |
| # Set up Go environment | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: "go.mod" | |
| cache: true | |
| cache-dependency-path: "**/*.sum" | |
| # Cache Go build cache for test results and compiled binaries | |
| - name: Cache Go build cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/*.go') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}- | |
| ${{ runner.os }}-go-build- | |
| # Detect changed packages for smarter test execution | |
| - name: Detect changed packages | |
| id: changed-packages | |
| run: | | |
| # For PRs, compare against the base branch | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | |
| HEAD_SHA="${{ github.sha }}" | |
| else | |
| # For pushes to main, compare against previous commit | |
| BASE_SHA="${{ github.event.before }}" | |
| HEAD_SHA="${{ github.sha }}" | |
| fi | |
| # Get list of changed Go files | |
| CHANGED_FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" | grep '\.go$' || true) | |
| if [ -z "$CHANGED_FILES" ]; then | |
| echo "No Go files changed, but running all tests for safety" | |
| echo "run_all=true" >> "$GITHUB_OUTPUT" | |
| echo "packages=./..." >> "$GITHUB_OUTPUT" | |
| else | |
| # Extract unique package directories from changed files | |
| PACKAGES=$(echo "$CHANGED_FILES" | xargs -I {} dirname {} | sort -u | sed 's|^|./|' | sed 's|$|/...|' | tr '\n' ' ') | |
| echo "Changed packages: $PACKAGES" | |
| echo "run_all=false" >> "$GITHUB_OUTPUT" | |
| echo "packages=$PACKAGES" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Run tests with caching | |
| env: | |
| PACKAGES: ${{ steps.changed-packages.outputs.packages }} | |
| run: | | |
| # Run tests with Go's built-in caching enabled (don't use -count=1) | |
| # The -vet=off flag skips vet since it's already run by golangci-lint | |
| go test -vet=off -race -cover -covermode=atomic -coverprofile=coverage.txt $PACKAGES | |
| # Display cache stats | |
| echo "=== Go Build Cache Stats ===" | |
| go clean -cache -n || true | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: false | |
| prepare: | |
| name: Prepare Build Config | |
| runs-on: ubuntu-latest | |
| outputs: | |
| is_pr: ${{ steps.config.outputs.is_pr }} | |
| should_push_docker: ${{ steps.config.outputs.should_push_docker }} | |
| steps: | |
| - id: config | |
| run: | | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| # PR builds: no Docker push | |
| echo "is_pr=true" >> "$GITHUB_OUTPUT" | |
| echo "should_push_docker=false" >> "$GITHUB_OUTPUT" | |
| else | |
| # Main branch: push Docker with 'main' tag | |
| echo "is_pr=false" >> "$GITHUB_OUTPUT" | |
| echo "should_push_docker=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| build: | |
| name: Build with GoReleaser | |
| runs-on: ubuntu-latest | |
| needs: | |
| - test | |
| - validate | |
| - prepare | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: "go.mod" | |
| cache: true | |
| cache-dependency-path: "**/*.sum" | |
| # Cache Go build cache - reusing same cache key across all jobs | |
| - name: Cache Go build cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/*.go') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}- | |
| ${{ runner.os }}-go-build- | |
| - name: Set up Docker Buildx | |
| if: needs.prepare.outputs.should_push_docker == 'true' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log into registry ${{ env.REGISTRY }} | |
| if: needs.prepare.outputs.should_push_docker == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Modify GoReleaser config for CI builds | |
| run: | | |
| # Install yq | |
| sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 | |
| sudo chmod +x /usr/local/bin/yq | |
| if [[ "${{ needs.prepare.outputs.is_pr }}" == "true" ]]; then | |
| # PR builds: Skip Docker entirely | |
| yq eval -i 'del(.dockers_v2) | del(.docker_signs)' .goreleaser.yaml | |
| else | |
| # Main branch builds: Change image tags to 'main' | |
| yq eval -i ' | |
| .dockers_v2[0].tags = ["main"] | | |
| del(.docker_signs) | |
| ' .goreleaser.yaml | |
| fi | |
| - name: Run GoReleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| args: release --snapshot --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |