mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
105 lines
3.8 KiB
YAML
105 lines
3.8 KiB
YAML
# .github/workflows/js-tests.yml
|
|
name: JS Tests
|
|
|
|
on:
|
|
workflow_call:
|
|
|
|
jobs:
|
|
workspaces:
|
|
name: List npm workspaces
|
|
runs-on: arc-runner-set
|
|
timeout-minutes: 20
|
|
outputs:
|
|
checks: ${{ steps.set-matrix.outputs.checks }}
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
|
with:
|
|
node-version: 22
|
|
|
|
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
id: npm-cache
|
|
with:
|
|
# Cache every workspace's node_modules, not just the root: npm
|
|
# nests conflicting-version deps inside apps/*/node_modules etc.,
|
|
# and a root-only cache restores an incomplete install.
|
|
path: |
|
|
node_modules
|
|
apps/*/node_modules
|
|
ui-tui/node_modules
|
|
ui-tui/packages/*/node_modules
|
|
web/node_modules
|
|
tests-js/node_modules
|
|
# noscripts flavor: MUST NOT share a key with full `npm ci`
|
|
# installs (electron postinstall binary, node-pty build).
|
|
key: node-modules-noscripts-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
|
|
|
|
- uses: ./.github/actions/retry
|
|
with:
|
|
command: npm ci --ignore-scripts
|
|
if: steps.npm-cache.outputs.cache-hit != 'true'
|
|
|
|
- id: set-matrix
|
|
run: |
|
|
node -e '
|
|
const { execSync } = require("child_process");
|
|
const pkgs = JSON.parse(execSync("npm query .workspace", { encoding: "utf-8" }));
|
|
if (pkgs.length === 0) {
|
|
console.error("::error::Workspace discovery produced an empty package list — refusing to emit a zero-length matrix (would skip all JS/TS checks silently).");
|
|
process.exit(1);
|
|
}
|
|
const checks = [];
|
|
for (const pkg of pkgs) {
|
|
const scripts = pkg.scripts || {};
|
|
const subs = Object.keys(scripts).filter(s => /^check:.+$/.test(s));
|
|
if (subs.length > 0) {
|
|
for (const script of subs) {
|
|
checks.push({ package: pkg.location, script });
|
|
}
|
|
} else if (scripts.check) {
|
|
checks.push({ package: pkg.location, script: "check" });
|
|
}
|
|
}
|
|
if (checks.length === 0) {
|
|
console.error("::error::No check scripts found in any workspace package.");
|
|
process.exit(1);
|
|
}
|
|
process.stdout.write("checks=" + JSON.stringify(checks) + "\n");
|
|
' >> "$GITHUB_OUTPUT"
|
|
|
|
check:
|
|
name: ${{ matrix.package }} / ${{ matrix.script }}
|
|
needs: workspaces
|
|
runs-on: arc-runner-set
|
|
timeout-minutes: 20
|
|
strategy:
|
|
matrix:
|
|
include: ${{ fromJson(needs.workspaces.outputs.checks) }}
|
|
fail-fast: false # report all failures, not just the first one
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
|
with:
|
|
node-version: 22
|
|
|
|
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
id: npm-cache
|
|
with:
|
|
path: |
|
|
node_modules
|
|
apps/*/node_modules
|
|
ui-tui/node_modules
|
|
ui-tui/packages/*/node_modules
|
|
web/node_modules
|
|
tests-js/node_modules
|
|
key: node-modules-full-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
|
|
|
|
- uses: ./.github/actions/retry
|
|
with:
|
|
command: npm ci
|
|
if: steps.npm-cache.outputs.cache-hit != 'true'
|
|
|
|
- uses: ./.github/actions/profile
|
|
with:
|
|
label: js-${{ matrix.package }}-${{ matrix.script }}
|
|
command: npm run --prefix ${{ matrix.package }} ${{ matrix.script }}
|