From caf03281ddd609652c1d5336b2246fe7c22ef52f Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Tue, 19 Nov 2024 10:11:33 +0700 Subject: [PATCH] pull playwright tests into a reusable action and call them from both staging and gha integration tests --- .github/actions/playwright-tests/action.yaml | 55 ++++++++++++++++++++ .github/workflows/integration-test-gha.yaml | 51 +++--------------- .github/workflows/integration-test.yaml | 44 ++++------------ 3 files changed, 70 insertions(+), 80 deletions(-) create mode 100644 .github/actions/playwright-tests/action.yaml diff --git a/.github/actions/playwright-tests/action.yaml b/.github/actions/playwright-tests/action.yaml new file mode 100644 index 000000000..c6e460977 --- /dev/null +++ b/.github/actions/playwright-tests/action.yaml @@ -0,0 +1,55 @@ +name: Setup and run playwright tests +inputs: + lexbox-hostname: + description: 'The hostname of the lexbox server, should include port if not 80' + required: true + lexbox-default-password: + description: 'The default password for the lexbox server' + required: true + viewer-tests: + description: 'Whether to run viewer tests' + required: false + default: 'true' + +runs: + using: composite + steps: + # First we need to setup Node... + - uses: actions/setup-node@v4 + with: + node-version-file: 'frontend/package.json' + # Then we can set up pnpm... + - uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0 + with: + package_json_file: 'frontend/package.json' + # Then we can have Node set up package caching + - uses: actions/setup-node@v4 + with: + node-version-file: 'frontend/package.json' + cache: 'pnpm' + cache-dependency-path: 'frontend/pnpm-lock.yaml' + - name: Playwright setup + shell: bash + working-directory: frontend + run: pnpm install + - name: Set up Playwright dependencies + shell: bash + working-directory: frontend + run: pnpm exec playwright install --with-deps + + - name: Integration tests (Playwright) + id: playwright-tests + shell: bash + env: + TEST_SERVER_HOSTNAME: ${{ inputs.lexbox-hostname }} + TEST_DEFAULT_PASSWORD: ${{ inputs.lexbox-default-password }} + working-directory: frontend + run: pnpm run test ${{ inputs.viewer-tests != 'true' && '-g "^(?!.*Viewer Page).*"' || '' }} + + - name: Upload playwright results + if: ${{ always() && steps.playwright-tests.outcome != 'skipped' }} + uses: actions/upload-artifact@v4 + with: + name: playwright-traces + path: | + ./frontend/test-results diff --git a/.github/workflows/integration-test-gha.yaml b/.github/workflows/integration-test-gha.yaml index 9ae9b4718..a604eea41 100644 --- a/.github/workflows/integration-test-gha.yaml +++ b/.github/workflows/integration-test-gha.yaml @@ -93,52 +93,13 @@ jobs: run: dotnet test LexBoxOnly.slnf --logger GitHubActions --filter "Category=Integration|Category=FlakyIntegration" --blame-hang-timeout 40m ##playwright tests - # First we need to setup Node... - - uses: actions/setup-node@v4 - if: always() + - name: Setup and run playwright tests + if: ${{ !cancelled() }} + uses: ./.github/actions/playwright-tests with: - node-version-file: 'frontend/package.json' - # Then we can set up pnpm... - - uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0 - if: always() - with: - package_json_file: 'frontend/package.json' - # Then we can have Node set up package caching - - uses: actions/setup-node@v4 - if: always() - with: - node-version-file: 'frontend/package.json' - cache: 'pnpm' - cache-dependency-path: 'frontend/pnpm-lock.yaml' - - name: Playwright setup - if: always() - working-directory: frontend - run: pnpm install - - name: Set up Playwright dependencies - if: always() - working-directory: frontend - run: pnpm exec playwright install --with-deps - - - name: Integration tests (Playwright) - if: always() - id: playwright-tests - env: - TEST_SERVER_HOSTNAME: 'localhost:6579' - TEST_STANDARD_HG_HOSTNAME: 'hg.localhost:6579' - TEST_RESUMABLE_HG_HOSTNAME: 'resumable.localhost:6579' - TEST_PROJECT_CODE: 'sena-3' - TEST_DEFAULT_PASSWORD: 'pass' - working-directory: frontend - run: pnpm run test -g "^(?!.*Viewer Page).*" # exclude the viewer page tests, because mongo is not available - - - name: Upload playwright results - if: ${{ always() && steps.playwright-tests.outcome != 'skipped' }} - uses: actions/upload-artifact@v4 - with: - name: playwright-traces - path: | - ./frontend/test-results - + lexbox-hostname: 'localhost:6579' + lexbox-default-password: 'pass' + viewer-tests: 'false' # exclude the viewer page tests, because mongo is not available - name: status if: failure() diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 49bd0dd2d..d35311121 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -152,8 +152,6 @@ jobs: runs-on: ${{ inputs.runs-on }} steps: - uses: actions/checkout@v4 - with: - submodules: true - name: Setup self-hosted dependencies if: ${{ inputs.runs-on == 'self-hosted' }} run: | @@ -164,47 +162,23 @@ jobs: sudo apt-get install -f rm powershell_7.4.1-1.deb_amd64.deb pwsh #validate that powershell installed correctly - # First we need to setup Node... - - uses: actions/setup-node@v4 - with: - node-version-file: 'frontend/package.json' - # Then we can set up pnpm... - - uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0 - with: - package_json_file: 'frontend/package.json' - # Then we can have Node set up package caching - - uses: actions/setup-node@v4 - with: - node-version-file: 'frontend/package.json' - cache: 'pnpm' - cache-dependency-path: 'frontend/pnpm-lock.yaml' - - name: Playwright setup - working-directory: frontend - run: pnpm install && pnpm pretest - - name: Set up Playwright dependencies - working-directory: frontend - if: ${{ inputs.runs-on == 'self-hosted' }} - run: sudo pnpm exec playwright install-deps - - name: Integration tests (Playwright) - env: - TEST_SERVER_HOSTNAME: ${{ vars.TEST_SERVER_HOSTNAME }} - # this is not a typo, we need to use the lf domain because it has a cert that hg will validate - TEST_STANDARD_HG_HOSTNAME: ${{ vars.TEST_STANDARD_HG_HOSTNAME }} - TEST_RESUMABLE_HG_HOSTNAME: ${{ vars.TEST_RESUMABLE_HG_HOSTNAME }} - TEST_PROJECT_CODE: 'sena-3' - TEST_DEFAULT_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }} - working-directory: frontend - run: pnpm test + - name: Setup and run playwright tests + if: ${{ !cancelled() }} + uses: ./.github/actions/playwright-tests + with: + lexbox-hostname: ${{ vars.TEST_SERVER_HOSTNAME }} + lexbox-default-password: ${{ secrets.TEST_USER_PASSWORD }} + viewer-tests: 'true' - name: Password protect Playwright traces id: password_protect_test_results - if: ${{ always() }} + if: ${{ !cancelled() }} shell: bash env: ZIP_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }} run: 7z a ./playwright-traces.7z -mx=0 -mmt=off ./frontend/test-results -p"$ZIP_PASSWORD" - name: Upload playwright results - if: ${{ always() && steps.password_protect_test_results.outcome == 'success' }} + if: ${{ !cancelled() && steps.password_protect_test_results.outcome == 'success' }} uses: actions/upload-artifact@v4 with: name: playwright-traces-${{ inputs.runs-on }}-hg-${{ inputs.hg-version }}