|
| 1 | +name: Run Regression Tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + ENVIRONMENT: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + VERSION_NUMBER: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + REGRESSION_TESTS_PEM: |
| 13 | + type: string |
| 14 | + default: "false" |
| 15 | + secrets: |
| 16 | + REGRESSION_TESTS_PEM: |
| 17 | + required: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + run_regression_tests: |
| 21 | + runs-on: ubuntu-22.04 |
| 22 | + permissions: |
| 23 | + id-token: write |
| 24 | + contents: write |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout local github actions |
| 28 | + uses: actions/checkout@v5 |
| 29 | + with: |
| 30 | + ref: ${{ env.BRANCH_NAME }} |
| 31 | + fetch-depth: 0 |
| 32 | + |
| 33 | + - name: Generate a token to authenticate regression testing |
| 34 | + id: generate-token |
| 35 | + uses: actions/create-github-app-token@v2 |
| 36 | + with: |
| 37 | + app-id: ${{ vars.REGRESSION_TESTS_APP_ID }} |
| 38 | + private-key: ${{ secrets.REGRESSION_TESTS_PEM }} |
| 39 | + owner: "NHSDigital" |
| 40 | + repositories: "electronic-prescription-service-api-regression-tests" |
| 41 | + |
| 42 | + # using git commit sha for version of action to ensure we have stable version |
| 43 | + - name: Install asdf |
| 44 | + uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302 |
| 45 | + with: |
| 46 | + asdf_branch: v0.11.3 |
| 47 | + |
| 48 | + - name: Cache asdf |
| 49 | + uses: actions/cache@v4 |
| 50 | + with: |
| 51 | + path: | |
| 52 | + ~/.asdf |
| 53 | + key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }} |
| 54 | + restore-keys: | |
| 55 | + ${{ runner.os }}-asdf- |
| 56 | +
|
| 57 | + - name: Install asdf dependencies in .tool-versions |
| 58 | + uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302 |
| 59 | + with: |
| 60 | + asdf_branch: v0.11.3 |
| 61 | + env: |
| 62 | + PYTHON_CONFIGURE_OPTS: --enable-shared |
| 63 | + |
| 64 | + - name: Run Regression Testing |
| 65 | + working-directory: scripts |
| 66 | + env: |
| 67 | + TARGET_ENVIRONMENT: ${{ inputs.ENVIRONMENT }} |
| 68 | + VERSION_NUMBER: ${{ inputs.VERSION_NUMBER }} |
| 69 | + GITHUB-TOKEN: ${{ steps.generate-token.outputs.token }} |
| 70 | + run: | |
| 71 | + if [[ "$TARGET_ENVIRONMENT" != "prod" && "$TARGET_ENVIRONMENT" != "ref" ]]; then |
| 72 | + # this should be the tag of the tests you want to run |
| 73 | + REGRESSION_TEST_REPO_TAG=v3.4.0 |
| 74 | +
|
| 75 | + # this should be the tag of the regression test workflow you want to run |
| 76 | + # This will normally be the same as REGRESSION_TEST_REPO_TAG |
| 77 | + REGRESSION_TEST_WORKFLOW_TAG=v3.4.0 |
| 78 | +
|
| 79 | + curl https://raw.githubusercontent.com/NHSDigital/electronic-prescription-service-api-regression-tests/refs/tags/${REGRESSION_TEST_WORKFLOW_TAG}/scripts/run_regression_tests.py -o run_regression_tests.py |
| 80 | + poetry install |
| 81 | + echo Running regression tests in the "$TARGET_ENVIRONMENT" environment |
| 82 | + poetry run python -u run_regression_tests.py \ |
| 83 | + --env="$TARGET_ENVIRONMENT" \ |
| 84 | + --pr_label="$VERSION_NUMBER" \ |
| 85 | + --token=${{ steps.generate-token.outputs.token }} \ |
| 86 | + --is_called_from_github=true \ |
| 87 | + --product=EPS-ASSIST-ME \ |
| 88 | + --regression_test_repo_tag "${REGRESSION_TEST_REPO_TAG}" \ |
| 89 | + --regression_test_workflow_tag "${REGRESSION_TEST_WORKFLOW_TAG}" |
| 90 | + fi |
0 commit comments