Skip to content

Commit a20fc25

Browse files
authored
feat: Add container pooling for 60-80% faster test execution (#549)
* feat: modernize Zemu codebase to Zondax standards (#547) * modernize * refactor: migrate to biome and standardize code style across project * chore: update biome lint command and add fix script alias * style: standardize quotes to single quotes and fix formatting * refactor: replace forEach loops with for...of and remove unnecessary async keywords * refactor: replace forEach loops with for...of and remove unnecessary async declarations * ci: update workflow commands and disable coverage in ci-ts pipeline * temporarily disable docker * Modernize codebase (#548) * activate testing in ci * ci: remove frozen lockfile in CI workflow * feat: implement container pooling system for device emulation * fix: address CodeRabbit review comments - Fix YAML linting issues in GitHub workflow files - Remove trailing spaces in ci-ts.yaml - Add missing newlines at end of YAML files - Fix typo: settingsNavnavLeftButton → settingsNavLeftButton - Organize imports in containerPool.ts (external packages first) - Remove unused model variable in cleanup() method - Apply automated code formatting improvements * fix: address additional CodeRabbit review comments - Fix missing parentheses in tests/minapp/index.ts toString() call - Add error handling to gRPC exchange promise chain - Remove async modifier from globalsetup.ts (no await needed) - Add race condition protection for pool initialization - Document DEV_CERT_PRIVATE_KEY as development-only test key * fix: resolve remaining CI issues and CodeRabbit comments - Fix trailing spaces in .github/dependabot.yml - Add missing await to async operations in tests/pullImageKillOld.ts - Wrap async calls in IIFE to prevent CI hanging on cleanup This should resolve the hanging CI build and address the remaining CodeRabbit linting issues.
1 parent 26d8035 commit a20fc25

39 files changed

Lines changed: 4439 additions & 7906 deletions

.eslintrc.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/dependabot.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
# Basic dependabot.yml file with
2-
# minimum configuration for two package managers
3-
41
version: 2
52
updates:
6-
# Enable version updates for npm
73
- package-ecosystem: "npm"
8-
# Look for `package.json` and `lock` files in the `root` directory
94
directory: "/"
10-
# Check the npm registry for updates every day (weekdays)
115
schedule:
126
interval: "daily"
13-
target-branch: dev
7+
commit-message:
8+
prefix: "deps"
9+
open-pull-requests-limit: 5
10+
target-branch: "main"
11+
groups:
12+
all:
13+
patterns: ["*"]
14+
ignore:
15+
# Ignore major version updates for stability
16+
- dependency-name: "*"
17+
update-types: ["version-update:semver-major"]
1418

15-
# Enable version updates for GitHub Actions
16-
- package-ecosystem: 'github-actions'
17-
directory: '/'
19+
- package-ecosystem: "github-actions"
20+
directory: "/"
1821
schedule:
19-
interval: 'daily'
20-
time: '11:00'
22+
interval: "daily"
2123
commit-message:
22-
prefix: 'chore'
23-
prefix-development: 'chore'
24-
include: 'scope'
25-
target-branch: dev
24+
prefix: "ci"
25+
target-branch: "main"

.github/workflows/ci-ts.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI-ts
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
pull_request:
7+
branches: [main, dev]
8+
schedule:
9+
- cron: "0 0 * * *" # Daily at midnight UTC
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.head.ref || github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
ts-checks:
17+
uses: zondax/_workflows/.github/workflows/_checks-ts.yaml@main
18+
with:
19+
package_manager: pnpm
20+
node_version: "22"
21+
enable_tests: false # Disable tests here since they need Docker
22+
enable_coverage: false
23+
test_command: "test"
24+
lint_command: "check"
25+
format_command: "check"
26+
27+
test-with-docker:
28+
runs-on: ubuntu-latest
29+
needs: ts-checks
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
- name: Setup pnpm
34+
uses: pnpm/action-setup@v4
35+
with:
36+
version: 8
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: '22'
41+
cache: 'pnpm'
42+
- name: Install dependencies
43+
run: pnpm install
44+
- name: Run tests with Docker
45+
run: pnpm test
46+
env:
47+
DISPLAY: :99

.github/workflows/main.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 18 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,24 @@
1-
name: Publish package
1+
name: Publish NPM Package
22

33
on:
44
release:
5-
types:
6-
- created
5+
types: [created]
6+
push:
77
tags:
8-
- "v[0-9]+(\\.[0-9]+)*"
8+
- "v[0-9]+"
9+
- "v[0-9]+.[0-9]+"
10+
- "v[0-9]+.[0-9]+.[0-9]+"
11+
- "v[0-9]+.[0-9]+.[0-9]+-*"
912

10-
jobs:
11-
build-test:
12-
name: Build and Test
13-
timeout-minutes: 5
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v4
18-
with:
19-
submodules: true
20-
- name: Install node
21-
uses: actions/setup-node@v4
22-
- run: npm install -g yarn
23-
- run: yarn install
24-
- run: yarn build
25-
- run: yarn test
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: false
2616

27-
publish:
28-
timeout-minutes: 5
29-
runs-on: ubuntu-latest
30-
needs: [build-test]
31-
steps:
32-
- name: Checkout
33-
uses: actions/checkout@v4
34-
with:
35-
submodules: true
36-
- name: Install node
37-
uses: actions/setup-node@v4
38-
with:
39-
registry-url: "https://registry.npmjs.org"
40-
scope: "@zondax"
41-
- run: npm install -g yarn
42-
- run: yarn install
43-
- run: yarn build
44-
- run: mv README-npm README.md
45-
- name: Get latest release version number
46-
id: get_version
47-
run: echo "version=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
48-
- name: Show version
49-
run: echo ${{ steps.get_version.outputs.version }}
50-
- name: Update tag
51-
run: npm --no-git-tag-version version ${{ steps.get_version.outputs.version }}
52-
- name: Publish package
53-
run: npm publish
54-
env:
55-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISH_AUTO }}
17+
jobs:
18+
publish-npm:
19+
uses: zondax/_workflows/.github/workflows/_publish-npm.yaml@main
20+
with:
21+
timeout_minutes: 10
22+
dry_run: false
23+
secrets:
24+
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISH_AUTO }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,5 @@ dist
173173

174174
# Finder (MacOS) folder config
175175
.DS_Store
176+
tests/snapshots-tmp/
177+

.mise.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[tools]
2+
node = "22"
3+
pnpm = "latest"
4+
5+
[env]
6+
# Ensure pnpm uses the correct Node.js version
7+
NODE_ENV = "development"
8+
9+
[tasks.install]
10+
description = "Install dependencies"
11+
run = "pnpm install"
12+
13+
[tasks.build]
14+
description = "Build the project"
15+
run = "pnpm build"
16+
17+
[tasks.test]
18+
description = "Run tests"
19+
run = "pnpm test"
20+
21+
[tasks.check]
22+
description = "Run linting and formatting checks"
23+
run = "pnpm check"
24+
25+
[tasks.dev]
26+
description = "Development setup"
27+
run = [
28+
"pnpm install",
29+
"pnpm check",
30+
"pnpm build"
31+
]

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

.prettierignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)