Skip to content

Commit

Permalink
chore: run E2E tests from a separate workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Niccolò Fei <[email protected]>
  • Loading branch information
NiccoloFei committed Sep 2, 2024
1 parent c8da8aa commit 8718a2b
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 84 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/build-commitfest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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 != ''
Expand Down Expand Up @@ -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 }}
39 changes: 0 additions & 39 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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: |
Expand Down Expand Up @@ -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 }}
6 changes: 0 additions & 6 deletions .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/run-e2e-test.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit 8718a2b

Please sign in to comment.