Skip to content

Commit

Permalink
Autoscaling github runners - fast fix (#6168)
Browse files Browse the repository at this point in the history
* initial commit. config changes and scripts

* add workflow config

* fix unstable macro tests

* fix microtests

* fix test

* try shard macro

* try to use full sharding
  • Loading branch information
AlexanderSavelyev authored Dec 18, 2024
1 parent fd39f41 commit 02a8413
Show file tree
Hide file tree
Showing 24 changed files with 291 additions and 46 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/playwright-macromolecules.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
name: Playwright Tests Macromolecules
on:
push:
branches:
- master
- 'release/**'
pull_request:
branches:
- master
- 'release/**'
workflow_dispatch:

env:
# Warnings breaks build on CI
# See: https://github.com/orgs/community/discussions/25228#discussioncomment-3246960
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
name: Playwright Tests
on:
push:
branches:
- master
- 'release/**'
pull_request:
branches:
- master
- 'release/**'
workflow_dispatch:

env:
# Warnings breaks build on CI
# See: https://github.com/orgs/community/discussions/25228#discussioncomment-3246960
Expand Down
174 changes: 174 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
name: Run Playwright Tests
on:
push:
branches:
- master
- 'release/**'
pull_request:
branches:
- master
- 'release/**'
workflow_dispatch:

env:
# Warnings breaks build on CI
# See: https://github.com/orgs/community/discussions/25228#discussioncomment-3246960
CI: false
MODE: standalone
KETCHER_URL: http://127.0.0.1:4002
DOCKER: true
IGNORE_UNSTABLE_TESTS: true
CI_ENVIRONMENT: true
USE_SEPARATE_INDIGO_WASM: true
jobs:
build_ketcher_micro:
runs-on: ubuntu-latest
container: node:18.14-bullseye-slim
env:
ENABLE_POLYMER_EDITOR: false
steps:
- name: Install dependencies
run: apt-get update -y && apt-get install -y git
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Git safe
run: git config --global --add safe.directory '*'
- name: Install NPM dependencies
run: npm ci
- name: Build all packages
run: npm run build:packages && npm run build:example:standalone
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ketcher-dist-micro
path: example/dist

build_ketcher_macro:
runs-on: ubuntu-latest
container: node:18.14-bullseye-slim
env:
ENABLE_POLYMER_EDITOR: true
steps:
- name: Install dependencies
run: apt-get update -y && apt-get install -y git
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Git safe
run: git config --global --add safe.directory '*'
- name: Install NPM dependencies
run: npm ci
- name: Build all packages
run: npm run build:packages && npm run build:example:standalone
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ketcher-dist-macro
path: example/dist

playwright_tests_micro:
timeout-minutes: 120
runs-on: self-hosted-a
needs: build_ketcher_micro
container: mcr.microsoft.com/playwright:v1.44.1-jammy
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2]
shardTotal: [2]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install dependencies
run: npm ci
- name: Create folder for dist
run: mkdir -p example/dist
- name: Download compiled ketcher
uses: actions/download-artifact@v3
with:
name: ketcher-dist-micro
path: example/dist/
- name: Create env file
env:
ENABLE_POLYMER_EDITOR: false
run: |
cat > ketcher-autotests/.env << EOF
DOCKER=true
KETCHER_URL=$KETCHER_URL
MODE=$MODE
IGNORE_UNSTABLE_TESTS=$IGNORE_UNSTABLE_TESTS
CI_ENVIRONMENT=$CI_ENVIRONMENT
USE_SEPARATE_INDIGO_WASM=$USE_SEPARATE_INDIGO_WASM
ENABLE_POLYMER_EDITOR=$ENABLE_POLYMER_EDITOR
EOF
- name: Run tests
run: |
cd example/ && nohup npm run serve:standalone &
cd ketcher-autotests/
npm i
npx playwright install chromium
npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- uses: actions/upload-artifact@v3
# run even if previous steps fails
if: always()
with:
name: playwright-report-micro-${{ matrix.shardIndex }}
path: ketcher-autotests/playwright-report/
retention-days: 5

playwright_tests_macromolecules:
timeout-minutes: 120
runs-on: self-hosted-a
needs: build_ketcher_macro
container: mcr.microsoft.com/playwright:v1.44.1-jammy
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install dependencies
run: npm ci
- name: Create folder for dist
run: mkdir -p example/dist
- name: Download compiled ketcher
uses: actions/download-artifact@v3
with:
name: ketcher-dist-macro
path: example/dist/
- name: Create env file
env:
ENABLE_POLYMER_EDITOR: true
run: |
cat > ketcher-autotests/.env << EOF
DOCKER=true
KETCHER_URL=$KETCHER_URL
MODE=$MODE
IGNORE_UNSTABLE_TESTS=$IGNORE_UNSTABLE_TESTS
CI_ENVIRONMENT=$CI_ENVIRONMENT
USE_SEPARATE_INDIGO_WASM=$USE_SEPARATE_INDIGO_WASM
ENABLE_POLYMER_EDITOR=$ENABLE_POLYMER_EDITOR
EOF
- name: Run tests
run: |
cd example/ && nohup npm run serve:standalone &
cd ketcher-autotests/
npm i
npx playwright install chromium
npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- uses: actions/upload-artifact@v3
# run even if previous steps fails
if: always()
with:
name: playwright-report-macromolecules-${{ matrix.shardIndex }}
path: ketcher-autotests/playwright-report/
retention-days: 5
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ yarn-error.log*

