Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use microsoft playwright image in e2e tests #9741

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ jobs:
- name: Build dummy test_data and static_assets images
run: |
echo -e "FROM scratch" > Dockerfile.empty
docker build -t test_data -f Dockerfile.empty .
docker build -t static_assets -f Dockerfile.empty .
docker build -t test_data - <Dockerfile.empty
docker build -t static_assets - <Dockerfile.empty
docker build -t front_tests:latest - <Dockerfile.empty

- name: Find and check all Dockerfiles using docker build --check
run: |
Expand Down Expand Up @@ -1054,6 +1055,24 @@ jobs:
docker load --input ./osrd-front-nginx.tar
docker load --input ./osrd-osrdyne.tar

- name: Detect Playwright version
id: detect_playwright_version
run: |
PLAYWRIGHT_VERSION=$(cd front && yarn list --pattern playwright --json | jq -r '.data.trees[].name | split("@")[-1]' | sort -u)
if [ "$(echo "$PLAYWRIGHT_VERSION" | wc -l)" -ne 1 ]; then
echo "Error: Zero or multiple playwright versions found: $PLAYWRIGHT_VERSION" >&2
exit 1
fi
echo "Detected Playwright version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV

- name: Build Playwright container
run: |
docker build --build-arg PLAYWRIGHT_VERSION=v$PLAYWRIGHT_VERSION \
--build-arg FRONT_TESTS_IMAGE=${{ fromJSON(needs.build.outputs.stable_tags).front-tests }} \
-t osrd-playwright:latest \
- <docker/Dockerfile.playwright-ci

- name: Startup the test infrastructure
id: start_playwright_worker
run: |
Expand All @@ -1077,10 +1096,9 @@ jobs:
run: |
docker run --init --name=playwright-test --net=host \
-e CI=true \
-v $PWD/front/test-results:/app/test-results \
${{ fromJSON(needs.build.outputs.stable_tags).front-tests }} \
/bin/sh -c "npx playwright install --with-deps && yarn e2e-tests"

--ipc=host \
-v "$PWD/front/test-results:/app/front/test-results" \
osrd-playwright:latest yarn playwright test
exit $(docker wait playwright-test)

- uses: actions/upload-artifact@v4
Expand Down
9 changes: 9 additions & 0 deletions docker/Dockerfile.playwright-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG PLAYWRIGHT_VERSION=latest
ARG FRONT_TESTS_IMAGE=front_tests:latest

FROM $FRONT_TESTS_IMAGE AS front-tests

FROM mcr.microsoft.com/playwright:$PLAYWRIGHT_VERSION
COPY --from=front-tests /app /app/front
COPY --from=front-tests /tests /app/tests
WORKDIR /app/front
Loading