From 0fc4951174f80cb9ad4a4ad5ffc3dc695939dd4a Mon Sep 17 00:00:00 2001 From: Daud Kakumirizi Date: Thu, 19 Oct 2023 12:43:39 +0300 Subject: [PATCH] OZ-365: Publish GitHub Actions report for E2E tests status to Slack. (#53) --- .github/workflows/e2e.yml | 103 +++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 1cf57ae7..74fd328b 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -10,7 +10,9 @@ on: workflow_dispatch: jobs: - build: + testOnPR: + if: ${{ github.event_name == 'pull_request' }} + timeout-minutes: 45 runs-on: ubuntu-latest steps: - name: Checkout repo @@ -44,3 +46,102 @@ jobs: name: playwright-report path: playwright-report/ retention-days: 30 + + testOnPush: + if: ${{ github.event_name == 'push' }} + timeout-minutes: 45 + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: Cache dependencies + id: cache + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn install + + - name: Install Playwright Browsers + run: npx playwright install chromium --with-deps + + - name: Run E2E tests + id: jobStatusPretty + run: | + npm run e2eTests + + if [[ ${{ job.status }} == "success" ]]; then + jobStatusPretty="✅ Passing" + else + jobStatusPretty="❌ Failing" + fi + echo "jobStatusPretty=$jobStatusPretty" >> "$GITHUB_ENV" + + - name: Notify Slack + id: slack + uses: slackapi/slack-github-action@v1.24.0 + with: + payload: | + { + "blocks": [ + { + "type": "rich_text", + "elements": [ + { + "type": "rich_text_section", + "elements": [ + { + "type": "text", + "text": "GitHub Actions report from " + }, + { + "type": "link", + "url": "https://github.com/ozone-his/ozone-e2e-pro", + "text": "${{ github.repository }}", + "style": { + "bold": false + } + }, + { + "type": "text", + "text": ":\n" + } + ] + }, + { + "type": "rich_text_quote", + "elements": [ + { + "type": "link", + "url": "https://ozone-dev.mekomsolutions.net", + "text": "Ozone Dev" + }, + { + "type": "text", + "text": " server QA status: ${{ env.jobStatusPretty }}" + } + ] + } + ] + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + + - name: Upload Report + uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30