Make playwright run faster (#2737)

This commit is contained in:
Cesar Celis Hernandez
2023-04-25 10:19:00 -06:00
committed by GitHub
parent 1477def4fe
commit 6020590b2f
12 changed files with 141 additions and 36 deletions

View File

@@ -1308,9 +1308,92 @@ jobs:
exit 1
fi
ui-assets-istanbul-coverage:
name: "Assets with Istanbul Plugin for coverage"
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.19.x]
os: [ubuntu-latest]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Read .nvmrc
id: node_version
run: echo "$(cat .nvmrc)" && echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_ENV
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NVMRC }}
cache: "yarn"
cache-dependency-path: portal-ui/yarn.lock
- uses: actions/cache@v3
id: assets-cache-istanbul-coverage
name: Assets Cache Istanbul Coverage
with:
path: |
./portal-ui/build/
key: ${{ runner.os }}-assets-istanbul-coverage-${{ github.run_id }}
- name: Install Dependencies
working-directory: ./portal-ui
continue-on-error: false
run: |
yarn install --frozen-lockfile --immutable
- name: Check for Warnings in build output
working-directory: ./portal-ui
continue-on-error: false
run: |
./check-warnings-istanbul-coverage.sh
- name: Check if Files are Prettified
working-directory: ./portal-ui
continue-on-error: false
run: |
./check-prettier.sh
compile-binary-istanbul-coverage:
name: "Compile Console Binary with Istanbul Plugin for Coverage"
needs:
- lint-job
- ui-assets-istanbul-coverage
- reuse-golang-dependencies
- semgrep-static-code-analysis
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.19.x]
os: [ubuntu-latest]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
cache: true
id: go
- uses: actions/cache@v3
name: Console Binary Cache Istanbul Coverage
with:
path: |
./console
key: ${{ runner.os }}-binary-istanbul-coverage-${{ github.run_id }}
- uses: actions/cache@v3
id: assets-cache-istanbul-coverage
name: Assets Cache Istanbul Coverage
with:
path: |
./portal-ui/build/
key: ${{ runner.os }}-assets-istanbul-coverage-${{ github.run_id }}
- name: Build on ${{ matrix.os }}
env:
GO111MODULE: on
GOOS: linux
run: |
make console
playwright:
needs:
- compile-binary
- compile-binary-istanbul-coverage
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
@@ -1337,21 +1420,16 @@ jobs:
run: npx playwright install --with-deps
- uses: actions/cache@v3
name: Console Binary Cache
name: Console Binary Cache Istanbul Coverage
with:
path: |
./console
key: ${{ runner.os }}-binary-${{ github.run_id }}
key: ${{ runner.os }}-binary-istanbul-coverage-${{ github.run_id }}
- name: Start Console, front-end app and initialize users/policies
run: |
(./console server) & (make initialize-permissions)
- name: Start Browser at port 5005
run: |
echo "yarn playwright"
(cd $GITHUB_WORKSPACE/portal-ui; yarn playwright) & (sleep 120) # To start port 5005 with Istanbul Plugin Injected
- name: Run Playwright tests
run: |
echo "Run tests under playwright folder only"

View File

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

View File

@@ -0,0 +1,19 @@
#!/bin/bash
yell() { echo "$0: $*" >&2; }
die() {
yell "$*"
cat yarn.log
exit 111
}
try() { "$@" &> yarn.log || die "cannot $*"; }
rm -f yarn.log
try make build-static-istanbul-coverage
if cat yarn.log | grep "Compiled with warnings"; then
echo "There are warnings in the code"
exit 1
fi

View File

