diff --git a/scaffold/.github/workflows/deploymentPlaywrightTests.yml b/scaffold/.github/workflows/deploymentPlaywrightTests.yml deleted file mode 100644 index 409620c..0000000 --- a/scaffold/.github/workflows/deploymentPlaywrightTests.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: "Run Playwright Tests on Pantheon" -run-name: "${{ github.event.deployment_status.environment }} by @${{ github.actor }}" - -on: - deployment_status: {} - -jobs: - Playwright-Tests: - runs-on: ubuntu-latest - if: github.event.deployment_status.state == 'success' - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "8.4" - - - name: Install Terminus - uses: pantheon-systems/terminus-github-actions@v1 - with: - pantheon-machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} - terminus-version: 4.3.1 - - name: Set multidev name - id: multidev - run: echo "name=${{ github.event.deployment_status.environment }}" | sed 's/pantheon-//' >> $GITHUB_OUTPUT - - - name: Wait for review app to respond - uses: ./.github/actions/code-testing/terminus/wait-for-build - with: - site-name: ${{ vars.PANTHEON_SITE_NAME }} - multidev-name: ${{ steps.multidev.outputs.name }} - - # Playwright steps go here - - name: Checkout actions - uses: actions/checkout@v4 - - - name: Run Playwright tests - uses: ./.github/actions/code-testing/playwright/test - with: - target-url: ${{ github.event.deployment_status.environment_url }} - environment-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} - environment-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} - test-script: 'test:ci-pantheon' \ No newline at end of file diff --git a/scaffold/.github/workflows/deploymentBrowserStackTests.yml b/scaffold/.github/workflows/deploymentTests.yml similarity index 60% rename from scaffold/.github/workflows/deploymentBrowserStackTests.yml rename to scaffold/.github/workflows/deploymentTests.yml index 30f589c..f81c153 100644 --- a/scaffold/.github/workflows/deploymentBrowserStackTests.yml +++ b/scaffold/.github/workflows/deploymentTests.yml @@ -1,7 +1,8 @@ -name: "Run BrowserStack tests on Pantheon" +name: "Deployment Tests" run-name: "${{ github.event.deployment_status.environment }} by @${{ github.actor }}" + on: - deployment_status: { } + deployment_status: {} jobs: detect-php-version: @@ -16,24 +17,91 @@ jobs: - name: Read php_version from Pantheon config id: php-version uses: ./.github/actions/code-testing/detect-php-version - Decide-If-Tests-Should-Run: + + Set-Multidev-Name: runs-on: ubuntu-latest if: github.event.deployment_status.state == 'success' outputs: - should-run: ${{ steps.decide.outputs.should-run }} - multidev-name: ${{ steps.multidev.outputs.name }} + name: ${{ steps.multidev.outputs.name }} steps: - name: Set multidev name id: multidev run: echo "name=${{ github.event.deployment_status.environment }}" | sed 's/pantheon-//' >> $GITHUB_OUTPUT + Index-Search-Api: + name: Index Search API (if needed) + runs-on: ubuntu-latest + needs: [Set-Multidev-Name] + if: github.event.deployment_status.state == 'success' + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Install Terminus + uses: pantheon-systems/terminus-github-actions@v1 + with: + pantheon-machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} + terminus-version: 4.3.1 + + - name: Wait for review app to respond + uses: ./.github/actions/code-testing/terminus/wait-for-build + with: + site-name: ${{ vars.PANTHEON_SITE_NAME }} + multidev-name: ${{ needs.Set-Multidev-Name.outputs.name }} + + - name: Run indexing if it is needed. + if: ${{ vars.TESTING_NEEDS_SEARCH_INDEXING == 'true' }} + uses: ./.github/actions/code-testing/drupal/index-search + with: + machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} + pantheon-site-name: ${{ vars.PANTHEON_SITE_NAME }} + multidev-name: ${{ needs.Set-Multidev-Name.outputs.name }} + + Playwright-Tests: + runs-on: ubuntu-latest + needs: [Set-Multidev-Name, Index-Search-Api] + if: github.event.deployment_status.state == 'success' + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.4" + + - name: Install Terminus + uses: pantheon-systems/terminus-github-actions@v1 + with: + pantheon-machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} + terminus-version: 4.3.1 + + - name: Wait for review app to respond + uses: ./.github/actions/code-testing/terminus/wait-for-build + with: + site-name: ${{ vars.PANTHEON_SITE_NAME }} + multidev-name: ${{ needs.Set-Multidev-Name.outputs.name }} + + - name: Run Playwright tests + uses: ./.github/actions/code-testing/playwright/test + with: + target-url: ${{ github.event.deployment_status.environment_url }} + environment-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} + environment-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} + test-script: 'test:ci-pantheon' + + Decide-If-Browserstack-Should-Run: + runs-on: ubuntu-latest + needs: [Set-Multidev-Name] + if: github.event.deployment_status.state == 'success' + outputs: + should-run: ${{ steps.decide.outputs.should-run }} + steps: - name: Decide whether to run BrowserStack tests id: decide shell: bash env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ github.repository }} - MULTIDEV_NAME: ${{ steps.multidev.outputs.name }} + MULTIDEV_NAME: ${{ needs.Set-Multidev-Name.outputs.name }} BROWSERSTACK_TESTS_ENABLED: ${{ vars.BROWSERSTACK_TESTS_ENABLED }} BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} @@ -65,10 +133,11 @@ jobs: echo "::notice::$MULTIDEV_NAME is not a PR multidev, running BrowserStack tests." echo "should-run=true" >> "$GITHUB_OUTPUT" fi - Set-Up-and-Run-Tests: + + BrowserStack-Tests: runs-on: ubuntu-latest - needs: [detect-php-version, Decide-If-Tests-Should-Run] - if: ${{ needs.Decide-If-Tests-Should-Run.outputs.should-run == 'true' }} + needs: [detect-php-version, Set-Multidev-Name, Decide-If-Browserstack-Should-Run, Index-Search-Api] + if: ${{ needs.Decide-If-Browserstack-Should-Run.outputs.should-run == 'true' }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -87,9 +156,8 @@ jobs: uses: ./.github/actions/code-testing/terminus/wait-for-build with: site-name: ${{ vars.PANTHEON_SITE_NAME }} - multidev-name: ${{ needs.Decide-If-Tests-Should-Run.outputs.multidev-name }} + multidev-name: ${{ needs.Set-Multidev-Name.outputs.name }} - # Browserstack test steps go here - name: Checkout actions uses: actions/checkout@v6 @@ -107,7 +175,7 @@ jobs: id: set-url env: PANTHEON_SITE_NAME: ${{ vars.PANTHEON_SITE_NAME }} - MULTIDEV_NAME: ${{ needs.Decide-If-Tests-Should-Run.outputs.multidev-name }} + MULTIDEV_NAME: ${{ needs.Set-Multidev-Name.outputs.name }} run: | echo "target_url=https://${MULTIDEV_NAME}-${PANTHEON_SITE_NAME}.pantheonsite.io" >> "$GITHUB_OUTPUT" diff --git a/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml b/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml index 4e66e8a..ad666be 100644 --- a/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml +++ b/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml @@ -62,23 +62,4 @@ jobs: terminus-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} commit-message: ${{ github.sha }} site-name: ${{ secrets.PANTHEON_SITE_NAME }} - branch: edge - - - name: Install Terminus - uses: pantheon-systems/terminus-github-actions@v1 - with: - pantheon-machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} - - - name: Wait for review app to respond - uses: ./.github/actions/code-testing/terminus/wait-for-build - with: - site-name: ${{ secrets.PANTHEON_SITE_NAME }} - multidev-name: edge - - - name: Run indexing if it is needed. - if: ${{ vars.TESTING_NEEDS_SEARCH_INDEXING == 'true' }} - uses: ./.github/actions/code-testing/drupal/index-search - with: - machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} - pantheon-site-name: ${{ secrets.PANTHEON_SITE_NAME }} - multidev-name: edge \ No newline at end of file + branch: edge \ No newline at end of file diff --git a/scaffold/.github/workflows/drainpipePantheonBuildMain.yml b/scaffold/.github/workflows/drainpipePantheonBuildMain.yml index efcd6f0..66b0b1d 100644 --- a/scaffold/.github/workflows/drainpipePantheonBuildMain.yml +++ b/scaffold/.github/workflows/drainpipePantheonBuildMain.yml @@ -57,23 +57,4 @@ jobs: terminus-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} commit-message: ${{ github.sha }} site-name: ${{ secrets.PANTHEON_SITE_NAME }} - branch: master - - - name: Install Terminus - uses: pantheon-systems/terminus-github-actions@v1 - with: - pantheon-machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} - - - name: Wait for review app to respond - uses: ./.github/actions/code-testing/terminus/wait-for-build - with: - site-name: ${{ secrets.PANTHEON_SITE_NAME }} - multidev-name: dev - - - name: Run indexing if it is needed. - if: ${{ vars.TESTING_NEEDS_SEARCH_INDEXING == 'true' }} - uses: ./.github/actions/code-testing/drupal/index-search - with: - machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} - pantheon-site-name: ${{ secrets.PANTHEON_SITE_NAME }} - multidev-name: dev \ No newline at end of file + branch: master \ No newline at end of file diff --git a/scaffold/.github/workflows/drainpipePantheonReviewApps.yml b/scaffold/.github/workflows/drainpipePantheonReviewApps.yml index 6c7523f..027792a 100644 --- a/scaffold/.github/workflows/drainpipePantheonReviewApps.yml +++ b/scaffold/.github/workflows/drainpipePantheonReviewApps.yml @@ -84,14 +84,6 @@ jobs: multidev-name: pr-${{ github.event.pull_request.number }} site-name: ${{ secrets.PANTHEON_SITE_NAME }} - - name: Run indexing if it is needed. - if: ${{ vars.TESTING_NEEDS_SEARCH_INDEXING == 'true' }} - uses: ./.github/actions/code-testing/drupal/index-search - with: - machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} - pantheon-site-name: ${{ secrets.PANTHEON_SITE_NAME }} - multidev-name: pr-${{ github.event.pull_request.number }} - - name: Add Multidev URL to PR uses: ./.github/actions/code-testing/github/add-pr-url with: diff --git a/scaffold/.github/workflows/drainpipePlaywrightTests.yml b/scaffold/.github/workflows/drainpipePlaywrightTests.yml deleted file mode 100644 index 2e7411a..0000000 --- a/scaffold/.github/workflows/drainpipePlaywrightTests.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: "Run Playwright Tests on Pantheon" -run-name: "${{ github.event.workflow_run.head_branch }} by @${{ github.event.workflow_run.actor.login }}" - -on: - workflow_run: - workflows: - - "Pantheon Build Edge" - - "Pantheon Build Main" - - "Pantheon Review Apps" - types: - - completed -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -permissions: - contents: read - pull-requests: read - -jobs: - get-multidev-name: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - outputs: - multidev-name: ${{ steps.name.outputs.multidev-name }} - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Get multidev name - id: name - uses: ./.github/actions/code-testing/github/decide-test-run - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - primary-branch: ${{ vars.BROWSERSTACK_PRIMARY_BRANCH || 'main' }} - run-playwright-tests: - runs-on: ubuntu-latest - needs: get-multidev-name - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Set target URL - shell: bash - id: set-url - env: - PANTHEON_SITE_NAME: ${{ vars.PANTHEON_SITE_NAME }} - MULTIDEV_NAME: ${{ needs.get-multidev-name.outputs.multidev-name }} - run: | - echo "target_url=https://${MULTIDEV_NAME}-${PANTHEON_SITE_NAME}.pantheonsite.io" >> "$GITHUB_OUTPUT" - - - name: Run Playwright tests in Pantheon environment. - uses: ./.github/actions/code-testing/playwright/test - with: - environment-password: ${{ secrets.PANTHEON_REVIEW_USERNAME }} - environment-username: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} - target-url: ${{ steps.set-url.outputs.target_url }} - test-script: 'test:ci-pantheon' \ No newline at end of file diff --git a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml b/scaffold/.github/workflows/drainpipeTests.yml similarity index 58% rename from scaffold/.github/workflows/drainpipeBrowserStackTests.yml rename to scaffold/.github/workflows/drainpipeTests.yml index e78a4c6..bce526c 100644 --- a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml +++ b/scaffold/.github/workflows/drainpipeTests.yml @@ -1,4 +1,4 @@ -name: "Run BrowserStack Tests on Pantheon" +name: "Run Tests on Pantheon" run-name: "${{ github.event.workflow_run.head_branch }} by @${{ github.event.workflow_run.actor.login }}" on: @@ -9,6 +9,9 @@ on: - "Pantheon Review Apps" types: - completed +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true permissions: contents: read @@ -27,6 +30,7 @@ jobs: - name: Read php_version from Pantheon config id: php-version uses: ./.github/actions/code-testing/detect-php-version + Decide-If-Tests-Should-Run: runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} @@ -36,17 +40,69 @@ jobs: steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Decide whether to run BrowserStack tests + - name: Decide whether to run tests id: decide uses: ./.github/actions/code-testing/github/decide-test-run with: github-token: ${{ secrets.GITHUB_TOKEN }} primary-branch: ${{ vars.BROWSERSTACK_PRIMARY_BRANCH || 'main' }} - Set-Up-Tests: - needs: Decide-If-Tests-Should-Run + Index-Search-Api: + name: Index Search API (if needed) + runs-on: ubuntu-latest + needs: [Decide-If-Tests-Should-Run] if: ${{ needs.Decide-If-Tests-Should-Run.outputs.should-run == 'true' }} + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Install Terminus + uses: pantheon-systems/terminus-github-actions@v1 + with: + pantheon-machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} + terminus-version: 4.3.1 + + - name: Wait for review app to respond + uses: ./.github/actions/code-testing/terminus/wait-for-build + with: + site-name: ${{ vars.PANTHEON_SITE_NAME }} + multidev-name: ${{ needs.Decide-If-Tests-Should-Run.outputs.multidev-name }} + + - name: Run indexing if it is needed. + if: ${{ vars.TESTING_NEEDS_SEARCH_INDEXING == 'true' }} + uses: ./.github/actions/code-testing/drupal/index-search + with: + machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} + pantheon-site-name: ${{ vars.PANTHEON_SITE_NAME }} + multidev-name: ${{ needs.Decide-If-Tests-Should-Run.outputs.multidev-name }} + + Playwright-Tests: + runs-on: ubuntu-latest + needs: [Decide-If-Tests-Should-Run, Index-Search-Api] + if: ${{ needs.Decide-If-Tests-Should-Run.outputs.should-run == 'true' }} + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Set target URL + shell: bash + id: set-url + env: + PANTHEON_SITE_NAME: ${{ vars.PANTHEON_SITE_NAME }} + MULTIDEV_NAME: ${{ needs.Decide-If-Tests-Should-Run.outputs.multidev-name }} + run: | + echo "target_url=https://${MULTIDEV_NAME}-${PANTHEON_SITE_NAME}.pantheonsite.io" >> "$GITHUB_OUTPUT" + + - name: Run Playwright tests in Pantheon environment. + uses: ./.github/actions/code-testing/playwright/test + with: + environment-password: ${{ secrets.PANTHEON_REVIEW_USERNAME }} + environment-username: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} + target-url: ${{ steps.set-url.outputs.target_url }} + test-script: 'test:ci-pantheon' + + BrowserStack-Tests: runs-on: ubuntu-latest + needs: [detect-php-version, Decide-If-Tests-Should-Run, Index-Search-Api] + if: ${{ needs.Decide-If-Tests-Should-Run.outputs.should-run == 'true' }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 diff --git a/src/Plugin.php b/src/Plugin.php index 8e9534f..d4b2f09 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -52,7 +52,7 @@ public function scaffold(Event $event): void { // Copy only the workflows declared in extra.code_testing.github. // Each context key becomes a filename prefix: - // "drainpipe": ["PlaywrightTests"] → drainpipePlaywrightTests.yml + // "drainpipe": ["PlaywrightTests"] → drainpipeTests.yml // "deployment": ["PlaywrightTests"] → deploymentPlaywrightTests.yml // "pantheon": ["ReviewApps"] → pantheonReviewApps.yml $hasDrainpipe = FALSE;