Skip to content

Commit

Permalink
feat: E2E reusable 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 e976045 commit fda88f1
Show file tree
Hide file tree
Showing 6 changed files with 341 additions and 233 deletions.
68 changes: 54 additions & 14 deletions .github/workflows/build-commitfest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,29 @@ name: Container Images from Commitest patch
on:
workflow_dispatch:
inputs:
major_version:
description: "PostgreSQL major version tag (leave empty for default)"
required: false
default: ""
commitfest_id:
description: "ID of the Commitfest"
required: false
default: ""
patch_id:
description: "ID of the Patch"
required: false
default: ""
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 @@ -34,19 +45,36 @@ jobs:
contents: read
packages: write
outputs:
tag: ${{ env.TAG }}

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

- name: Set PostgreSQL Major version
- name: Set env variables from defaults.json
run: |
majorVersion="${{ github.event.inputs.major_version }}"
if [[ -z "${majorVersion}" ]]; then
majorVersion=`cat pg_major.json | jq -r '.pg_major'`
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.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
echo "PG_MAJOR=${majorVersion}" >> $GITHUB_ENV
- name: Set commitfest branch and tag
if: github.event.inputs.commitfest_id != '' && github.event.inputs.patch_id != ''
Expand Down Expand Up @@ -86,7 +114,7 @@ jobs:
commitFestID=${{ github.event.inputs.commitfest_id }}
commitFestPatchID=${{ github.event.inputs.patch_id }}
commitFestURL="https://commitfest.postgresql.org/${commitFestID}/${commitFestPatchID}"
image="${{ env.REGISTRY }}:${{ needs.build-pg.outputs.tag }}"
image="${{ needs.build-pg.outputs.pg_image }}"
imageURL="https://${image}"
echo "# Commitfest Image Build summary" >> $GITHUB_STEP_SUMMARY
echo "**Commitfest Patch URL**: [$commitFestID / $commitFestPatchID]($commitFestURL)" >> $GITHUB_STEP_SUMMARY
Expand All @@ -107,3 +135,15 @@ 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 }}
28 changes: 20 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ name: Container Images from PostgreSQL sources
on:
workflow_dispatch:
inputs:
major_version:
description: "PostgreSQL major version tag (leave empty for default)"
required: false
default: ""
extra_tag:
description: "Use this field to set an extra tag (make sure it starts with the PG major)"
required: false
default: ""
pg_repo:
description: "Name of the target PG repository"
required: true
Expand All @@ -19,6 +11,26 @@ on:
description: "Name of the branch in the target PG repository"
required: true
default: "master"
major_version:
description: "PostgreSQL major version (leave empty for default)"
required: false
extra_tag:
description: "Use this field to set an 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"
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 Down
Loading

0 comments on commit fda88f1

Please sign in to comment.