End-to-end Testing #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: End-to-end Testing | |
on: | |
deployment_status: | |
defaults: | |
run: | |
shell: bash -exuo pipefail {0} | |
jobs: | |
dump: | |
name: Dump | |
runs-on: ubuntu-22.04 | |
outputs: | |
env: ${{ steps.env.outputs.name }} | |
steps: | |
- run: | | |
cat > f <<EOF | |
${{ toJson(github.event) }} | |
EOF | |
cat f | |
e2e-tests: | |
name: End-to-end Tests | |
if: github.event.deployment_status.state == 'success' | |
runs-on: ubuntu-22.04 | |
container: | |
image: mcr.microsoft.com/playwright:v1.37.1-jammy | |
steps: | |
- run: apt-get update && apt-get install -y patch | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.deployment.sha }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20.x | |
cache: npm | |
cache-dependency-path: e2e/package-lock.json | |
- run: npm ci | |
working-directory: e2e | |
- run: ./apply-patches.sh | |
working-directory: e2e | |
- id: test | |
run: npx playwright test | |
working-directory: e2e | |
env: | |
DESCOPE_PROJECT_ID: ${{ secrets.DESCOPE_PROJECT_ID }} | |
DESCOPE_MANAGEMENT_KEY: ${{ secrets.DESCOPE_MANAGEMENT_KEY }} | |
DESCOPE_TENANT_ADMIN_ACCESS_KEY: ${{ secrets.DESCOPE_TENANT_ADMIN_ACCESS_KEY }} | |
ENV_NAME: ${{ github.event.deployment_status.environment }} | |
- uses: actions/upload-artifact@v3 | |
if: success() || (failure() && steps.test.conclusion == 'failure') | |
with: | |
name: playwright-report | |
path: | | |
e2e/playwright-report | |
e2e/custom-summary.txt | |
if-no-files-found: error | |
retention-days: 1 | |
e2e-report: | |
name: End-to-end Report | |
needs: e2e-tests | |
if: success() || (failure() && needs.e2e-tests.result == 'failure') | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: write | |
pull-requests: write | |
id-token: write | |
env: | |
BUCKET_NAME: arikkfir-playwright-reports | |
BUCKET_PATH: ${{ github.repository }}/actions/${{ github.run_number }}/${{ github.run_attempt }} | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: playwright-report | |
path: report | |
- uses: google-github-actions/auth@v1 | |
with: | |
workload_identity_provider: projects/8909046976/locations/global/workloadIdentityPools/github-actions/providers/github-oidc | |
service_account: playwright-uploader@arikkfir.iam.gserviceaccount.com | |
- uses: google-github-actions/setup-gcloud@v1 | |
with: | |
skip_install: true | |
- run: gcloud storage cp -r -P ./report/playwright-report/* "gs://${BUCKET_NAME}/${BUCKET_PATH}/" | |
- run: | | |
REPORT_WEB_URL="https://playwright.kfirs.com/${BUCKET_PATH}/index.html" | |
touch comment.txt | |
echo "End to end tests result: ${RESULT} ([click here for a full report](${REPORT_WEB_URL}))" >> comment.txt | |
echo "Application URL: ${APP_WEB_URL}" >> comment.txt | |
echo "" >> comment.txt | |
echo "---" >> comment.txt | |
echo "" >> comment.txt | |
cat ./report/custom-summary.txt >> comment.txt | |
if [[ -z "${PR}" ]]; then | |
gh api --method POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
"/repos/${REPOSITORY}/commits/${SHA}/comments" \ | |
-F 'body=@comment.txt' | |
else | |
# Purpose for the "||" expression is the "edit-last" does not work if this is the first comment | |
gh pr comment --repo "${REPOSITORY}" "${PR}" --body-file comment.txt --edit-last \ | |
|| gh pr comment --repo "${REPOSITORY}" "${PR}" --body-file comment.txt | |
fi | |
env: | |
APP_WEB_URL: ${{ github.event.deployment_status.environment_url }} | |
ENV_NAME: ${{ github.event.deployment_status.environment }} | |
GH_TOKEN: ${{ github.token }} | |
PR: ${{ github.event.workflow_run.pull_requests[0].number }} | |
REPOSITORY: ${{ github.repository }} | |
RESULT: ${{ needs.e2e-tests.result }} | |
SHA: ${{ github.event.deployment.sha }} |