Files
puter/.github/workflows/test.yml
T
Workflow config file is invalid. Please check your config file: resolve aliases: yaml: line 34: could not find expected ':'
Eric Dubé 9506c537ab fix(security): shell escape paths in HostDiskUsageService; null-prototype objects in batch parser (#2659)
* fix(core): escape path in HostDiskUsageService

* fix: always use null prototypes on operation specs

* fix: update test.yml so that tests work again
2026-03-13 14:17:36 -07:00

138 lines
3.9 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: test
on:
push:
branches: ["main"]
paths-ignore:
- "src/docs/**"
pull_request:
branches: ["main"]
paths-ignore:
- "src/docs/**"
jobs:
test-backend:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [24.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Backend Tests (with coverage)
env:
NODE_OPTIONS: --max-old-space-size=4096
run: |
rm package-lock.json
          npm install -g npm@latest
          npm install
npm run build
npm run test:backend -- --coverage --coverage.reporter=json --coverage.reporter=json-summary --coverage.reporter=lcov
- name: Upload backend coverage report
if: ${{ always() && hashFiles('coverage/**/coverage-summary.json') != '' }}
uses: actions/upload-artifact@v4
with:
name: backend-coverage-${{ matrix.node-version }}
path: coverage
retention-days: 5
- name: Publish backend coverage summary
if: ${{ always() && matrix.node-version == '24.x' }}
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
const globModule = require('glob');
const matches = globModule.sync('coverage/**/coverage-summary.json', {
cwd: process.cwd(),
ignore: ['**/node_modules/**'],
});
if (!matches.length) {
core.warning('Coverage summary not found (expected coverage/**/coverage-summary.json). Did Vitest run with --coverage and include the json-summary reporter?');
return;
}
const summaryPath = path.resolve(matches[0]);
const summary = JSON.parse(fs.readFileSync(summaryPath, 'utf8'));
const metrics = ['lines', 'statements', 'branches', 'functions']
.map((key) => ({
label: key.charAt(0).toUpperCase() + key.slice(1),
...summary.total[key],
}));
core.summary
.addHeading('Backend coverage')
.addTable([
['Metric', 'Covered', 'Total', 'Pct'],
...metrics.map(({ label, covered, total, pct }) => [
label,
`${covered}`,
`${total}`,
`${pct}%`,
]),
])
.addRaw('Full HTML report is available in the uploaded `backend-coverage-${{ matrix.node-version }}` artifact.')
.write();
api-test:
name: API tests (node env, api-test)
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node-version: [24.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: API Test
run: |
pip install -r ./tests/ci/requirements.txt
./tests/ci/api-test.py
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: (api-test) server-logs
path: /tmp/backend.log
retention-days: 3
vitest:
name: puterjs (node env, vitest)
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node-version: [24.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Vitest Test
run: |
pip install -r ./tests/ci/requirements.txt
./tests/ci/vitest.py