Skip to content

Commit e55c298

Browse files
committed
Make playwright run faster by using port 9090 on compiled binary and avoiding to run on port 5005 that can be skipped if we incorporate istanbul plugin on the assets since the start and then coverage can be obtained from port 9090 instead saving time.
1 parent 056d487 commit e55c298

File tree

11 files changed

+134
-36
lines changed

11 files changed

+134
-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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { minioadminFile } from "./consts";
1818

1919
setup("authenticate as admin", async ({ page }) => {
2020
// Perform authentication steps. Replace these actions with your own.
21-
await page.goto("http://localhost:5005");
21+
await page.goto("http://localhost:9090");
2222
await page.getByPlaceholder("Username").click();
2323
await page.getByPlaceholder("Username").fill("minioadmin");
2424
await page.getByPlaceholder("Password").click();

portal-ui/e2e/buckets.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { minioadminFile } from "./consts";
2020
test.use({ storageState: minioadminFile });
2121

2222
test.beforeEach(async ({ page }) => {
23-
await page.goto("http://localhost:5005/");
23+
await page.goto("http://localhost:9090/");
2424
});
2525

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

portal-ui/e2e/groups.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { minioadminFile } from "./consts";
2121
test.use({ storageState: minioadminFile });
2222

2323
test.beforeEach(async ({ page }) => {
24-
await page.goto("http://localhost:5005/");
24+
await page.goto("http://localhost:9090/");
2525
});
2626

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

portal-ui/e2e/lifecycle.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { minioadminFile } from "./consts";
2121
test.use({ storageState: minioadminFile });
2222

2323
test.beforeEach(async ({ page }) => {
24-
await page.goto("http://localhost:5005/buckets");
24+
await page.goto("http://localhost:9090/buckets");
2525
});
2626

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

portal-ui/e2e/login.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test, expect } from "@playwright/test";
22

33
test("Basic `minioadmin` Login", async ({ page, context }) => {
4-
await page.goto("http://localhost:5005");
4+
await page.goto("http://localhost:9090");
55
await page.getByPlaceholder("Username").click();
66
await page.getByPlaceholder("Username").fill("minioadmin");
77
await page.getByPlaceholder("Password").click();

portal-ui/e2e/policies.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { minioadminFile } from "./consts";
2020
test.use({ storageState: minioadminFile });
2121

2222
test.beforeEach(async ({ page }) => {
23-
await page.goto("http://localhost:5005/");
23+
await page.goto("http://localhost:9090/");
2424
});
2525

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

portal-ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"scripts": {
4040
"start": "PORT=5005 react-scripts start",
4141
"build": "react-scripts build",
42+
"buildistanbulcoverage": "PORT=9090 USE_BABEL_PLUGIN_ISTANBUL=1 react-app-rewired build",
4243
"test": "react-scripts test",
4344
"eject": "react-scripts eject",
4445
"playwright": "PORT=5005 USE_BABEL_PLUGIN_ISTANBUL=1 react-app-rewired start"

0 commit comments

Comments
 (0)