allure-js icon indicating copy to clipboard operation
allure-js copied to clipboard

[BUG] Allure Report on Github pages does not have videos (locally it does)

Open borecz opened this issue 1 year ago • 0 comments

System info

  • Playwright Version: [v1.34]
  • Operating System: [All]
  • Browser: [All]
  • Other info:

Source code (.yaml file)

name: Playwright Tests
on:
  workflow_dispatch:
    inputs:
      management-url:
        required: true
      management-password:
        required: true
      project:
        required: true
        default: 'all'
        type: choice
        description: Project
        options:
          - all
          - project1
          - project2
          - project3

env:
  MANAGEMENT_URL: ${{ github.event.inputs.management-url }}
  MANAGEMENT_USER: admin@${{ github.event.inputs.management-url }}
  MANAGEMENT_PASSWORD: ${{ github.event.inputs.management-password }}

jobs:
  install:
    permissions:
      contents: read
      pages: write
      id-token: write
    timeout-minutes: 60
    runs-on: company-runner
    container:
      image: mcr.microsoft.com/playwright:v1.34.3-jammy
    outputs:
      playwright_version: ${{ steps.set-env.outputs.PLAYWRIGHT_VERSION }}
      started_at: ${{ steps.set-env.outputs.STARTED_AT}}
      pull_request_url: ${{ steps.set-env.outputs.PULL_REQUEST_URL }}

    env:
      PULL_REQUEST_URL: ${{ github.event.pull_request._links.html.href }}

    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 18

      - name: Set current date as env variable
        run: echo "STARTED_AT=$(date +%s)" >> $GITHUB_ENV

      - name: Get installed Playwright version
        id: playwright-version
        run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').dependencies['@playwright/test'].version)")" >> $GITHUB_ENV

      - name: Cache playwright binaries
        uses: actions/cache@v3
        id: playwright-cache
        with:
          path: |
            ~/.cache/ms-playwright
          key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
      - run: npx playwright install --with-deps
        if: steps.playwright-cache.outputs.cache-hit != 'true'
      - run: npx playwright install-deps
        if: steps.playwright-cache.outputs.cache-hit != 'true'

      - name: Cache node_modules
        uses: actions/cache@v3
        id: node-modules-cache
        with:
          path: |
            node_modules
          key: modules-${{ hashFiles('package-lock.json') }}
      - run: npm ci --ignore-scripts
        if: steps.node-modules-cache.outputs.cache-hit != 'true'

      - name: Create Output for ENV Variables
        id: set-env
        run: |
          echo "PLAYWRIGHT_VERSION=${{env.PLAYWRIGHT_VERSION}}" >> $GITHUB_OUTPUT
          echo "STARTED_AT=${{env.STARTED_AT}}" >> $GITHUB_OUTPUT      
          echo "PULL_REQUEST_URL=${{env.PULL_REQUEST_URL}}" >> $GITHUB_OUTPUT

  tests:
    name: Run Playwright Tests (${{ matrix.shardIndex }}/${{ strategy.job-total }})
    needs: install
    timeout-minutes: 20
    runs-on: company-runner
    container:
      image: mcr.microsoft.com/playwright:v1.34.3-jammy
    strategy:
      fail-fast: false
      matrix:
        shardIndex: [1, 2, 3, 4]
        shardTotal: [4]
    env:
      PLAYWRIGHT_VERSION: ${{ needs.install.outputs.playwright_version }}
      STARTED_AT: ${{ needs.install.outputs.started_at }}
      PULL_REQUEST_URL: ${{ needs.install.outputs.pull_request_url }}

    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 18

      - name: Cache node_modules
        uses: actions/cache@v3
        with:
          path: |
            node_modules
          key: modules-${{ hashFiles('package-lock.json') }}

      - name: Cache Playwright
        uses: actions/cache@v3
        with:
          path: |
            ~/.cache/ms-playwright
          key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}

      - name: Run Playwright tests
        run: npx playwright test --project ${{ github.event.inputs.project }} --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}

      - name: Archive Allure results
        uses: actions/upload-artifact@v2
        if: always()
        with:
          name: allure-results-${{ matrix.shardIndex }}
          path: ./allure-results
          retention-days: 3

      - uses: actions/upload-artifact@v2
        if: always()
        with:
          name: report-${{ matrix.shardIndex }}
          path: playwright-report/
          retention-days: 3

  merge:
    name: Merge Reports
    if: ${{ always() }}
    needs: [install, tests]
    timeout-minutes: 10
    permissions:
      contents: read
      pages: write
      id-token: write
    concurrency:
      group: 'pages'
      cancel-in-progress: true
    env:
      PLAYWRIGHT_VERSION: ${{ needs.tests.outputs.playwright_version }}
      STARTED_AT: ${{ needs.tests.outputs.started_at }}
      PULL_REQUEST_URL: ${{ needs.tests.outputs.pull_request_url }}
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: company-runner

    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 18

      - name: Cache node_modules
        uses: actions/cache@v3
        with:
          path: |
            node_modules
          key: modules-${{ hashFiles('package-lock.json') }}

      - name: Cache Playwright
        uses: actions/cache@v3
        with:
          path: |
            ~/.cache/ms-playwright
          key: playwright-${{ hashFiles('package-lock.json') }}

      - name: Download Allure results
        uses: actions/download-artifact@v3
        with:
          path: ./allure-results

      - name: Move Allure results into one directory
        run: |
          mkdir allure-results-final
          for i in allure-results-{1..4}; do
            if [ -d "$i" ]; then
              mv $i/* allure-results-final/
            fi
          done
        working-directory: ./allure-results

      - name: Display structure of grouped files
        run: ls -R
        working-directory: ./allure-results

      - name: Install Java
        uses: actions/setup-java@v3
        with:
          distribution: 'adopt'
          java-version: '11'

      - name: Install Allure-commandline
        run: npm install -g allure-commandline --save-dev

      - name: Generate Allure Report
        run: npx allure generate ./allure-results-final --clean -o allure-report
        working-directory: ./allure-results

      - name: Display structure of Generated Report
        run: ls -R
        working-directory: ./allure-results/allure-report

      - uses: actions/upload-pages-artifact@v1
        if: always()
        with:
          name: allure-report
          path: ./allure-results/allure-report
          retention-days: 3

      - name: Setup Pages
        if: always()
        uses: actions/configure-pages@v2

      - name: Deploy Allure report to GitHub Pages
        if: always()
        id: deployment
        uses: actions/deploy-pages@v1
        with:
          artifact_name: allure-report
          commit-message: 'Deploy Allure report to GitHub Pages'

Config file

export default defineConfig({
  testDir: './packages/teams',
  testIgnore: ['**/work-in-progress/**', 'setup'],
  timeout: 30 * 1000,
  expect: {timeout: 30 * 1000},

  /* Retry on CI only */
  retries: process.env['CI'] ? 1 : 1,
  workers: process.env['CI'] ? 2 : undefined,

  /* Run tests in files in parallel */
  fullyParallel: true,
  use: {
    baseURL: isLocal ? `http://${process.env['LOCALHOST_URL']}` : `https://${process.env['MANAGEMENT_URL']}`,
    // Capture screenshot after each test failure.
    screenshot: 'only-on-failure',

    // Record trace only when retrying a test for the first time.
    trace: 'on-first-retry',

    // Record video only when retrying a test for the first time.
    video: 'on-first-retry',
    testIdAttribute: 'data-testid',
    browserName: 'chromium',
    serviceWorkers: 'block',
    headless: true,
  },
  reporter: [
    ['list'],
    ['json', {outputFile: 'test-results.json'}],
    ['allure-playwright', {outputDir: 'allure-results'}],
  ],

Expected The report published in Github pages contains the video

Actual Only locally generated Allure report contains the video

borecz avatar Jun 02 '23 10:06 borecz