test_docker: align container launch with playwright-browsers #877
Workflow file for this run
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: Docker | |
| on: | |
| workflow_dispatch: | |
| push: | |
| paths: | |
| - '.github/workflows/test_docker.yml' | |
| - '**/Dockerfile*' | |
| branches: | |
| - main | |
| - release-* | |
| pull_request: | |
| paths: | |
| - .github/workflows/test_docker.yml | |
| - '**/Dockerfile*' | |
| - scripts/DRIVER_VERSION | |
| - '**/pom.xml' | |
| branches: | |
| - main | |
| - release-* | |
| jobs: | |
| test: | |
| name: Test | |
| timeout-minutes: 120 | |
| runs-on: ${{ matrix.runs-on }} | |
| env: | |
| PW_MAX_RETRIES: 3 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| flavor: [jammy, noble] | |
| runs-on: [ubuntu-24.04, ubuntu-24.04-arm] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build Docker image | |
| run: | | |
| ARCH="${{ matrix.runs-on == 'ubuntu-24.04-arm' && 'arm64' || 'amd64' }}" | |
| bash utils/docker/build.sh --$ARCH ${{ matrix.flavor }} playwright-java:localbuild-${{ matrix.flavor }} | |
| - name: Start container | |
| run: | | |
| ARCH="${{ matrix.runs-on == 'ubuntu-24.04-arm' && 'arm64' || 'amd64' }}" | |
| CONTAINER_ID=$(docker run \ | |
| --rm \ | |
| --name playwright-docker-test \ | |
| --platform linux/$ARCH \ | |
| --user=pwuser \ | |
| --workdir /home/pwuser \ | |
| -e CI \ | |
| -e PW_MAX_RETRIES \ | |
| -d -t \ | |
| playwright-java:localbuild-${{ matrix.flavor }} /bin/bash) | |
| echo "CONTAINER_ID=$CONTAINER_ID" >> $GITHUB_ENV | |
| - name: Copy repository inside docker container | |
| run: | | |
| docker cp . "$CONTAINER_ID":/home/pwuser/playwright | |
| docker exec --user root "$CONTAINER_ID" chown -R pwuser /home/pwuser/playwright | |
| # Maven cache populated during image build lives in /root/.m2; make it | |
| # accessible to pwuser so the suite doesn't have to redownload everything | |
| # and so the locally-installed playwright-java SNAPSHOT artifacts are visible. | |
| docker exec --user root "$CONTAINER_ID" cp -R /root/.m2 /home/pwuser/.m2 | |
| docker exec --user root "$CONTAINER_ID" chown -R pwuser /home/pwuser/.m2 | |
| - name: Run test in container | |
| run: | | |
| docker exec "$CONTAINER_ID" /home/pwuser/playwright/tools/test-local-installation/create_project_and_run_tests.sh | |
| - name: Test ClassLoader | |
| run: | | |
| docker exec "${CONTAINER_ID}" /home/pwuser/playwright/tools/test-spring-boot-starter/package_and_run_async_test.sh | |
| - name: Stop container | |
| run: | | |
| docker stop "$CONTAINER_ID" |