Merge pull request #5225 from jay-hodgson/SWC-6606 #94
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: 'Build/Run End-to-End Tests' | |
on: push | |
env: | |
BUILD_ARTIFACT_NAME: swc-war | |
BUILD_DIR: target | |
BUILD_NAME: portal-develop-SNAPSHOT.war | |
NODE_VERSION: 18.16.0 | |
PW_ALL_BLOBS_DIR: all-blob-reports | |
jobs: | |
build: | |
# Run in Sage repo on develop or release- branches | |
# and on all branches in user-owned forks | |
if: ${{ github.ref_name == 'develop' || startsWith(github.ref_name, 'release-') || github.actor == github.repository_owner }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build SWC | |
uses: ./.github/workflows/build | |
- name: Upload build to GitHub Actions Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.BUILD_ARTIFACT_NAME }} | |
path: '${{ env.BUILD_DIR }}/${{ env.BUILD_NAME }}' | |
retention-days: 1 | |
playwright-tests: | |
needs: [build] | |
runs-on: ${{ github.repository_owner == 'Sage-Bionetworks' && 'ubuntu-22.04-4core-16GBRAM-150GBSSD' || 'macos-latest' }} | |
timeout-minutes: 60 | |
strategy: | |
fail-fast: false | |
matrix: | |
shard: [1/3, 2/3, 3/3] | |
env: | |
CONTAINER_NAME: 'swc-tomcat' | |
CI: true | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup docker (missing on MacOS) | |
if: runner.os == 'macos' | |
run: | | |
brew install docker | |
colima start | |
- name: Download build from GitHub Actions Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.BUILD_ARTIFACT_NAME }} | |
path: ${{ env.BUILD_DIR }} | |
- name: Run SWC on Tomcat | |
run: | | |
docker run \ | |
--name "${{ env.CONTAINER_NAME }}" \ | |
-d --rm \ | |
-p 8888:8080 \ | |
-v "/$(pwd)/${{ env.BUILD_DIR }}/${{ env.BUILD_NAME }}:/usr/local/tomcat/webapps/ROOT.war" \ | |
-v "/$(pwd)/e2e_workflow/settings.xml":/root/.m2/settings.xml \ | |
tomcat:9.0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Install Playwright Browsers | |
run: yarn playwright install --with-deps | |
- name: Run Playwright tests | |
env: | |
ADMIN_PAT: ${{ secrets.ADMIN_PAT }} | |
run: yarn playwright test --shard ${{ matrix.shard }} | |
- name: Upload blob report to GitHub Actions Artifacts | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: ${{ env.PW_ALL_BLOBS_DIR }} | |
path: blob-report | |
retention-days: 1 | |
- name: Stop Tomcat | |
if: always() | |
run: docker stop "${{ env.CONTAINER_NAME }}" | |
- name: Stop Colima | |
if: runner.os == 'macos' | |
run: colima stop | |
merge-reports: | |
# Merge reports after playwright-tests, even if some shards have failed | |
# But skip this job if the previous job was cancelled | |
if: ${{ !cancelled() }} | |
needs: [playwright-tests] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Download blob reports from GitHub Actions Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.PW_ALL_BLOBS_DIR }} | |
path: ${{ env.PW_ALL_BLOBS_DIR }} | |
- name: Merge into HTML Report | |
run: yarn playwright merge-reports --reporter html ./"${{ env.PW_ALL_BLOBS_DIR }}" | |
- name: Upload HTML report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: html-report--attempt-${{ github.run_attempt }} | |
path: playwright-report | |
retention-days: 14 |