Skip to content

Commit ee266a0

Browse files
Merge pull request #640 from gemini-testing/TRIVIAL.use_gh_ci
chore: use github ci
2 parents 2e235bb + 82abec3 commit ee266a0

File tree

36 files changed

+373
-172
lines changed

36 files changed

+373
-172
lines changed

.github/workflows/e2e.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Testplane E2E
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
testplane-e2e:
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
env:
18+
DOCKER_IMAGE_NAME: html-reporter-browsers
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Use Node.js 20
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Build the package
33+
run: npm run build
34+
35+
- name: 'Prepare e2e tests: Install pwt-chromium'
36+
run: npx playwright install chromium
37+
38+
- name: 'Prepare e2e tests: Build-packages'
39+
run: npm run e2e:build-packages
40+
41+
- name: 'Prepare e2e tests: Cache browser docker image'
42+
uses: actions/cache@v3
43+
with:
44+
path: ~/.docker/cache
45+
key: docker-browser-image-${{ hashFiles('test/func/docker/Dockerfile') }}
46+
47+
- name: 'Prepare e2e tests: Pull browser docker image'
48+
run: |
49+
mkdir -p ~/.docker/cache
50+
if [ -f ~/.docker/cache/image.tar ]; then
51+
docker load -i ~/.docker/cache/image.tar
52+
else
53+
docker pull yinfra/html-reporter-browsers
54+
docker save yinfra/html-reporter-browsers -o ~/.docker/cache/image.tar
55+
fi
56+
57+
- name: 'Prepare e2e tests: Run browser docker image'
58+
run: docker run -d --name ${{ env.DOCKER_IMAGE_NAME }} -it --rm --network=host $(which colima >/dev/null || echo --add-host=host.docker.internal:0.0.0.0) yinfra/html-reporter-browsers
59+
60+
- name: 'Prepare e2e tests: Generate fixtures'
61+
run: npm run e2e:generate-fixtures || true
62+
63+
- name: 'Prepare e2e tests: Setup env'
64+
run: |
65+
REPORT_PREFIX=testplane-reports
66+
REPORT_DATE=$(date '+%y-%m-%d')
67+
echo "DEST_REPORTS_DIR=$REPORT_PREFIX/$REPORT_DATE/${{ github.run_id }}/${{ github.run_attempt }}" >> $GITHUB_ENV
68+
69+
- name: Upload fixtures reports
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: testplane-fixtures
73+
path: test/func/fixtures/*/report
74+
75+
- name: 'e2e: Run Testplane'
76+
id: 'testplane'
77+
continue-on-error: true
78+
working-directory: 'test/func/tests'
79+
run: npm run test
80+
81+
- name: 'e2e: Stop browser docker image'
82+
run: |
83+
docker kill ${{ env.DOCKER_IMAGE_NAME }} || true
84+
docker rm ${{ env.DOCKER_IMAGE_NAME }} || true
85+
86+
- name: Merge Testplane html-reporter reports
87+
working-directory: 'test/func/tests'
88+
run: |
89+
mkdir -p ../../../${{ env.DEST_REPORTS_DIR }}
90+
npx testplane merge-reports reports/*/sqlite.db -d ../../../${{ env.DEST_REPORTS_DIR }}
91+
92+
- name: Deploy Testplane html-reporter reports
93+
uses: peaceiris/actions-gh-pages@v4
94+
with:
95+
github_token: ${{ secrets.GITHUB_TOKEN }}
96+
publish_dir: ${{ env.DEST_REPORTS_DIR }}
97+
destination_dir: ${{ env.DEST_REPORTS_DIR }}
98+
keep_files: true
99+
100+
- name: Construct PR comment
101+
run: |
102+
link="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ env.DEST_REPORTS_DIR }}"
103+
if [ "${{ steps.testplane.outcome }}" != "success" ]; then
104+
comment="### ❌ Testplane run failed<br><br>[Report](${link})"
105+
echo "PR_COMMENT=${comment}" >> $GITHUB_ENV
106+
else
107+
comment="### ✅ Testplane run succeed<br><br>[Report](${link})"
108+
echo "PR_COMMENT=${comment}" >> $GITHUB_ENV
109+
fi
110+
111+
- name: Leave comment to PR with link to Testplane HTML reports
112+
uses: thollander/actions-comment-pull-request@v3
113+
with:
114+
message: ${{ env.PR_COMMENT }}
115+
comment-tag: testplane_results
116+
117+
- name: Fail the job if any Testplane job is failed
118+
if: ${{ steps.testplane.outcome != 'success' }}
119+
run: exit 1

package-lock.json

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/func/fixtures/playwright/tests/failed-describe.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test.describe('failed describe', () => {
3838
test('test with successful assertView and error', async ({page, baseURL}) => {
3939
await page.goto(baseURL as string);
4040

41-
await expect(page.locator('header')).toHaveScreenshot('header-success.png');
41+
await expect(page.locator('header')).toHaveScreenshot('header-success.png', {maxDiffPixelRatio: 1});
4242

4343
throw new Error('Some error');
4444
});
0 Bytes
Loading

test/func/fixtures/plugins/success-describe.testplane.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ describe('success describe', function() {
88
it('test with screenshot', async ({browser}) => {
99
await browser.url(browser.options.baseUrl);
1010

11-
await browser.assertView('header', 'header');
11+
await browser.assertView('header', 'header', {ignoreDiffPixelCount: '100%'});
1212
});
1313
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
const _ = require('lodash');
4+
5+
const {getFixturesConfig} = require('../fixtures.testplane.conf');
6+
7+
module.exports = _.merge(getFixturesConfig(__dirname), {});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en" dir="ltr">
3+
<head>
4+
<meta charset="utf-8">
5+
<title></title>
6+
</head>
7+
<body>
8+
<p id="paragraph-1">Hello, world!</p>
9+
<p id="paragraph-2">Another line...</p>
10+
<p id="paragraph-3">The third line.</p>
11+
</body>
12+
</html>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "testplane-tinder",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"clean": "rm -rf report",
7+
"generate": "npx testplane --grep 'tests to run'",
8+
"gui": "npx testplane gui --hostname 0.0.0.0 --port $(../../utils/get-port.js testplane-tinder gui)"
9+
}
10+
}
1.41 KB
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
describe('tests to run', () => {
2+
it('test with image comparison diff', async ({browser}) => {
3+
await browser.url(browser.options.baseUrl);
4+
5+
await browser.assertView('paragraph', '#paragraph-1');
6+
});
7+
8+
it('test with no reference image', async ({browser}) => {
9+
await browser.url(browser.options.baseUrl);
10+
11+
await browser.assertView('paragraph', '#paragraph-3');
12+
});
13+
});
14+
15+
describe('tests not to run', () => {
16+
it('successful test', async ({browser}) => {
17+
await browser.url(browser.options.baseUrl);
18+
19+
assert.isTrue(true);
20+
});
21+
});

0 commit comments

Comments
 (0)