Skip to content

Commit 9f43602

Browse files
cniackzMinIO Bot
authored andcommitted
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 60d70e3 commit 9f43602

File tree

10 files changed

+133
-35
lines changed

10 files changed

+133
-35
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/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
@@ -40,6 +40,7 @@
4040
"scripts": {
4141
"start": "PORT=5005 react-scripts start",
4242
"build": "react-scripts build",
43+
"buildistanbulcoverage": "PORT=9090 USE_BABEL_PLUGIN_ISTANBUL=1 react-app-rewired build",
4344
"test": "react-scripts test",
4445
"eject": "react-scripts eject",
4546
"playwright": "PORT=5005 USE_BABEL_PLUGIN_ISTANBUL=1 react-app-rewired start"

portal-ui/playwright/jobs.yaml

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ jobs:
4040
run: |
4141
make verifiers
4242
43-
ui-assets:
44-
name: "React Code Has No Warnings & Prettified"
43+
ui-assets-istanbul-coverage:
44+
name: "Assets with Istanbul Plugin for coverage"
4545
runs-on: ubuntu-latest
4646
strategy:
4747
matrix:
@@ -59,12 +59,12 @@ jobs:
5959
cache: "yarn"
6060
cache-dependency-path: portal-ui/yarn.lock
6161
- uses: actions/cache@v3
62-
id: assets-cache
63-
name: Assets Cache
62+
id: assets-cache-istanbul-coverage
63+
name: Assets Cache Istanbul Coverage
6464
with:
6565
path: |
6666
./portal-ui/build/
67-
key: ${{ runner.os }}-assets-${{ github.run_id }}
67+
key: ${{ runner.os }}-assets-istanbul-coverage-${{ github.run_id }}
6868
- name: Install Dependencies
6969
working-directory: ./portal-ui
7070
continue-on-error: false
@@ -74,7 +74,7 @@ jobs:
7474
working-directory: ./portal-ui
7575
continue-on-error: false
7676
run: |
77-
./check-warnings.sh
77+
./check-warnings-istanbul-coverage.sh
7878
- name: Check if Files are Prettified
7979
working-directory: ./portal-ui
8080
continue-on-error: false
@@ -122,11 +122,11 @@ jobs:
122122
pip3 install semgrep
123123
semgrep --config semgrep.yaml $(pwd)/portal-ui --error
124124
125-
compile-binary:
126-
name: Compiles on Go ${{ matrix.go-version }} and ${{ matrix.os }}
125+
compile-binary-istanbul-coverage:
126+
name: "Compile Console Binary with Istanbul Plugin for Coverage"
127127
needs:
128128
- lint-job
129-
- ui-assets
129+
- ui-assets-istanbul-coverage
130130
- reuse-golang-dependencies
131131
- semgrep-static-code-analysis
132132
runs-on: ${{ matrix.os }}
@@ -145,18 +145,18 @@ jobs:
145145
cache: true
146146
id: go
147147
- uses: actions/cache@v3
148-
name: Console Binary Cache
148+
name: Console Binary Cache Istanbul Coverage
149149
with:
150150
path: |
151151
./console
152-
key: ${{ runner.os }}-binary-${{ github.run_id }}
152+
key: ${{ runner.os }}-binary-istanbul-coverage-${{ github.run_id }}
153153
- uses: actions/cache@v3
154-
id: assets-cache
155-
name: Assets Cache
154+
id: assets-cache-istanbul-coverage
155+
name: Assets Cache Istanbul Coverage
156156
with:
157157
path: |
158158
./portal-ui/build/
159-
key: ${{ runner.os }}-assets-${{ github.run_id }}
159+
key: ${{ runner.os }}-assets-istanbul-coverage-${{ github.run_id }}
160160
- name: Build on ${{ matrix.os }}
161161
env:
162162
GO111MODULE: on
@@ -166,7 +166,7 @@ jobs:
166166
167167
playwright:
168168
needs:
169-
- compile-binary
169+
- compile-binary-istanbul-coverage
170170
timeout-minutes: 60
171171
runs-on: ubuntu-latest
172172
steps:
@@ -193,21 +193,16 @@ jobs:
193193
run: npx playwright install --with-deps
194194

195195
- uses: actions/cache@v3
196-
name: Console Binary Cache
196+
name: Console Binary Cache Istanbul Coverage
197197
with:
198198
path: |
199199
./console
200-
key: ${{ runner.os }}-binary-${{ github.run_id }}
200+
key: ${{ runner.os }}-binary-istanbul-coverage-${{ github.run_id }}
201201

202202
- name: Start Console, front-end app and initialize users/policies
203203
run: |
204204
(./console server) & (make initialize-permissions)
205205
206-
- name: Start Browser at port 5005
207-
run: |
208-
echo "yarn playwright"
209-
(cd $GITHUB_WORKSPACE/portal-ui; yarn playwright) & (sleep 120) # To start port 5005 with Istanbul Plugin Injected
210-
211206
- name: Run Playwright tests
212207
run: |
213208
echo "Run tests under playwright folder only"

0 commit comments

Comments
 (0)