Skip to content

Commit 6020590

Browse files
authored
Make playwright run faster (#2737)
1 parent 1477def commit 6020590

File tree

12 files changed

+141
-36
lines changed

12 files changed

+141
-36
lines changed

.github/workflows/jobs.yaml

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,9 +1308,92 @@ jobs:
13081308
exit 1
13091309
fi
13101310
1311+
ui-assets-istanbul-coverage:
1312+
name: "Assets with Istanbul Plugin for coverage"
1313+
runs-on: ubuntu-latest
1314+
strategy:
1315+
matrix:
1316+
go-version: [1.19.x]
1317+
os: [ubuntu-latest]
1318+
steps:
1319+
- name: Check out code
1320+
uses: actions/checkout@v3
1321+
- name: Read .nvmrc
1322+
id: node_version
1323+
run: echo "$(cat .nvmrc)" && echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_ENV
1324+
- uses: actions/setup-node@v3
1325+
with:
1326+
node-version: ${{ env.NVMRC }}
1327+
cache: "yarn"
1328+
cache-dependency-path: portal-ui/yarn.lock
1329+
- uses: actions/cache@v3
1330+
id: assets-cache-istanbul-coverage
1331+
name: Assets Cache Istanbul Coverage
1332+
with:
1333+
path: |
1334+
./portal-ui/build/
1335+
key: ${{ runner.os }}-assets-istanbul-coverage-${{ github.run_id }}
1336+
- name: Install Dependencies
1337+
working-directory: ./portal-ui
1338+
continue-on-error: false
1339+
run: |
1340+
yarn install --frozen-lockfile --immutable
1341+
- name: Check for Warnings in build output
1342+
working-directory: ./portal-ui
1343+
continue-on-error: false
1344+
run: |
1345+
./check-warnings-istanbul-coverage.sh
1346+
- name: Check if Files are Prettified
1347+
working-directory: ./portal-ui
1348+
continue-on-error: false
1349+
run: |
1350+
./check-prettier.sh
1351+
1352+
compile-binary-istanbul-coverage:
1353+
name: "Compile Console Binary with Istanbul Plugin for Coverage"
1354+
needs:
1355+
- lint-job
1356+
- ui-assets-istanbul-coverage
1357+
- reuse-golang-dependencies
1358+
- semgrep-static-code-analysis
1359+
runs-on: ${{ matrix.os }}
1360+
strategy:
1361+
matrix:
1362+
go-version: [1.19.x]
1363+
os: [ubuntu-latest]
1364+
steps:
1365+
- name: Check out code
1366+
uses: actions/checkout@v3
1367+
1368+
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
1369+
uses: actions/setup-go@v3
1370+
with:
1371+
go-version: ${{ matrix.go-version }}
1372+
cache: true
1373+
id: go
1374+
- uses: actions/cache@v3
1375+
name: Console Binary Cache Istanbul Coverage
1376+
with:
1377+
path: |
1378+
./console
1379+
key: ${{ runner.os }}-binary-istanbul-coverage-${{ github.run_id }}
1380+
- uses: actions/cache@v3
1381+
id: assets-cache-istanbul-coverage
1382+
name: Assets Cache Istanbul Coverage
1383+
with:
1384+
path: |
1385+
./portal-ui/build/
1386+
key: ${{ runner.os }}-assets-istanbul-coverage-${{ github.run_id }}
1387+
- name: Build on ${{ matrix.os }}
1388+
env:
1389+
GO111MODULE: on
1390+
GOOS: linux
1391+
run: |
1392+
make console
1393+
13111394
playwright:
13121395
needs:
1313-
- compile-binary
1396+
- compile-binary-istanbul-coverage
13141397
timeout-minutes: 60
13151398
runs-on: ubuntu-latest
13161399
steps:
@@ -1337,21 +1420,16 @@ jobs:
13371420
run: npx playwright install --with-deps
13381421

13391422
- uses: actions/cache@v3
1340-
name: Console Binary Cache
1423+
name: Console Binary Cache Istanbul Coverage
13411424
with:
13421425
path: |
13431426
./console
1344-
key: ${{ runner.os }}-binary-${{ github.run_id }}
1427+
key: ${{ runner.os }}-binary-istanbul-coverage-${{ github.run_id }}
13451428

13461429
- name: Start Console, front-end app and initialize users/policies
13471430
run: |
13481431
(./console server) & (make initialize-permissions)
13491432
1350-
- name: Start Browser at port 5005
1351-
run: |
1352-
echo "yarn playwright"
1353-
(cd $GITHUB_WORKSPACE/portal-ui; yarn playwright) & (sleep 120) # To start port 5005 with Istanbul Plugin Injected
1354-
13551433
- name: Run Playwright tests
13561434
run: |
13571435
echo "Run tests under playwright folder only"

portal-ui/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ build-static:
55
@if [ -f "${NVM_DIR}/nvm.sh" ]; then \. "${NVM_DIR}/nvm.sh" && nvm install && nvm use; fi && \
66
NODE_OPTIONS=--openssl-legacy-provider yarn build
77

8+
build-static-istanbul-coverage:
9+
@echo "Building frontend static assets to 'build'"
10+
@if [ -f "${NVM_DIR}/nvm.sh" ]; then \. "${NVM_DIR}/nvm.sh" && nvm install && nvm use; fi && \
11+
NODE_OPTIONS=--openssl-legacy-provider yarn buildistanbulcoverage
12+
813
test-warnings:
914
./check-warnings.sh
1015

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
yell() { echo "$0: $*" >&2; }
4+
5+
die() {
6+
yell "$*"
7+
cat yarn.log
8+
exit 111
9+
}
10+
11+
try() { "$@" &> yarn.log || die "cannot $*"; }
12+
13+
rm -f yarn.log
14+
try make build-static-istanbul-coverage
15+
16+
if cat yarn.log | grep "Compiled with warnings"; then
17+
echo "There are warnings in the code"
18+
exit 1
19+
fi

portal-ui/e2e/auth.setup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
import { test as setup } from "@playwright/test";
1717
import { minioadminFile } from "./consts";
18+
import { pagePort } from "./consts";
1819

1920
setup("authenticate as admin", async ({ page }) => {
2021
// Perform authentication steps. Replace these actions with your own.
21-
await page.goto("http://localhost:5005");
22+
await page.goto(pagePort);
2223
await page.getByPlaceholder("Username").click();
2324
await page.getByPlaceholder("Username").fill("minioadmin");
2425
await page.getByPlaceholder("Password").click();

portal-ui/e2e/buckets.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
import { expect } from "@playwright/test";
1717
import { generateUUID, test } from "./fixtures/baseFixture";
1818
import { minioadminFile } from "./consts";
19+
import { pagePort } from "./consts";
1920

2021
test.use({ storageState: minioadminFile });
2122

2223
test.beforeEach(async ({ page }) => {
23-
await page.goto("http://localhost:5005/");
24+
await page.goto(pagePort);
2425
});
2526

2627
test("create a new bucket", async ({ page }) => {

portal-ui/e2e/consts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
export const minioadminFile = "playwright/.auth/admin.json";
18+
export const pagePort = "http://localhost:9090/buckets";

portal-ui/e2e/groups.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
import { expect } from "@playwright/test";
1818
import { generateUUID, test } from "./fixtures/baseFixture";
1919
import { minioadminFile } from "./consts";
20+
import { pagePort } from "./consts";
2021

2122
test.use({ storageState: minioadminFile });
2223

2324
test.beforeEach(async ({ page }) => {
24-
await page.goto("http://localhost:5005/");
25+
await page.goto(pagePort);
2526
});
2627

2728
test("Add a new group", async ({ page }) => {

portal-ui/e2e/lifecycle.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
import { expect } from "@playwright/test";
1818
import { test } from "./fixtures/baseFixture";
1919
import { minioadminFile } from "./consts";
20+
import { pagePort } from "./consts";
2021

2122
test.use({ storageState: minioadminFile });
2223

2324
test.beforeEach(async ({ page }) => {
24-
await page.goto("http://localhost:5005/buckets");
25+
await page.goto(pagePort);
2526
});
2627

2728
test("Test if Object Version selector is present in Lifecycle rule modal", async ({

portal-ui/e2e/login.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { test, expect } from "@playwright/test";
2+
import { pagePort } from "./consts";
23

34
test("Basic `minioadmin` Login", async ({ page, context }) => {
4-
await page.goto("http://localhost:5005");
5+
await page.goto(pagePort);
56
await page.getByPlaceholder("Username").click();
67
await page.getByPlaceholder("Username").fill("minioadmin");
78
await page.getByPlaceholder("Password").click();

portal-ui/e2e/policies.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
import { expect } from "@playwright/test";
1717
import { generateUUID, test } from "./fixtures/baseFixture";
1818
import { minioadminFile } from "./consts";
19+
import { pagePort } from "./consts";
1920

2021
test.use({ storageState: minioadminFile });
2122

2223
test.beforeEach(async ({ page }) => {
23-
await page.goto("http://localhost:5005/");
24+
await page.goto(pagePort);
2425
});
2526

2627
test("Can create a policy", async ({ page }) => {

0 commit comments

Comments
 (0)