Nightly checks (Upgrade) #260
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: Nightly checks (Upgrade) | |
| on: | |
| # workflow_dispatch so that it can be triggered manually if needed | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "55 23 * * *" | |
| jobs: | |
| e2e-upgrade-tests: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| from_branch: | |
| - release-1.5 | |
| - release-1.6 | |
| - release-1.7 | |
| to_branch: | |
| - main | |
| - release-1.7 | |
| - release-1.6 | |
| - release-1.5 | |
| name: 'E2E Upgrade: ${{ matrix.from_branch }} => ${{ matrix.to_branch }}' | |
| concurrency: | |
| group: '${{ github.workflow }}-${{ matrix.from_branch }}-${{ matrix.to_branch }}' | |
| cancel-in-progress: true | |
| env: | |
| CONTAINER_ENGINE: podman | |
| steps: | |
| - name: Determine if upgrade path should be skipped | |
| id: upgrade-path-checker | |
| run: | | |
| SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE="false" | |
| from_branch=${{ matrix.from_branch }} | |
| to_branch=${{ matrix.to_branch }} | |
| if [[ "${from_branch}" == "main" ]]; then | |
| # This is considered a downgrade or a test using the same from/to branches | |
| SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE="true" | |
| else | |
| from_version="${from_branch#release-}" | |
| from_minor=$(echo $from_version | cut -d. -f2) | |
| if [[ "${to_branch}" != "main" ]]; then | |
| to_version="${to_branch#release-}" | |
| to_minor=$(echo $to_version | cut -d. -f2) | |
| if [[ $from_minor -ge $to_minor ]]; then | |
| SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE="true" | |
| fi | |
| fi | |
| fi | |
| echo "SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE=${SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE}" >> $GITHUB_OUTPUT | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 # default branch will be checked out by default on scheduled workflows | |
| if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' }} | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Go | |
| if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' }} | |
| uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Set env vars | |
| if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' }} | |
| run: | | |
| distLocation="dist/rhdh/install.yaml" | |
| from_branch=${{ matrix.from_branch }} | |
| FROM_OPERATOR_MANIFEST="${{ github.workspace }}/${distLocation}" | |
| proto="file://" | |
| if [[ "${from_branch}" != "main" ]]; then | |
| version="${from_branch#release-}" | |
| major=$(echo $version | cut -d. -f1) | |
| minor=$(echo $version | cut -d. -f2) | |
| FROM_OPERATOR_MANIFEST="${{ github.workspace }}/tests/e2e/testdata/rhdh-operator-${version}.yaml" | |
| # TODO(rm3l): remove this once 1.6 is the minimal supported version | |
| if [[ $major -ge 1 && $minor -ge 6 ]]; then | |
| FROM_OPERATOR_MANIFEST="https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/${from_branch}/${distLocation}" | |
| proto="" | |
| fi | |
| fi | |
| echo "FROM_OPERATOR_MANIFEST=${FROM_OPERATOR_MANIFEST}" >> $GITHUB_ENV | |
| FROM_OPERATOR_IMAGE=$(curl -s "${proto}${FROM_OPERATOR_MANIFEST}" | yq 'select(.kind == "Deployment" and .metadata.labels.app == "rhdh-operator") | .spec.template.spec.containers[0].image') | |
| echo "FROM_OPERATOR_IMAGE=${FROM_OPERATOR_IMAGE}" >> $GITHUB_ENV | |
| to_branch=${{ matrix.to_branch }} | |
| TO_OPERATOR_MANIFEST="${{ github.workspace }}/${distLocation}" | |
| proto="file://" | |
| if [[ "${to_branch}" != "main" ]]; then | |
| version="${to_branch#release-}" | |
| major=$(echo $version | cut -d. -f1) | |
| minor=$(echo $version | cut -d. -f2) | |
| TO_OPERATOR_MANIFEST="${{ github.workspace }}/tests/e2e/testdata/rhdh-operator-${version}.yaml" | |
| # TODO(rm3l): remove this once 1.6 is the minimal supported version | |
| if [[ $major -ge 1 && $minor -ge 6 ]]; then | |
| TO_OPERATOR_MANIFEST="https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/${to_branch}/${distLocation}" | |
| proto="" | |
| fi | |
| fi | |
| echo "TO_OPERATOR_MANIFEST=${TO_OPERATOR_MANIFEST}" >> $GITHUB_ENV | |
| TO_OPERATOR_IMAGE=$(curl -s "${proto}${TO_OPERATOR_MANIFEST}" | yq 'select(.kind == "Deployment" and .metadata.labels.app == "rhdh-operator") | .spec.template.spec.containers[0].image') | |
| echo "TO_OPERATOR_IMAGE=${TO_OPERATOR_IMAGE}" >> $GITHUB_ENV | |
| - name: Check if operator images exist in remote registry | |
| id: operator-image-existence-checker | |
| if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' }} | |
| run: | | |
| echo "FROM_OPERATOR_IMAGE_EXISTS=$(skopeo inspect "docker://${{ env.FROM_OPERATOR_IMAGE }}" > /dev/null && echo "true" || echo "false")" >> $GITHUB_OUTPUT | |
| echo "TO_OPERATOR_IMAGE_EXISTS=$(skopeo inspect "docker://${{ env.TO_OPERATOR_IMAGE }}" > /dev/null && echo "true" || echo "false")" >> $GITHUB_OUTPUT | |
| - name: Display warning if any of the operator images were not found | |
| if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' && (steps.operator-image-existence-checker.outputs.FROM_OPERATOR_IMAGE_EXISTS == 'false' || steps.operator-image-existence-checker.outputs.TO_OPERATOR_IMAGE_EXISTS == 'false') }} | |
| run: | | |
| echo "::warning ::One of the operator images (${{ env.FROM_OPERATOR_IMAGE }} or ${{ env.TO_OPERATOR_IMAGE }}) could not be found for testing the ${{ matrix.from_branch }} => ${{ matrix.to_branch }} upgrade path. They might have expired. Skipping." | |
| - name: Generate Kind Config | |
| if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' && steps.operator-image-existence-checker.outputs.FROM_OPERATOR_IMAGE_EXISTS == 'true' && steps.operator-image-existence-checker.outputs.TO_OPERATOR_IMAGE_EXISTS == 'true' }} | |
| run: | | |
| cat <<EOF > /tmp/kind-config.yaml | |
| apiVersion: kind.x-k8s.io/v1alpha4 | |
| kind: Cluster | |
| nodes: | |
| - role: control-plane | |
| extraPortMappings: | |
| - containerPort: 80 | |
| hostPort: 80 | |
| protocol: TCP | |
| - containerPort: 443 | |
| hostPort: 443 | |
| protocol: TCP | |
| EOF | |
| - name: Create Kind cluster | |
| if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' && steps.operator-image-existence-checker.outputs.FROM_OPERATOR_IMAGE_EXISTS == 'true' && steps.operator-image-existence-checker.outputs.TO_OPERATOR_IMAGE_EXISTS == 'true' }} | |
| uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0 | |
| with: | |
| cluster_name: test-cluster | |
| config: /tmp/kind-config.yaml | |
| ignore_failed_clean: true | |
| - name: Install Ingress Controller | |
| if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' && steps.operator-image-existence-checker.outputs.FROM_OPERATOR_IMAGE_EXISTS == 'true' && steps.operator-image-existence-checker.outputs.TO_OPERATOR_IMAGE_EXISTS == 'true' }} | |
| run: | | |
| kubectl apply -f https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx.yaml | |
| kubectl wait --namespace ingress-nginx \ | |
| --for=condition=ready pod \ | |
| --selector=app.kubernetes.io/component=controller \ | |
| --timeout=90s | |
| - name: 'Run E2E tests (RHDH Operator Upgrade path: ${{ matrix.from_branch }} => ${{ matrix.to_branch }})' | |
| if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' && steps.operator-image-existence-checker.outputs.FROM_OPERATOR_IMAGE_EXISTS == 'true' && steps.operator-image-existence-checker.outputs.TO_OPERATOR_IMAGE_EXISTS == 'true' }} | |
| env: | |
| BACKSTAGE_OPERATOR_TESTS_PLATFORM: kind | |
| PROFILE: 'rhdh' | |
| FROM_OPERATOR_MANIFEST: ${{ env.FROM_OPERATOR_MANIFEST }} | |
| TO_OPERATOR_MANIFEST: ${{ env.TO_OPERATOR_MANIFEST }} | |
| OPERATOR_MANIFEST: ${{ env.TO_OPERATOR_MANIFEST }} | |
| IMG: ${{ env.TO_OPERATOR_IMAGE }} | |
| run: make test-e2e-upgrade |