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 diff --git a/.github/workflows/run-p0-tests.yaml b/.github/workflows/run-p0-tests.yaml new file mode 100644 index 0000000..1892947 --- /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 + + - 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 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.