Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 23 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,31 @@ jobs:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6

- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
- name: Setup utoo
uses: utooland/setup-utoo@3a51006d0b66afcc32d1b9177a4b200b74f4a8cb # main

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: '24'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile
run: ut install --from pnpm

- name: Run lint
run: pnpm run lint

- name: Check dedupe
run: pnpm dedupe --check
run: ut run lint

- name: Run typecheck
run: pnpm run typecheck
run: ut run typecheck

- name: Run format check
run: pnpm run fmtcheck
run: ut run fmtcheck

- name: Run build
run: pnpm run build
run: ut run build

- name: Run site build
run: pnpm run site:build
run: ut run site:build

test:
strategy:
Expand Down Expand Up @@ -157,25 +153,24 @@ jobs:
# & mysqladmin -u root password root
& mysql -uroot -e "CREATE DATABASE IF NOT EXISTS test;"

- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
- name: Setup utoo
uses: utooland/setup-utoo@3a51006d0b66afcc32d1b9177a4b200b74f4a8cb # main

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile
run: ut install --from pnpm

- name: Run tests
run: pnpm run ci --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
run: ut run ci -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}

- name: Run example tests
if: ${{ matrix.node != '20' && matrix.os != 'windows-latest' }}
run: |
pnpm run example:test:all
ut run example:test:all

- name: Code Coverage
# skip on windows, it will hangup on codecov
Expand Down Expand Up @@ -205,22 +200,21 @@ jobs:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6

- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
- name: Setup utoo
uses: utooland/setup-utoo@3a51006d0b66afcc32d1b9177a4b200b74f4a8cb # main

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile
run: ut install --from pnpm

- name: Run tests
run: |
pnpm build --workspace ./tools/egg-bin
pnpm run --filter ./tools/egg-bin ci
ut run build -- --workspace tools/egg-bin
ut run ci --workspace tools/egg-bin
env:
# https://github.com/jamiebuilds/ci-parallel-vars
CI_NODE_INDEX: ${{ matrix.shardIndex }}
Expand Down Expand Up @@ -251,22 +245,21 @@ jobs:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6

- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
- name: Setup utoo
uses: utooland/setup-utoo@3a51006d0b66afcc32d1b9177a4b200b74f4a8cb # main

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile
run: ut install --from pnpm

- name: Run tests
run: |
pnpm build
pnpm run --filter=./tools/scripts ci
ut run build
ut run ci --workspace tools/scripts

- name: Code Coverage
if: ${{ matrix.os != 'windows-latest' }}
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,24 +138,23 @@ jobs:
with:
ecosystem-ci-project: ${{ matrix.project.name }}

- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
- name: Setup utoo
uses: utooland/setup-utoo@3a51006d0b66afcc32d1b9177a4b200b74f4a8cb # main

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: ${{ matrix.project.node-version }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile
run: ut install --from pnpm

- name: Build all packages
run: pnpm build
run: ut run build

- name: Pack packages into tgz
run: |
pnpm -r pack
node ecosystem-ci/pack-all.mjs

- name: Override dependencies from tgz in ${{ matrix.project.name }}
working-directory: ecosystem-ci/${{ matrix.project.name }}
Expand Down
64 changes: 64 additions & 0 deletions ecosystem-ci/pack-all.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { execSync } from 'node:child_process';
import { readFileSync, writeFileSync } from 'node:fs';
import { glob } from 'node:fs/promises';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

import yaml from 'js-yaml';

const rootDir = join(fileURLToPath(import.meta.url), '../..');
const wsConfig = yaml.load(readFileSync(join(rootDir, 'pnpm-workspace.yaml'), 'utf8'));
const catalog = wsConfig.catalog ?? {};

// Build a map of workspace package versions for resolving workspace: protocol
const workspaceVersions = {};
for (const pattern of wsConfig.packages ?? []) {
for await (const entry of glob(`${pattern}/package.json`, { cwd: rootDir })) {
const pkg = JSON.parse(readFileSync(join(rootDir, entry), 'utf8'));
if (pkg.name && pkg.version) workspaceVersions[pkg.name] = pkg.version;
}
}

function resolveVersion(name, version) {
if (typeof version !== 'string') return version;
if (version === 'catalog:' || version.startsWith('catalog:')) {
return catalog[name] ?? version;
}
if (version.startsWith('workspace:')) {
return workspaceVersions[name] ? `^${workspaceVersions[name]}` : version;
}
return version;
}

function resolveDeps(deps) {
if (!deps) return deps;
return Object.fromEntries(Object.entries(deps).map(([k, v]) => [k, resolveVersion(k, v)]));
}

for (const pattern of wsConfig.packages ?? []) {
for await (const entry of glob(`${pattern}/package.json`, { cwd: rootDir })) {
const pkgPath = join(rootDir, entry);
const original = readFileSync(pkgPath, 'utf8');
const pkg = JSON.parse(original);
if (pkg.private || !pkg.name || !pkg.version) continue;

// Apply publishConfig overrides (npm pack does not do this automatically)
const publishConfig = pkg.publishConfig ?? {};
const publishOverrides = Object.fromEntries(
Object.entries(publishConfig).filter(([k]) => !['access', 'registry', 'tag'].includes(k)),
);
const patched = {
...pkg,
...publishOverrides,
dependencies: resolveDeps(pkg.dependencies),
peerDependencies: resolveDeps(pkg.peerDependencies),
optionalDependencies: resolveDeps(pkg.optionalDependencies),
};
writeFileSync(pkgPath, JSON.stringify(patched, null, 2) + '\n');
try {
execSync(`npm pack --pack-destination "${rootDir}"`, { cwd: join(rootDir, dirname(entry)), stdio: 'inherit' });
} finally {
writeFileSync(pkgPath, original);
}
}
}
41 changes: 27 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,40 @@
"type": "git",
"url": "git+https://github.com/eggjs/egg.git"
},
"workspaces": [
"packages/*",
"plugins/*",
"examples/*",
"tools/*",
"site",
"tegg/core/*",
"tegg/plugin/*",
"tegg/standalone/*"
],
"files": [
"README.md"
],
"type": "module",
"scripts": {
"clean-dist": "pnpm -r --parallel exec rimraf dist",
"clean": "pnpm -r --parallel run clean && pnpm clean-dist",
"clean-dist": "ut run clean --workspaces",
"build": "tsdown",
"prelint": "pnpm clean-dist",
"prelint": "ut run clean-dist",
"lint": "oxlint --type-aware --type-check --quiet",
"fmt": "oxfmt",
"typecheck": "pnpm clean && pnpm -r run typecheck",
"typecheck": "ut run clean-dist && ut run typecheck --workspaces",
"fmtcheck": "oxfmt --check .",
"pretest": "pnpm run clean && pnpm -r run pretest",
"pretest": "ut run clean-dist && ut run pretest --workspaces --if-present",
"test": "vitest run --bail 1 --retry 2 --testTimeout 20000 --hookTimeout 20000",
"test:cov": "pnpm run test --coverage",
"preci": "pnpm -r --parallel run pretest",
"ci": "pnpm run test --coverage",
"site:dev": "pnpm --filter=site run dev",
"site:build": "pnpm --filter=site run build",
"test:cov": "ut run test -- --coverage",
"preci": "ut run pretest --workspaces --if-present",
"ci": "ut run test -- --coverage",
"site:dev": "ut run dev --workspace site",
"site:build": "ut run build --workspace site",
"puml": "puml . --dest ./site",
"example:dev:commonjs": "pnpm --filter=helloworld-commonjs run dev",
"example:dev:typescript": "pnpm --filter=helloworld-typescript run dev",
"example:dev:tegg": "pnpm --filter=helloworld-tegg run dev",
"example:test:all": "pnpm --filter=helloworld-* run test",
"example:dev:commonjs": "ut run dev --workspace helloworld-commonjs",
"example:dev:typescript": "ut run dev --workspace helloworld-typescript",
"example:dev:tegg": "ut run dev --workspace helloworld-tegg",
"example:test:all": "ut run test --workspace helloworld-typescript && ut run test --workspace helloworld-tegg",
"prepare": "husky",
"version:patch": "node scripts/version.js patch",
"version:minor": "node scripts/version.js minor",
Expand Down Expand Up @@ -67,9 +76,13 @@
"tsdown": "catalog:",
"tsx": "catalog:",
"typescript": "catalog:",
"unplugin-unused": "catalog:",
"urllib": "catalog:",
"vitest": "catalog:"
},
"overrides": {
"vite": "npm:rolldown-vite@^7.1.13"
},
"lint-staged": {
"*": [
"oxfmt --no-error-on-unmatched-pattern",
Expand Down
19 changes: 9 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tools/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"scripts": {
"typecheck": "tsgo --noEmit",
"test": "vitest run --bail 1 --no-file-parallelism",
"cov": "pnpm test --coverage",
"ci": "pnpm run cov"
"cov": "ut run test -- --coverage",
"ci": "ut run cov"
},
"dependencies": {
"@eggjs/utils": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default defineConfig({
publint: {
level: 'suggestion',
strict: true,
pack: 'npm',
},

// Default entry pattern - glob to include all source files
Expand Down
Loading