|
| 1 | +name: Run Playwright e2e tests and generate documentation |
| 2 | + |
| 3 | +on: |
| 4 | + # Runs on pushes targeting the main branch |
| 5 | + push: |
| 6 | + branches: [main, dev] |
| 7 | + |
| 8 | + # Allows you to run this workflow manually from the Actions tab |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + pages: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 18 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 19 | +concurrency: |
| 20 | + group: "pages" |
| 21 | + cancel-in-progress: false |
| 22 | + |
| 23 | +jobs: |
| 24 | + # Build job: runs tsdocs and playwright tests, then uploads docs and playwright-report to Pages as an artifact |
| 25 | + build: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - name: Checkout repo |
| 29 | + uses: actions/checkout@v3 |
| 30 | + |
| 31 | + - name: Setup node environment |
| 32 | + uses: actions/setup-node@v3 |
| 33 | + with: |
| 34 | + node-version: "20" |
| 35 | + |
| 36 | + - name: Configure Github Pages |
| 37 | + uses: actions/configure-pages@v3 |
| 38 | + |
| 39 | + - name: Install xvfb |
| 40 | + run: sudo apt-get update && sudo apt-get install -y xvfb |
| 41 | + |
| 42 | + - name: Install node dependencies |
| 43 | + run: npm i |
| 44 | + |
| 45 | + - name: Run tsdocs on the src directory |
| 46 | + run: npm run docs |
| 47 | + |
| 48 | + - name: Install Playwright browsers |
| 49 | + run: npx playwright install --with-deps |
| 50 | + |
| 51 | + - name: Build the extension |
| 52 | + run: npm run build:webext |
| 53 | + |
| 54 | + - name: Run Playwright tests with xvfb |
| 55 | + run: xvfb-run --auto-servernum --server-args='-screen 0 1280x1024x24' npx playwright test |
| 56 | + |
| 57 | + - name: Build the artifact directory |
| 58 | + run: | |
| 59 | + mkdir -p build_outputs_folder/ |
| 60 | + cp -r docs build_outputs_folder/ |
| 61 | + cp index.html build_outputs_folder/ |
| 62 | + cp -r assets build_outputs_folder/ |
| 63 | + # Uncomment for debugging purposes |
| 64 | + # cp -r playwright/playwright-report build_outputs_folder/ |
| 65 | + # cp -r playwright/test-results build_outputs_folder/ |
| 66 | + |
| 67 | + - name: List artifact directory contents |
| 68 | + run: ls -l build_outputs_folder/* |
| 69 | + |
| 70 | + - name: Upload the artifact to Pages |
| 71 | + uses: actions/upload-pages-artifact@v3 |
| 72 | + with: |
| 73 | + path: build_outputs_folder/ |
| 74 | + |
| 75 | + # Deployment job: deploys the artifact to GitHub Pages |
| 76 | + deploy: |
| 77 | + environment: |
| 78 | + name: github-pages |
| 79 | + url: ${{ steps.deployment.outputs.page_url }} |
| 80 | + runs-on: ubuntu-latest |
| 81 | + needs: build |
| 82 | + steps: |
| 83 | + - name: Download artifact from build |
| 84 | + uses: actions/download-artifact@v4 |
| 85 | + with: |
| 86 | + name: github-pages |
| 87 | + path: . |
| 88 | + - name: Deploy to GitHub Pages |
| 89 | + id: deployment |
| 90 | + uses: actions/deploy-pages@v4 |
0 commit comments