1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Split integration tests into seperate jobs from unit tests for faster CI

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-10-03 15:29:13 -04:00
parent 0fe3242030
commit 101e1ec7b6
2 changed files with 80 additions and 21 deletions

View File

@ -7,8 +7,8 @@ on:
branches:
- master
jobs:
build:
name: Test
smoke:
name: Run Smoke Tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@ -62,16 +62,6 @@ jobs:
retry_on: error
command: make -j2 build-extensions
- run: make test
name: Run tests
- run: make test-extensions
name: Run In-tree Extension tests
- run: make ci-validate-dev
if: contains(github.event.pull_request.labels.*.name, 'dependencies')
name: Validate dev mode will work
- name: Install integration test dependencies
id: minikube
uses: medyagh/setup-minikube@master
@ -96,3 +86,57 @@ jobs:
env:
ELECTRON_BUILDER_EXTRA_ARGS: "--x64 --ia32"
if: runner.os == 'Windows'
unit:
name: Run Unit Tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-11, windows-2019]
node-version: [16.x]
steps:
- name: Checkout Release from lens
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
if: runner.os == 'Linux'
run: |
echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
- name: Using Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- uses: nick-fields/retry@v2
name: Install dependencies
with:
timeout_minutes: 10
max_attempts: 3
retry_on: error
command: make node_modules
- run: make test
name: Run tests
- run: make test-extensions
name: Run In-tree Extension tests
- run: make ci-validate-dev
if: contains(github.event.pull_request.labels.*.name, 'dependencies')
name: Validate dev mode will work

View File

@ -10,6 +10,8 @@ import * as uuid from "uuid";
import type { ElectronApplication, Frame, Page } from "playwright";
import { _electron as electron } from "playwright";
import { noop } from "lodash";
import { disposer } from "../../src/common/utils";
import { Writable } from "stream";
export const appPaths: Partial<Record<NodeJS.Platform, string>> = {
"win32": "./dist/win-unpacked/OpenLens.exe",
@ -18,19 +20,32 @@ export const appPaths: Partial<Record<NodeJS.Platform, string>> = {
};
async function getMainWindow(app: ElectronApplication, timeout = 50_000): Promise<Page> {
const deadline = Date.now() + timeout;
return new Promise((resolve, reject) => {
const cleanup = disposer();
const stdoutBuffer = Buffer.from("");
const stdoutStream = new Writable(stdoutBuffer);
for (; Date.now() < deadline;) {
for (const page of app.windows()) {
const handler = (page: Page) => {
if (page.url().startsWith("http://localhost")) {
return page;
cleanup();
resolve(page);
}
}
};
await new Promise(resolve => setTimeout(resolve, 2_000));
}
app.addListener("window", handler);
cleanup.push(() => app.removeListener("window", handler));
throw new Error(`Lens did not open the main window within ${timeout}ms`);
app.process().stdout?.pipe(stdoutStream);
cleanup.push(() => app.process().stdout?.unpipe(stdoutStream));
const timeoutId = setTimeout(() => {
cleanup();
console.log(stdoutBuffer.toString("utf8"));
reject(new Error(`Lens did not open the main window within ${timeout}ms`));
}, timeout);
cleanup.push(() => clearTimeout(timeoutId));
});
}
async function attemptStart() {
@ -49,7 +64,7 @@ async function attemptStart() {
...process.env,
},
timeout: 100_000,
} as Parameters<typeof electron["launch"]>[0]);
});
try {
const window = await getMainWindow(app);