@@ -15,10 +15,11 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import { test as setup } from "@playwright/test";
import { minioadminFile } from "./consts";
import { pagePort } from "./consts";
setup("authenticate as admin", async ({ page }) => {
// Perform authentication steps. Replace these actions with your own.
await page.goto("http://localhost:5005");
await page.goto(pagePort);
await page.getByPlaceholder("Username").click();
await page.getByPlaceholder("Username").fill("minioadmin");
await page.getByPlaceholder("Password").click();

View File

@@ -16,11 +16,12 @@
import { expect } from "@playwright/test";
import { generateUUID, test } from "./fixtures/baseFixture";
import { minioadminFile } from "./consts";
import { pagePort } from "./consts";
test.use({ storageState: minioadminFile });
test.beforeEach(async ({ page }) => {
await page.goto("http://localhost:5005/");
await page.goto(pagePort);
});
test("create a new bucket", async ({ page }) => {

View File

@@ -15,3 +15,4 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
export const minioadminFile = "playwright/.auth/admin.json";
export const pagePort = "http://localhost:9090/buckets";

View File

@@ -17,11 +17,12 @@
import { expect } from "@playwright/test";
import { generateUUID, test } from "./fixtures/baseFixture";
import { minioadminFile } from "./consts";
import { pagePort } from "./consts";
test.use({ storageState: minioadminFile });
test.beforeEach(async ({ page }) => {
await page.goto("http://localhost:5005/");
await page.goto(pagePort);
});
test("Add a new group", async ({ page }) => {

View File

@@ -17,11 +17,12 @@
import { expect } from "@playwright/test";
import { test } from "./fixtures/baseFixture";
import { minioadminFile } from "./consts";
import { pagePort } from "./consts";
test.use({ storageState: minioadminFile });
test.beforeEach(async ({ page }) => {
await page.goto("http://localhost:5005/buckets");
await page.goto(pagePort);
});
test("Test if Object Version selector is present in Lifecycle rule modal", async ({

View File

@@ -1,7 +1,8 @@
import { test, expect } from "@playwright/test";
import { pagePort } from "./consts";
test("Basic `minioadmin` Login", async ({ page, context }) => {
await page.goto("http://localhost:5005");
await page.goto(pagePort);
await page.getByPlaceholder("Username").click();
await page.getByPlaceholder("Username").fill("minioadmin");
await page.getByPlaceholder("Password").click();

View File

@@ -16,11 +16,12 @@
import { expect } from "@playwright/test";
import { generateUUID, test } from "./fixtures/baseFixture";
import { minioadminFile } from "./consts";
import { pagePort } from "./consts";
test.use({ storageState: minioadminFile });
test.beforeEach(async ({ page }) => {
await page.goto("http://localhost:5005/");
await page.goto(pagePort);
});
test("Can create a policy", async ({ page }) => {

View File

@@ -39,6 +39,7 @@
"scripts": {
"start": "PORT=5005 react-scripts start",
"build": "react-scripts build",
"buildistanbulcoverage": "PORT=9090 USE_BABEL_PLUGIN_ISTANBUL=1 react-app-rewired build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"playwright": "PORT=5005 USE_BABEL_PLUGIN_ISTANBUL=1 react-app-rewired start"

View File

@@ -40,8 +40,8 @@ jobs:
run: |
make verifiers
ui-assets:
name: "React Code Has No Warnings & Prettified"
ui-assets-istanbul-coverage:
name: "Assets with Istanbul Plugin for coverage"
runs-on: ubuntu-latest
strategy:
matrix:
@@ -59,12 +59,12 @@ jobs:
cache: "yarn"
cache-dependency-path: portal-ui/yarn.lock
- uses: actions/cache@v3
id: assets-cache
name: Assets Cache
id: assets-cache-istanbul-coverage
name: Assets Cache Istanbul Coverage
with:
path: |
./portal-ui/build/
key: ${{ runner.os }}-assets-${{ github.run_id }}
key: ${{ runner.os }}-assets-istanbul-coverage-${{ github.run_id }}
- name: Install Dependencies
working-directory: ./portal-ui
continue-on-error: false
@@ -74,7 +74,7 @@ jobs:
working-directory: ./portal-ui
continue-on-error: false
run: |
./check-warnings.sh
./check-warnings-istanbul-coverage.sh
- name: Check if Files are Prettified
working-directory: ./portal-ui
continue-on-error: false
@@ -122,11 +122,11 @@ jobs:
pip3 install semgrep
semgrep --config semgrep.yaml $(pwd)/portal-ui --error
compile-binary:
name: Compiles on Go ${{ matrix.go-version }} and ${{ matrix.os }}
compile-binary-istanbul-coverage:
name: "Compile Console Binary with Istanbul Plugin for Coverage"
needs:
- lint-job
- ui-assets
- ui-assets-istanbul-coverage
- reuse-golang-dependencies
- semgrep-static-code-analysis
runs-on: ${{ matrix.os }}
@@ -145,18 +145,18 @@ jobs:
cache: true
id: go
- uses: actions/cache@v3
name: Console Binary Cache
name: Console Binary Cache Istanbul Coverage
with:
path: |
./console
key: ${{ runner.os }}-binary-${{ github.run_id }}
key: ${{ runner.os }}-binary-istanbul-coverage-${{ github.run_id }}
- uses: actions/cache@v3
id: assets-cache
name: Assets Cache
id: assets-cache-istanbul-coverage
name: Assets Cache Istanbul Coverage
with:
path: |
./portal-ui/build/
key: ${{ runner.os }}-assets-${{ github.run_id }}
key: ${{ runner.os }}-assets-istanbul-coverage-${{ github.run_id }}
- name: Build on ${{ matrix.os }}
env:
GO111MODULE: on
@@ -166,7 +166,7 @@ jobs:
playwright:
needs:
- compile-binary
- compile-binary-istanbul-coverage
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
@@ -193,21 +193,16 @@ jobs:
run: npx playwright install --with-deps
- uses: actions/cache@v3
name: Console Binary Cache
name: Console Binary Cache Istanbul Coverage
with:
path: |
./console
key: ${{ runner.os }}-binary-${{ github.run_id }}
key: ${{ runner.os }}-binary-istanbul-coverage-${{ github.run_id }}
- name: Start Console, front-end app and initialize users/policies
run: |
(./console server) & (make initialize-permissions)
- name: Start Browser at port 5005
run: |
echo "yarn playwright"
(cd $GITHUB_WORKSPACE/portal-ui; yarn playwright) & (sleep 120) # To start port 5005 with Istanbul Plugin Injected
- name: Run Playwright tests
run: |
echo "Run tests under playwright folder only"