Skip to content

Playwright Tests

Playwright Tests #544

Workflow file for this run

#
# SPDX-FileCopyrightText: 2023 Lifely
# SPDX-License-Identifier: EUPL-1.2+
#
name: Playwright Tests
on:
schedule:
# Runs at 9:00 PM UTC from Monday to Friday
- cron: "0 21 * * 1-5"
workflow_dispatch:
jobs:
playwright:
name: "Playwright Tests"
runs-on: ubuntu-latest
environment: azure-dimpact-dta
steps:
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d-%H-%M')" >> $GITHUB_OUTPUT
- name: login to azure and allow pssessions
uses: azure/login@a65d910e8af852a8061c627c456678983e180302 # v2.2.0
with:
creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'
enable-AzPSSession: true
- name: check IP
run: |
my_ip=$(curl https://api.ipify.org)
echo "my_ip=$my_ip" >> $GITHUB_ENV
- name: add ip to nsg
uses: azure/CLI@089eac9d8cc39f5d003e94f8b65efc51076c9cbd # v2.1.0
with:
azcliversion: "latest"
inlineScript: |
az network nsg rule create -g zac-infra --nsg-name k8s-test-nsg -n allow_github_runner --priority 295 --source-address-prefixes ${{ env.my_ip }} --destination-port-ranges '*' --direction Inbound --access allow --protocol '*' --destination-address-prefixes '*'
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
- name: Install dependencies
run: cd src/e2e && npm ci
- name: Install Playwright Browsers
run: cd src/e2e && npx playwright install --with-deps
- name: Run your tests
run: 'cd src/e2e && npm run e2e:run -- --world-parameters "{\"urls\": { \"zac\": \"${{ secrets.ZAC_URL }}\", \"openForms\": \"${{ secrets.OPEN_FORMS_URL }}\" }, \"headless\": true, \"users\": { \"Bob\": { \"username\": \"${{ secrets.ZAC_E2E_TEST_USER_1_USERNAME }}\", \"password\": \"${{ secrets.ZAC_E2E_TEST_USER_1_PASSWORD }}\"}, \"Oscar\": { \"username\": \"${{ secrets.ZAC_E2E_TEST_USER_2_USERNAME }}\", \"password\": \"${{ secrets.ZAC_E2E_TEST_USER_2_PASSWORD }}\"}}}"'
- name: Make a playwright report
if: always()
run: "cd src/e2e && npm run e2e:generate:report"
- name: copy report to seperate folder
if: always()
run: "cd src/e2e && mv reports ${{ steps.date.outputs.date }} && mkdir reports && mv ${{ steps.date.outputs.date }} reports/"
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
if: always()
with:
name: playwright-report
path: src/e2e/reports
retention-days: 7
- name: Deploy to GitHub Pages
if: ${{ !cancelled() && github.ref == 'refs/heads/main' }}
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./src/e2e/reports/ # directory of your reports
publish_branch: gh-pages/dimpact-e2e-test-report # deploying to gh-pages branch
keep_files: true # retains files that are not part of the current publish
- name: Notify Slack
if: ${{ !cancelled() && github.ref == 'refs/heads/main' }}
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: custom
fields: workflow,job,status
custom_payload: |
{
"text": ":performing_arts: Playwright Tests Update",
"attachments": [
{
"color": "${{ job.status == 'success' && 'good' || job.status == 'failure' && 'danger' || 'warning' }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Workflow Run Details"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Repository:*\n${{ github.repository }}"
},
{
"type": "mrkdwn",
"text": "*Workflow:*\n${{ github.workflow }}"
},
{
"type": "mrkdwn",
"text": "*Job:*\n${{ github.job }}"
},
{
"type": "mrkdwn",
"text": "*Status:*\n${{ job.status }} ${{ job.status == 'success' && ':white_check_mark:' || ':x:' }}"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Report URL:*\n:link: https://infonl.github.io/dimpact-zaakafhandelcomponent/${{ steps.date.outputs.date }}/e2e-report.html"
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "View Report"
},
"url": "https://infonl.github.io/dimpact-zaakafhandelcomponent/${{ steps.date.outputs.date }}/e2e-report.html"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "View Run"
},
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "View Videos"
},
"url": "https://infonl.github.io/dimpact-zaakafhandelcomponent/${{ steps.date.outputs.date }}/videos.html"
}
]
}
]
}
]
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: remove nsg rule by name
if: always()
uses: azure/CLI@089eac9d8cc39f5d003e94f8b65efc51076c9cbd # v2.1.0
with:
azcliversion: "latest"
inlineScript: |
az network nsg rule delete -g zac-infra --nsg-name k8s-test-nsg -n allow_github_runner