From 07f85b1b730121091a9005bbce3202816171e52a Mon Sep 17 00:00:00 2001 From: Daria Domina Date: Sun, 12 Oct 2025 12:48:44 +0200 Subject: [PATCH 1/7] use composite action for env setup --- .github/actions/setup-playwright/action.yaml | 20 +++++++ .../workflows/auto-simple-suite-reusable.yaml | 58 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 .github/actions/setup-playwright/action.yaml create mode 100644 .github/workflows/auto-simple-suite-reusable.yaml diff --git a/.github/actions/setup-playwright/action.yaml b/.github/actions/setup-playwright/action.yaml new file mode 100644 index 0000000..449ab5a --- /dev/null +++ b/.github/actions/setup-playwright/action.yaml @@ -0,0 +1,20 @@ +name: 'Setup Playwright' +description: 'Install Node.js, dependencies and Playwright browsers' + +runs: + using: 'composite' + steps: + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'yarn' + shell: bash + + - name: Install dependencies + run: yarn install + shell: bash + + - name: Install Playwright browsers + run: yarn playwright install chromium + shell: bash \ No newline at end of file diff --git a/.github/workflows/auto-simple-suite-reusable.yaml b/.github/workflows/auto-simple-suite-reusable.yaml new file mode 100644 index 0000000..549c13e --- /dev/null +++ b/.github/workflows/auto-simple-suite-reusable.yaml @@ -0,0 +1,58 @@ +name: Auto run simple suite with reusable setup + +on: + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + run-simple-suite: + timeout-minutes: 15 + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js and Playwright + uses: ./.github/actions/setup-playwright/action.yaml + + - name: Run simple suite + run: yarn playwright test --project=chromium --grep @smoke + + - name: Upload test results + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 + with: + name: simple-suite-results-${{ github.run_id }} + path: playwright-report/ + retention-days: 7 + + post-slack-notification-started: + runs-on: ubuntu-latest + steps: + - name: Post a start message in a Slack channel + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + run: | + curl -X POST -H 'Content-type: application/json' \ + --data '{"text":"The simple suite pipeline started"}' \ + $SLACK_WEBHOOK_URL + + post-slack-notification-results: + runs-on: ubuntu-latest + needs: run-simple-suite + if: always() + steps: + - name: Post a result message in a Slack channel + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + run: | + if [ "${{ needs.run-simple-suite.result }}" == "success" ]; then + MESSAGE="The simple suite pipeline succeeded" + elif [ "${{ needs.run-simple-suite.result }}" == "failure" ]; then + MESSAGE="The simple suite pipeline failed" + fi + + curl -X POST -H 'Content-type: application/json' \ + --data "{\"text\":\"$MESSAGE\"}" \ + $SLACK_WEBHOOK_URL \ No newline at end of file From 991a8b7e5df4fe5c7fa9f610f5f655b5e84a69a2 Mon Sep 17 00:00:00 2001 From: Daria Domina Date: Sun, 12 Oct 2025 12:53:15 +0200 Subject: [PATCH 2/7] fix the path --- .github/workflows/auto-simple-suite-reusable.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-simple-suite-reusable.yaml b/.github/workflows/auto-simple-suite-reusable.yaml index 549c13e..0bf93b3 100644 --- a/.github/workflows/auto-simple-suite-reusable.yaml +++ b/.github/workflows/auto-simple-suite-reusable.yaml @@ -14,7 +14,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Node.js and Playwright - uses: ./.github/actions/setup-playwright/action.yaml + uses: ./.github/actions/setup-playwright - name: Run simple suite run: yarn playwright test --project=chromium --grep @smoke From 75af4e59b42eec2435e0bea90f696e384451a460 Mon Sep 17 00:00:00 2001 From: Daria Domina Date: Sun, 12 Oct 2025 12:54:36 +0200 Subject: [PATCH 3/7] remove shell --- .github/actions/setup-playwright/action.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/setup-playwright/action.yaml b/.github/actions/setup-playwright/action.yaml index 449ab5a..36e84c3 100644 --- a/.github/actions/setup-playwright/action.yaml +++ b/.github/actions/setup-playwright/action.yaml @@ -9,7 +9,6 @@ runs: with: node-version: '22' cache: 'yarn' - shell: bash - name: Install dependencies run: yarn install From d882af6f728c6f92b1232dbc4986e92fffb2c5db Mon Sep 17 00:00:00 2001 From: Daria Domina Date: Sun, 12 Oct 2025 13:30:03 +0200 Subject: [PATCH 4/7] add a p0 tag to a test --- tests/example.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/example.spec.ts b/tests/example.spec.ts index 7300917..f0b0196 100644 --- a/tests/example.spec.ts +++ b/tests/example.spec.ts @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test'; -test('has title', { tag: ['@smoke'] }, async ({ page }) => { +test('has title', { tag: ['@smoke', '@p0'] }, async ({ page }) => { await page.goto('https://playwright.dev/'); // Expect a title "to contain" a substring. From 9361aa1af27a4297845a66ef5df388ec208de8eb Mon Sep 17 00:00:00 2001 From: Daria Domina Date: Sun, 12 Oct 2025 13:57:14 +0200 Subject: [PATCH 5/7] resusable workflow for slack notifications --- .github/workflows/run-p0-tests.yaml | 43 +++++++++++++++++++++++ .github/workflows/slack-notification.yaml | 35 ++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 .github/workflows/run-p0-tests.yaml create mode 100644 .github/workflows/slack-notification.yaml diff --git a/.github/workflows/run-p0-tests.yaml b/.github/workflows/run-p0-tests.yaml new file mode 100644 index 0000000..a7468c2 --- /dev/null +++ b/.github/workflows/run-p0-tests.yaml @@ -0,0 +1,43 @@ +name: Run P0 tests + +on: + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + run-p0-tests: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js and Playwright + uses: ./.github/actions/setup-playwright/action.yaml + + - name: Run P0 tests + run: yarn playwright test --project=chromium --grep @p0 + + - name: Upload test results + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 + with: + name: p0-tests-results-${{ github.run_id }} + path: playwright-report/ + retention-days: 7 + + post-slack-notification-started: + uses: ./.github/workflows/slack-notification.yaml + with: + job_status: started + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + post-slack-notification-results: + needs: run-p0-tests + if: always() + uses: ./.github/workflows/slack-notification.yaml + with: + job_status: ${{ needs.run-p0-tests.result }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file diff --git a/.github/workflows/slack-notification.yaml b/.github/workflows/slack-notification.yaml new file mode 100644 index 0000000..c615e69 --- /dev/null +++ b/.github/workflows/slack-notification.yaml @@ -0,0 +1,35 @@ +name: Slack Notification + +on: + workflow_call: + inputs: + job_status: + description: 'Status: started, success, failure, cancelled, skipped' + required: true + type: string + secrets: + SLACK_WEBHOOK_URL: + required: true + +jobs: + send-notification: + runs-on: ubuntu-latest + steps: + - name: Post message to Slack + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + run: | + PIPELINE_NAME="${{ github.workflow }}" + + case "${{ inputs.job_status }}" in + "started") MESSAGE="🚀 $PIPELINE_NAME started" ;; + "success") MESSAGE="✅ $PIPELINE_NAME succeeded" ;; + "failure") MESSAGE="❌ $PIPELINE_NAME failed" ;; + "cancelled") MESSAGE="🚫 $PIPELINE_NAME was cancelled" ;; + "skipped") MESSAGE="⏭️ $PIPELINE_NAME was skipped" ;; + *) MESSAGE="⚠️ $PIPELINE_NAME - status: ${{ inputs.job_status }}" ;; + esac + + curl -X POST -H 'Content-type: application/json' \ + --data "{\"text\":\"$MESSAGE\"}" \ + $SLACK_WEBHOOK_URL From bfcc85baef8e93490d2296ae414cbda0a775e135 Mon Sep 17 00:00:00 2001 From: Daria Domina Date: Sun, 12 Oct 2025 14:00:23 +0200 Subject: [PATCH 6/7] connect the reusable workflow to auto-simple-suite-reusable --- .../workflows/auto-simple-suite-reusable.yaml | 36 ++++++------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/.github/workflows/auto-simple-suite-reusable.yaml b/.github/workflows/auto-simple-suite-reusable.yaml index 0bf93b3..54289c8 100644 --- a/.github/workflows/auto-simple-suite-reusable.yaml +++ b/.github/workflows/auto-simple-suite-reusable.yaml @@ -28,31 +28,17 @@ jobs: retention-days: 7 post-slack-notification-started: - runs-on: ubuntu-latest - steps: - - name: Post a start message in a Slack channel - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - run: | - curl -X POST -H 'Content-type: application/json' \ - --data '{"text":"The simple suite pipeline started"}' \ - $SLACK_WEBHOOK_URL + uses: ./.github/workflows/slack-notification.yaml + with: + job_status: started + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} post-slack-notification-results: - runs-on: ubuntu-latest - needs: run-simple-suite + needs: run-simple-suite if: always() - steps: - - name: Post a result message in a Slack channel - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - run: | - if [ "${{ needs.run-simple-suite.result }}" == "success" ]; then - MESSAGE="The simple suite pipeline succeeded" - elif [ "${{ needs.run-simple-suite.result }}" == "failure" ]; then - MESSAGE="The simple suite pipeline failed" - fi - - curl -X POST -H 'Content-type: application/json' \ - --data "{\"text\":\"$MESSAGE\"}" \ - $SLACK_WEBHOOK_URL \ No newline at end of file + uses: ./.github/workflows/slack-notification.yaml + with: + job_status: ${{ needs.run-simple-suite.result }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file From 3280c1ec149c53657cbaf8e8c652d4835940a480 Mon Sep 17 00:00:00 2001 From: Daria Domina Date: Sun, 12 Oct 2025 14:02:21 +0200 Subject: [PATCH 7/7] fix the action call --- .github/workflows/run-p0-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-p0-tests.yaml b/.github/workflows/run-p0-tests.yaml index a7468c2..1892947 100644 --- a/.github/workflows/run-p0-tests.yaml +++ b/.github/workflows/run-p0-tests.yaml @@ -13,7 +13,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Node.js and Playwright - uses: ./.github/actions/setup-playwright/action.yaml + uses: ./.github/actions/setup-playwright - name: Run P0 tests run: yarn playwright test --project=chromium --grep @p0