K8SPG-1051 fix e2e-tests #7213
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: reviewdog | |
| on: [pull_request] | |
| jobs: | |
| golangci-lint: | |
| name: runner / suggester / golangci-lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | |
| with: | |
| go-version: '^1.26.0' | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9 | |
| with: | |
| version: latest | |
| only-new-issues: true | |
| args: --timeout 5m | |
| goimports-reviser: | |
| name: runner / suggester / goimports-reviser | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | |
| with: | |
| go-version: '^1.26.0' | |
| - run: go install -v github.com/incu6us/goimports-reviser/v3@latest | |
| - run: $(go env GOPATH)/bin/goimports-reviser -imports-order "std,general,company,project" -company-prefixes "github.com/percona" ./... | |
| - uses: reviewdog/action-suggester@2558ba17e65a9039e73764a73009fc05fef28a46 # v1 | |
| with: | |
| tool_name: goimports-reviser | |
| gofmt: | |
| name: runner / suggester / gofmt | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - run: gofmt -w -s $(find . -not -path "*/vendor/*" -name "*.go") | |
| - uses: reviewdog/action-suggester@2558ba17e65a9039e73764a73009fc05fef28a46 # v1 | |
| with: | |
| tool_name: gofmt | |
| shfmt: | |
| name: runner / suggester / shfmt | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | |
| with: | |
| go-version: '^1.26.0' | |
| - run: go install mvdan.cc/sh/v3/cmd/shfmt@latest | |
| - run: $(go env GOPATH)/bin/shfmt -bn -ci -s -w . | |
| - name: suggester / shfmt | |
| uses: reviewdog/action-suggester@2558ba17e65a9039e73764a73009fc05fef28a46 # v1 | |
| with: | |
| tool_name: shfmt | |
| shellcheck: | |
| if: github.event_name == 'pull_request' | |
| name: runner / shellcheck | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - uses: reviewdog/action-shellcheck@0722bbdb0d47f04c1b53b8734d2422ac63a45ec6 # v1 | |
| with: | |
| github_token: ${{ secrets.github_token }} | |
| reporter: github-pr-check | |
| misspell: | |
| name: runner / misspell | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - uses: reviewdog/action-misspell@d6429416b12b09b4e2768307d53bef58d172e962 # v1 | |
| with: | |
| github_token: ${{ secrets.github_token }} | |
| locale: "US" | |
| reporter: github-pr-check | |
| alex: | |
| name: runner / alex | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - uses: reviewdog/action-alex@347481655add010a2ae302df34b57c9bcfa0d6e4 # v1 | |
| with: | |
| github_token: ${{ secrets.github_token }} | |
| reporter: github-pr-check | |
| level: info | |
| manifests: | |
| name: runner / manifests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: check on release branch | |
| if: ${{ contains(github.base_ref, 'release-') && ! startsWith(github.head_ref, 'after-release-') }} | |
| run: | | |
| make generate VERSION="$(cat percona/version/version.txt)" IMAGE_TAG_BASE="percona/percona-postgresql-operator" | |
| git diff --exit-code | |
| - name: check on non release branches | |
| if: ${{ ! contains(github.base_ref, 'release-') || startsWith(github.head_ref, 'after-release-') }} | |
| run: | | |
| make generate VERSION=main | |
| git diff --exit-code | |
| deploy-cr-release-versions: | |
| name: deploy/cr.yaml vs e2e-tests/release_versions | |
| if: ${{ contains(github.base_ref, 'release-') }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 | |
| - uses: mikefarah/yq@c14f446382944492701b16c1ddb48bb9dbe683e3 # v4.53.6 | |
| - name: Verify deploy/cr.yaml images match release_versions | |
| run: | | |
| set -euo pipefail | |
| # shellcheck disable=SC1091 | |
| source e2e-tests/release_versions | |
| registry="${REGISTRY_NAME:-docker.io}" | |
| pg_ver=$(yq -r '.spec.postgresVersion' deploy/cr.yaml) | |
| if [ -z "$pg_ver" ] || [ "$pg_ver" = "null" ]; then | |
| echo "::error::spec.postgresVersion not found in deploy/cr.yaml" | |
| exit 1 | |
| fi | |
| postgres_var="IMAGE_POSTGRESQL${pg_ver}" | |
| pgbouncer_var="IMAGE_PGBOUNCER${pg_ver}" | |
| backrest_var="IMAGE_BACKREST${pg_ver}" | |
| for var in "$postgres_var" "$pgbouncer_var" "$backrest_var"; do | |
| if [ -z "${!var:-}" ]; then | |
| echo "::error::${var} is not defined in e2e-tests/release_versions" | |
| exit 1 | |
| fi | |
| done | |
| expected_postgres="${registry}/${!postgres_var}" | |
| expected_pgbouncer="${registry}/${!pgbouncer_var}" | |
| expected_backrest="${registry}/${!backrest_var}" | |
| expected_pmm="${registry}/${IMAGE_PMM_CLIENT}" | |
| expected_cr_version="${IMAGE_OPERATOR##*:}" | |
| spec_image=$(yq -r '.spec.image' deploy/cr.yaml) | |
| pgbouncer_image=$(yq -r '.spec.proxy.pgBouncer.image' deploy/cr.yaml) | |
| backrest_image=$(yq -r '.spec.backups.pgbackrest.image' deploy/cr.yaml) | |
| pmm_image=$(yq -r '.spec.pmm.image' deploy/cr.yaml) | |
| cr_version=$(yq -r '.spec.crVersion' deploy/cr.yaml) | |
| failed=0 | |
| check() { | |
| local name="$1" actual="$2" expected="$3" | |
| if [ -z "$actual" ] || [ "$actual" = "null" ]; then | |
| echo "::error::${name}: missing in deploy/cr.yaml" | |
| failed=1 | |
| return | |
| fi | |
| if [ "$actual" != "$expected" ]; then | |
| echo "::error::${name}: deploy/cr.yaml has '${actual}', e2e-tests/release_versions expects '${expected}'" | |
| failed=1 | |
| fi | |
| } | |
| check "spec.image (IMAGE_POSTGRESQL${pg_ver})" "$spec_image" "$expected_postgres" | |
| check "spec.proxy.pgBouncer.image (IMAGE_PGBOUNCER${pg_ver})" "$pgbouncer_image" "$expected_pgbouncer" | |
| check "spec.backups.pgbackrest.image (IMAGE_BACKREST${pg_ver})" "$backrest_image" "$expected_backrest" | |
| check "spec.pmm.image (IMAGE_PMM_CLIENT)" "$pmm_image" "$expected_pmm" | |
| check "spec.crVersion (IMAGE_OPERATOR tag)" "$cr_version" "$expected_cr_version" | |
| if [ "$failed" -ne 0 ]; then | |
| exit 1 | |
| fi | |
| echo "deploy/cr.yaml images match e2e-tests/release_versions." | |
| e2e-release-versions-images: | |
| name: e2e-tests release_versions image availability | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if e2e-tests/release_versions changed | |
| id: changed | |
| run: | | |
| git fetch origin ${{ github.base_ref }} | |
| if git diff --name-only origin/${{ github.base_ref }}...HEAD -- e2e-tests/release_versions | grep -q .; then | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Verify release_versions images exist (docker manifest inspect) | |
| if: steps.changed.outputs.changed == 'true' | |
| run: | | |
| set -e | |
| # All IMAGE_*=value lines, exclude operator image (percona/percona-postgresql-operator) | |
| images=$(grep -E '^IMAGE_[^=]+=' e2e-tests/release_versions | cut -d= -f2 | grep -v '^$' | grep -v 'percona/percona-postgresql-operator' | sort -u) | |
| if [ -z "$images" ]; then | |
| echo "No non-operator images found in e2e-tests/release_versions" | |
| exit 0 | |
| fi | |
| failed="" | |
| for img in $images; do | |
| echo "Checking image $img" | |
| if ! docker manifest inspect "$img"; then | |
| echo "::error::Image not found or inaccessible: $img" | |
| failed="${failed} ${img}" | |
| fi | |
| done | |
| if [ -n "$failed" ]; then | |
| echo "::error::The following images failed docker manifest inspect:$failed" | |
| exit 1 | |
| fi | |
| echo "All images are available." |