TestPullRequestEnv #404
Workflow file for this run
This file contains 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
######################################################################################################################## | |
## ## | |
## This github workflow file is part of the Platform.sh process of updating and maintaining our collection of ## | |
## templates. For more information see https://github.com/platformsh-templates/ghrw-templates ## | |
## and https://github.com/search?q=topic%3Agithub-action+org%3Aplatformsh ## | |
## ## | |
## YOU CAN SAFELY DELETE THIS FILE ## | |
## ## | |
######################################################################################################################## | |
name: "TestPullRequestEnv" | |
run-name: "TestPullRequestEnv" | |
on: | |
workflow_run: | |
workflows: [ "platformsh" ] | |
types: | |
- completed | |
pull_request: | |
branches: | |
- master | |
- main | |
jobs: | |
reset-test-state: | |
runs-on: ubuntu-latest | |
env: | |
PLATFORMSH_CLI_TOKEN: ${{ secrets.TEMPLATES_CLI_TOKEN }} | |
PLATFORM_BRANCH: "pr-${{ github.event.pull_request.number }}" | |
steps: | |
- name: Get Project ID | |
id: get-proj-id | |
uses: platformsh/gha-retrieve-projectid@main | |
with: | |
github_token: ${{ secrets.TEMPLATES_GITHUB_TOKEN }} | |
- name: Sets up the Platformsh CLI | |
run: curl -fsSL https://raw.githubusercontent.com/platformsh/cli/main/installer.sh | bash | |
shell: bash | |
- name: 'Wait for psh and get target url' | |
id: get-target-url | |
uses: platformsh/gha-retrieve-psh-prenv-url@main | |
with: | |
github-token: ${{ secrets.TEMPLATES_GITHUB_TOKEN }} | |
- name: reset testing state | |
continue-on-error: true | |
env: | |
PLATFORM_PROJECT: ${{ steps.get-proj-id.outputs.project_id }} | |
run: | | |
platform ssh 'wp user delete bobby --yes --quiet' | |
# !!!! WARNING !!!! # | |
# If for some reason you decide to change this jobid from `TestPrEnv-CW` to something else, you will also need to | |
# add a repository variable of CW_JOBID with a value of the new jobid. | |
# Explanation: the jobid below is part of the status check name that is used in preparing the repository for an | |
# auto-accepting PR. If you change the jobid below, but do not add the repo variable with this value, then the repository | |
# will be configured to require a status check that does not exist and it will be unable to accept the PR. In addition, | |
# you will be blocked from accepting the PR until you remove it from the repo's settings | |
TestPrEnv-CW: | |
needs: reset-test-state | |
uses: platformsh-templates/ghrw-templates/.github/workflows/testprenvironment.yaml@main | |
secrets: inherit | |
# This one will eventually be migrated into the above reusable workflow | |
runE2Etests: | |
runs-on: ubuntu-latest | |
name: Runs E2E testing on PR Environment | |
needs: TestPrEnv-CW | |
env: | |
PLATFORMSH_CLI_TOKEN: ${{ secrets.TEMPLATES_CLI_TOKEN }} | |
PLATFORM_PROJECT: ${{ vars.PROJECT_ID }} | |
PLATFORM_BRANCH: "pr-${{ github.event.pull_request.number }}" | |
steps: | |
- name: Get Project ID | |
id: get-proj-id | |
uses: platformsh/gha-retrieve-projectid@main | |
with: | |
github_token: ${{ secrets.TEMPLATES_GITHUB_TOKEN }} | |
- name: Sets up the Platformsh CLI | |
run: curl -fsSL https://raw.githubusercontent.com/platformsh/cli/main/installer.sh | bash | |
shell: bash | |
- name: 'Wait for psh and get target url' | |
id: get-target-url | |
uses: platformsh/gha-retrieve-psh-prenv-url@main | |
with: | |
github-token: ${{ secrets.TEMPLATES_GITHUB_TOKEN }} | |
- uses: actions/checkout@v4 | |
name: Check out the repository | |
- uses: cypress-io/github-action@v6 | |
name: Run E2E tests | |
id: run-e2e | |
with: | |
wait-on: ${{ steps.get-target-url.outputs.target_url }} | |
record: true | |
working-directory: ./.cypress | |
env: | |
CYPRESS_baseUrl: ${{ steps.get-target-url.outputs.target_url }} | |
CYPRESS_environment: platform | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PLATFORM_PROJECT: ${{ steps.get-proj-id.outputs.project_id }} | |
- name: Remove E2E test user | |
if: steps.run-e2e.outcome == 'success' | |
run: | | |
platform ssh wp user delete bobby --yes |