.vscode
/.idea
nohup.out
ketcher-autotests/results.json

.pnp.*
.yarn/*
Expand Down
9 changes: 4 additions & 5 deletions ketcher-autotests/.env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
KETCHER_URL=http://host.docker.internal:4002
# KETCHER_URL=http://localhost:4002
# KETCHER_URL=http://host.docker.internal:5173
KETCHER_URL=http://localhost:4002
MODE="standalone"
DOCKER=true
IGNORE_UNSTABLE_TESTS=true
GENERATE_DATA=false
ENABLE_POLYMER_EDITOR = false
CI_ENVIRONMENT=false
ENABLE_POLYMER_EDITOR=false
CI_ENVIRONMENT=false
NUM_WORKERS=8
6 changes: 0 additions & 6 deletions ketcher-autotests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@

FROM node:18-alpine
FROM mcr.microsoft.com/playwright:v1.44.1-jammy

WORKDIR /app

COPY . .

RUN npm i && npx playwright install chromium
5 changes: 5 additions & 0 deletions ketcher-autotests/Dockerfile-ketcher
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM node:18.14-bullseye-slim

RUN apt-get update -y && apt-get install -y git

WORKDIR /ketcher
43 changes: 39 additions & 4 deletions ketcher-autotests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ selectNestedTool - select specific tool that has sub / nested levels.
- DOCKER=true
- KETCHER_URL
- Rc: KETCHER_URL=link_to_rc
- Local frontend: KETCHER_URL=http://host.docker.internal:port (port where you run application)
- Local frontend: KETCHER_URL=http://localhost:4002
- OPTIONAL: IGNORE_UNSTABLE_TESTS=true (if you want to ignore unstable tests)
- OPTIONAL: ENABLE_POLYMER_EDITOR=true (If you want to run tests for Macromolecule Editor)
- **OPTIONAL: Build frontend**:
if you want to run tests based on the localhost:4002, you can put KETCHER_URL=http://localhost:4002
- OPTIONAL: NUM_WORKERS=8 (default=num cpus, if you want to define custom number of workers)

### Run tests:

Expand All @@ -121,7 +120,7 @@ Remove "skip" before running.
- `npm run build`
- `npm run serve`

- **Run docker**:
- **Run tests using docker**:

- `cd ketcher-autotests`
- `npm run docker:build`
Expand All @@ -146,6 +145,42 @@ Run this command in the directory "ketcher-autotests"
- `npm run docker:update file_name:N` update specific test in a file (N - line on which test starts)
- `npm run docker:update:test -- "test_title"` update only 1 snapshot with test_title

### Testing without installed NPM

If no NPM installed (only docker) to build ketcher the same compiler as on CI platforms, use the following command

Build Ketcher

```
docker-compose build ketcher
docker-compose run --rm --user $(id -u) ketcher bash /app/test_build.sh
```

Prepare tests

```
docker-compose build autotests
docker-compose run --rm --user $(id -u) autotests bash /app/test_prepare.sh
```

Run tests

```
docker-compose run --rm --user $(id -u) autotests bash /app/test_run.sh
```

Run pattern

```
docker-compose run --rm --user $(id -u) autotests bash /app/test_run.sh -g "Cut the reaction"
```

Run update

```
docker-compose run --rm --user $(id -u) autotests bash /app/test_run.sh -g "Cut the reaction" --update-snapshots
```

### Known issues

The "file name too long" error in Git is related to the maximum length of file names in the operating system. In most cases, this happens on Windows systems, where the maximum path length to a file is 260 characters.
Expand Down
23 changes: 18 additions & 5 deletions ketcher-autotests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
version: '3'
services:
ketcher:
build:
context: ./reporters/
dockerfile: ../Dockerfile-ketcher
env_file:
.env
volumes:
- ./:/app
- ../:/ketcher
autotests:
build:
context: .
context: ./reporters/
dockerfile: ../Dockerfile
container_name: ketcher-autotest
env_file:
.env
network_mode: "host"
extra_hosts:
- "host.docker.internal:host-gateway"
# network_mode: "host"
# extra_hosts:
# - "host.docker.internal:host-gateway"
# ports:
# - "4002:4002"
volumes:
- ./:/app
- /app/node_modules
- ../:/ketcher
11 changes: 5 additions & 6 deletions ketcher-autotests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
"check:lint": "eslint .",
"lint:fix": "eslint . --fix",
"prettier:write": "prettier --write \"./**/*.{js,ts}\" ",
"docker": "docker-compose run --rm autotests",
"docker:build": "docker-compose build autotests",
"docker:test": "npm run docker npx playwright test",
"docker:trace": "npm run docker npm run test:trace",
"docker:update": "npm run docker npm run test:update",
"docker:update:test": "npm run docker -- npx playwright test --update-snapshots -g"
"docker:build": "docker-compose build autotests && docker-compose run --rm autotests bash /app/test_prepare.sh",
"docker:test": "docker-compose run --rm autotests bash /app/test_run.sh",
"docker:trace": "docker-compose run --rm autotests bash /app/test_run.sh --trace on",
"docker:update": "docker-compose run --rm autotests bash /app/test_run.sh --update-snapshots",
"docker:update:test": "docker-compose run --rm autotests bash /app/test_run.sh --update-snapshots -g"
},
"author": "Nitvex",
"license": "ISC",
Expand Down
Loading

0 comments on commit 02a8413

Please sign in to comment.