Playwright E2E Tests #162
This file contains hidden or 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: Playwright E2E Tests | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| project: | |
| description: 'Select the Browser to be used for E2E Testing' | |
| required: true | |
| default: 'chromium_test_workflow' | |
| type: choice | |
| options: | |
| - chromium_test_workflow | |
| - firefox_test_workflow | |
| - webkit_test_workflow | |
| schedule: | |
| - cron: "0 0 * * *" | |
| jobs: | |
| run-playwright-e2e: | |
| timeout-minutes: 30 | |
| runs-on: ubuntu-latest | |
| outputs: | |
| upload_success: ${{ steps.set-upload-status.outputs.upload_success }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: lts/* | |
| - name: Add Environment Variable To DependencyTrack Apiserver | |
| run: | | |
| cat <<EOF > docker-compose.override.yml | |
| services: | |
| apiserver: | |
| environment: | |
| ALPINE_BCRYPT_ROUNDS: "4" | |
| EOF | |
| - name: Checkout Hyades Repository | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: DependencyTrack/hyades | |
| path: hyades | |
| - name: Start DependencyTrack | |
| run: | | |
| docker compose -f ./hyades/docker-compose.yml -f docker-compose.override.yml --profile demo up -d --pull always | |
| - name: Generate Random UUID for password use | |
| run: | | |
| RANDOM_PASSWORD=$(uuidgen -r) | |
| echo "::add-mask::$RANDOM_PASSWORD" # Mask the value | |
| echo "RANDOM_PASSWORD=$RANDOM_PASSWORD" >> $GITHUB_ENV | |
| - name: Install necessary playwright dependencies | |
| run: | | |
| npm ci | |
| npx playwright install --with-deps | |
| - name: Generate BDD Tests | |
| run: npx bddgen | |
| - name: Run Playwright tests | |
| run: npx playwright test --project=${{ inputs.project || 'chromium_test_workflow' }} | |
| - name: Upload test results | |
| id: upload-step | |
| if: ${{ !cancelled() }} | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: playwright-results | |
| path: playwright-test-results/allure-results | |
| - name: Set upload success output | |
| id: set-upload-status | |
| if: ${{ !cancelled() }} | |
| run: | | |
| if [ "${{ steps.upload-step.conclusion }}" == "success" ]; then | |
| echo "upload_success=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "upload_success=false" >> $GITHUB_OUTPUT | |
| fi | |
| publish-results: | |
| needs: run-playwright-e2e | |
| runs-on: ubuntu-latest | |
| if: "${{ always() && needs.run-playwright-e2e.outputs.upload_success == 'true' && github.repository_owner == 'DependencyTrack' }}" | |
| steps: | |
| - name: Download test results | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: playwright-results | |
| path: playwright-test-results/allure-results | |
| - name: Load test report history | |
| uses: actions/checkout@v5 | |
| if: always() | |
| continue-on-error: true | |
| with: | |
| ref: allure-report | |
| path: latest-test-results | |
| - name: Build test report | |
| uses: simple-elf/[email protected] | |
| if: always() | |
| with: | |
| gh_pages: latest-test-results | |
| allure_results: playwright-test-results/allure-results # path in project to allure report | |
| allure_history: allure-history # directory to be published | |
| - name: Publish test report | |
| uses: peaceiris/actions-gh-pages@v4 | |
| if: always() | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_branch: allure-report # branch-name to paste history to | |
| publish_dir: allure-history # directory to be published | |
| user_name: 'github-actions[bot]' # user for publishing | |
| user_email: 'github-actions[bot]@users.noreply.github.com' # email for publishing |