Skip to content

Commit 87a81c9

Browse files
committed
Try to enable coverage in playwright testing
1 parent d190674 commit 87a81c9

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

.github/workflows/test.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,49 @@ jobs:
7070
steps:
7171
- uses: actions/checkout@v5
7272
- name: Build test image
73-
id: docker-build-test
73+
id: docker-build-playwright
7474
uses: docker/build-push-action@v6
7575
with:
76-
target: server
76+
target: playwright
7777
push: false
7878
load: true
79-
- name: Run Perl tests
79+
- name: Start playwright server
80+
id: start-container
8081
run: >
81-
docker run -d -i -p 5001:8000
82-
${{ steps.docker-build-test.outputs.imageid }}
82+
CONTAINER_ID=$(docker run -d -i -p 8000:80
83+
-v $(pwd):/app
84+
${{ steps.docker-build-playwright.outputs.imageid }})
85+
&& echo "container_id=$CONTAINER_ID" >> $GITHUB_OUTPUT
86+
|| (echo "Failed to start container" && exit 1)
8387
- uses: actions/setup-node@v5
8488
with:
8589
node-version: 22
8690
- name: Install Playwright Browsers
8791
run: ./bin/install-playwright
92+
- name: Install Codecovbash
93+
uses: perl-actions/install-with-cpm@v1
94+
with:
95+
install: |
96+
Devel::Cover
97+
Devel::Cover::Report::Codecovbash
98+
sudo: true
99+
- name: Check docker status
100+
id: playwright-tests
101+
run: |
102+
npx playwright test || {
103+
echo "Playwright tests failed"
104+
docker logs ${{ steps.start-container.outputs.container_id }}
105+
exit 1
106+
}
88107
- name: Run Playwright tests
89108
run: npx playwright test
109+
- name: Generate Codecov report
110+
run: cover -report codecovbash
111+
- uses: codecov/codecov-action@v5
112+
with:
113+
fail_ci_if_error: true
114+
file: ./cover_db/codecov.json
115+
token: ${{ secrets.CODECOV_TOKEN }}
90116
test:
91117
runs-on: ubuntu-24.04
92118
name: Dockerless

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,18 @@ CMD [ "prove", "-l", "-r", "-j", "2", "t" ]
153153
FROM server AS production
154154

155155
USER metacpan
156+
157+
################### Playwright Server
158+
FROM server AS playwright
159+
USER root
160+
161+
RUN echo "Starting Playwright stage setup"
162+
RUN --mount=type=cache,target=/root/.perl-cpm,sharing=private \
163+
<<EOT
164+
cpm install --show-build-log-on-failure Devel::Cover \
165+
EOT
166+
167+
ENV HARNESS_ACTIVE=1
168+
ENV PERL5OPT='-MDevel::Cover=+ignore,^local/|^templates/|^t/|yaml$'
169+
170+
USER metacpan

0 commit comments

Comments
 (0)