From 8718a2bbd60a0ad4df0a65004b58b810fe363a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Fei?= Date: Mon, 2 Sep 2024 18:28:43 +0200 Subject: [PATCH] chore: run E2E tests from a separate workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Niccolò Fei --- .github/workflows/build-commitfest.yml | 39 ------------- .github/workflows/build.yml | 39 ------------- .github/workflows/continuous-delivery.yml | 6 -- .github/workflows/run-e2e-test.yml | 71 +++++++++++++++++++++++ 4 files changed, 71 insertions(+), 84 deletions(-) create mode 100644 .github/workflows/run-e2e-test.yml diff --git a/.github/workflows/build-commitfest.yml b/.github/workflows/build-commitfest.yml index e3ed863..a58d4b4 100644 --- a/.github/workflows/build-commitfest.yml +++ b/.github/workflows/build-commitfest.yml @@ -12,20 +12,6 @@ on: major_version: description: "PostgreSQL major version (leave empty for default)" required: false - run_e2e: - description: "Run E2Es on the built image" - required: false - type: boolean - default: "false" - cnpg_branch: - description: "Name of the branch/tag used to build & load the operator (leave empty for default)" - required: false - test_depth: - description: 'E2E test level: 0(highest) to 4(lowest) (leave empty for default)' - required: false - feature_type: - description: 'E2E feature type filter. See https://github.com/cloudnative-pg/cloudnative-pg/blob/main/contribute/e2e_testing_environment/README.md#using-feature-type-test-selectionfilter' - required: false # set up environment variables to be used across all the jobs env: @@ -46,10 +32,6 @@ jobs: packages: write outputs: pg_image: "${{ env.REGISTRY }}:${{ env.TAG }}" - pg_major: ${{ env.PG_MAJOR }} - cnpg_branch: ${{ env.CNPG_BRANCH }} - test_depth: ${{ env.TEST_DEPTH }} - feature_type: ${{ env.FEATURE_TYPE }} steps: - name: Checkout Code uses: actions/checkout@v4 @@ -66,15 +48,6 @@ jobs: if [[ -n "${{ github.event.inputs.major_version }}" ]]; then echo "PG_MAJOR=${{ github.event.inputs.major_version }}" >> $GITHUB_ENV fi - if [[ -n "${{ github.event.inputs.cnpg_branch }}" ]]; then - echo "CNPG_BRANCH=${{ github.event.inputs.cnpg_branch }}" >> $GITHUB_ENV - fi - if [[ -n "${{ github.event.inputs.test_depth }}" ]]; then - echo "TEST_DEPTH=${{ github.event.inputs.test_depth }}" >> $GITHUB_ENV - fi - if [[ -n "${{ github.event.inputs.feature_type }}" ]]; then - echo "FEATURE_TYPE=${{ github.event.inputs.feature_type }}" >> $GITHUB_ENV - fi - name: Set commitfest branch and tag if: github.event.inputs.commitfest_id != '' && github.event.inputs.patch_id != '' @@ -135,15 +108,3 @@ jobs: echo "EOF" >> $GITHUB_STEP_SUMMARY echo ") | kubectl apply -f -" >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - - call-run-e2e: - if: github.event.inputs.run_e2e == 'true' - needs: - - build-pg - uses: ./.github/workflows/run-e2e.yml - with: - postgres_img: ${{ needs.build-pg.outputs.pg_image }} - major_version: ${{ needs.build-pg.outputs.pg_major }} - cnpg_branch: ${{ needs.build-pg.outputs.cnpg_branch }} - test_depth: ${{ needs.build-pg.outputs.test_depth }} - feature_type: ${{ needs.build-pg.outputs.feature_type }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1e05660..2676ff1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,20 +17,6 @@ on: extra_tag: description: "Optional extra tag (make sure it starts with the PG major)" required: false - run_e2e: - description: "Run E2Es on the built image" - required: false - type: boolean - default: "false" - cnpg_branch: - description: "Name of the branch/tag used to build & load the operator (leave empty for default)" - required: false - test_depth: - description: 'E2E test level: 0(highest) to 4(lowest) (leave empty for default)' - required: false - feature_type: - description: 'E2E feature type filter. See https://github.com/cloudnative-pg/cloudnative-pg/blob/main/contribute/e2e_testing_environment/README.md#using-feature-type-test-selectionfilter' - required: false # set up environment variables to be used across all the jobs env: @@ -50,10 +36,6 @@ jobs: packages: write outputs: pg_image: ${{ env.TAG }} - pg_major: ${{ env.PG_MAJOR }} - cnpg_branch: ${{ env.CNPG_BRANCH }} - test_depth: ${{ env.TEST_DEPTH }} - feature_type: ${{ env.FEATURE_TYPE }} steps: - name: Checkout Code uses: actions/checkout@v4 @@ -70,15 +52,6 @@ jobs: if [[ -n "${{ github.event.inputs.major_version }}" ]]; then echo "PG_MAJOR=${{ github.event.inputs.major_version }}" >> $GITHUB_ENV fi - if [[ -n "${{ github.event.inputs.cnpg_branch }}" ]]; then - echo "CNPG_BRANCH=${{ github.event.inputs.cnpg_branch }}" >> $GITHUB_ENV - fi - if [[ -n "${{ github.event.inputs.test_depth }}" ]]; then - echo "TEST_DEPTH=${{ github.event.inputs.test_depth }}" >> $GITHUB_ENV - fi - if [[ -n "${{ github.event.inputs.feature_type }}" ]]; then - echo "FEATURE_TYPE=${{ github.event.inputs.feature_type }}" >> $GITHUB_ENV - fi - name: Set tag and optional extra tag run: | @@ -139,15 +112,3 @@ jobs: echo "EOF" >> $GITHUB_STEP_SUMMARY echo ") | kubectl apply -f -" >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - - call-run-e2e: - if: github.event.inputs.run_e2e == 'true' - needs: - - build-pg - uses: ./.github/workflows/run-e2e.yml - with: - postgres_img: ${{ needs.build-pg.outputs.pg_image }} - major_version: ${{ needs.build-pg.outputs.pg_major }} - cnpg_branch: ${{ needs.build-pg.outputs.cnpg_branch }} - test_depth: ${{ needs.build-pg.outputs.test_depth }} - feature_type: ${{ needs.build-pg.outputs.feature_type }} diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index 310706e..63ca6aa 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -2,9 +2,6 @@ name: continuous-delivery on: workflow_dispatch: inputs: - major_version: - description: "PostgreSQL major version (leave empty for default)" - required: false cnpg_branch: description: "Name of the branch/tag used to build & load the operator (leave empty for default)" required: false @@ -52,9 +49,6 @@ jobs: # Inputs have priority over defaults.json. - name: Evaluate E2E workflow inputs run: | - if [[ -n "${{ github.event.inputs.major_version }}" ]]; then - echo "PG_MAJOR=${{ github.event.inputs.major_version }}" >> $GITHUB_ENV - fi if [[ -n "${{ github.event.inputs.cnpg_branch }}" ]]; then echo "CNPG_BRANCH=${{ github.event.inputs.cnpg_branch }}" >> $GITHUB_ENV fi diff --git a/.github/workflows/run-e2e-test.yml b/.github/workflows/run-e2e-test.yml new file mode 100644 index 0000000..3764f9d --- /dev/null +++ b/.github/workflows/run-e2e-test.yml @@ -0,0 +1,71 @@ +name: Run E2E tests + +on: + push: + workflow_dispatch: + inputs: + postgres_img: + description: "PostgreSQL Image (leave empty for default)" + required: false + major_version: + description: "PostgreSQL major version (leave empty for default)" + required: false + cnpg_branch: + description: "Name of the branch/tag used to build & load the operator (leave empty for default)" + required: false + test_depth: + description: 'E2E test level: 0(highest) to 4(lowest) (leave empty for default)' + required: false + feature_type: + description: 'E2E feature type filter. See https://github.com/cloudnative-pg/cloudnative-pg/blob/main/contribute/e2e_testing_environment/README.md#using-feature-type-test-selectionfilter' + required: false + +jobs: + evaluate-env: + name: Evaluate input env variables + runs-on: ubuntu-24.04 + outputs: + pg_image: "${{ env.PG_IMAGE }}" + pg_major: ${{ env.PG_MAJOR }} + cnpg_branch: ${{ env.CNPG_BRANCH }} + test_depth: ${{ env.TEST_DEPTH }} + feature_type: ${{ env.FEATURE_TYPE }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Set env variables from defaults.json + run: | + for key in $(jq -r 'keys[]' defaults.json); do + echo "$key=$(cat defaults.json | jq -r --arg key "$key" '.[$key]')" >> $GITHUB_ENV + done + + # Inputs have priority over defaults.json. + - name: Evaluate E2E workflow inputs + run: | + if [[ -n "${{ github.event.inputs.postgres_img }}" ]]; then + echo "PG_IMAGE=${{ github.event.inputs.postgres_img }}" >> $GITHUB_ENV + fi + if [[ -n "${{ github.event.inputs.major_version }}" ]]; then + echo "PG_MAJOR=${{ github.event.inputs.major_version }}" >> $GITHUB_ENV + fi + if [[ -n "${{ github.event.inputs.cnpg_branch }}" ]]; then + echo "CNPG_BRANCH=${{ github.event.inputs.cnpg_branch }}" >> $GITHUB_ENV + fi + if [[ -n "${{ github.event.inputs.test_depth }}" ]]; then + echo "TEST_DEPTH=${{ github.event.inputs.test_depth }}" >> $GITHUB_ENV + fi + if [[ -n "${{ github.event.inputs.feature_type }}" ]]; then + echo "FEATURE_TYPE=${{ github.event.inputs.feature_type }}" >> $GITHUB_ENV + fi + + call-run-e2e: + needs: + - evaluate-env + uses: ./.github/workflows/run-e2e.yml + with: + postgres_img: ${{ needs.evaluate-env.outputs.pg_image }} + major_version: ${{ needs.evaluate-env.outputs.pg_major }} + cnpg_branch: ${{ needs.evaluate-env.outputs.cnpg_branch }} + test_depth: ${{ needs.evaluate-env.outputs.test_depth }} + feature_type: ${{ needs.evaluate-env.outputs.feature_type }}