Skip to content

docs: audit package reachability before removing shipped assets #1156

docs: audit package reachability before removing shipped assets

docs: audit package reachability before removing shipped assets #1156

Workflow file for this run

name: Tests
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- name: Set up Node 24
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- name: ESLint, typecheck, and codespell
run: npm run lint
test:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
# Branch protection requires the floating `test (lts/*)` check. The
# plan's preferred fixed-24 entry would duplicate current LTS
# (24.20.0), so review fixed coverage when the LTS line advances.
node-version: ["18.1.0", 20, 22, "lts/*"]
fail-fast: false
steps:
- uses: actions/checkout@v6
- name: Set up Node ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Run tests
if: matrix.node-version != '18.1.0'
run: npm test
- name: Run minimum Node smoke
if: matrix.node-version == '18.1.0'
run: |
npm run lint:syntax
npm run benchmark
node tests/quality/scorer-benchmark.mjs
quality:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- name: Set up Node 24
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- name: Release metadata
run: npm run release:check
- name: Private asset leak gate
run: npm run check:no-private-assets
- name: Syntax lint
run: npm run lint:syntax
- name: Benchmark report schema
run: npm run benchmark:report
- name: Detector comparison harness
# Runs before the drift check: it rewrites
# docs/benchmarks/detector-comparison.{json,md}, so the check below
# covers those files too (issue #399 item 1 staleness class).
run: npm run benchmark:compare
- name: Benchmark report drift check
# The regen is deterministic except for the generatedAt /
# benchmarkGeneratedAt timestamps and the node version of the
# regenerating environment (CI pins Node 24, contributors run Node
# 22), so ignore those metadata lines and fail only on real
# fixture/metric drift.
run: |
git diff --exit-code -I '"generatedAt":' -I '"benchmarkGeneratedAt":' -I 'Generated at:' -I '"nodeVersion":' -I '^- Node: ' -- docs/benchmarks || {
echo '::error::docs/benchmarks is stale. Run `npm run benchmark:report && npm run benchmark:compare` and commit the result.'
exit 1
}
- name: Dogfood public docs
run: npm run dogfood
- name: Install Redis test executables
# tests/unit/quota-redis.test.js skips unless both executables are
# supplied, so a hosted run without Redis would pass while proving
# nothing. Install the executables explicitly and fail here if that is
# not possible.
#
# redis-server.postinst runs `deb-systemd-invoke start
# redis-server.service` (and `invoke-rc.d ... start`) on a new install,
# so a plain apt install would briefly launch an OS-managed Redis. Both
# invokers honour the Debian policy layer, so install behind a
# policy-rc.d that denies service start, then remove it again. The
# package still *enables* the unit, so disable it afterwards and assert
# that nothing OS-managed is running: this regression owns and launches
# its own Redis process on a private UNIX socket.
run: |
set -euo pipefail
printf '#!/bin/sh\nexit 101\n' | sudo tee /usr/sbin/policy-rc.d > /dev/null
sudo chmod +x /usr/sbin/policy-rc.d
sudo apt-get update
sudo apt-get install -y --no-install-recommends redis-server redis-tools
sudo rm -f /usr/sbin/policy-rc.d
sudo systemctl disable --now redis-server \
|| echo 'no systemd-managed redis-server unit to disable'
# Fail closed if packaging ever starts an OS-managed Redis anyway.
! systemctl is-active --quiet redis-server
! pgrep -x redis-server > /dev/null
echo 'OS-managed redis-server unit: inactive and disabled'
REDIS_SERVER="$(command -v redis-server)"
REDIS_CLI="$(command -v redis-cli)"
test -n "$REDIS_SERVER"
test -x "$REDIS_SERVER"
test -n "$REDIS_CLI"
test -x "$REDIS_CLI"
"$REDIS_SERVER" --version
"$REDIS_CLI" --version
echo "PATINA_TEST_REDIS_SERVER=$REDIS_SERVER" >> "$GITHUB_ENV"
echo "PATINA_TEST_REDIS_CLI=$REDIS_CLI" >> "$GITHUB_ENV"
- name: Real Redis quota regression
# Re-verify the resolved paths so a lost or empty environment value
# fails here instead of silently reverting to the skip path, then
# require the run to report one executed test and zero skips.
run: |
set -euo pipefail
test -n "${PATINA_TEST_REDIS_SERVER:-}"
test -x "$PATINA_TEST_REDIS_SERVER"
test -n "${PATINA_TEST_REDIS_CLI:-}"
test -x "$PATINA_TEST_REDIS_CLI"
log="$RUNNER_TEMP/redis-quota-regression.log"
node -r ./tests/helpers/real-tmpdir.cjs \
--test tests/unit/quota-redis.test.js | tee "$log"
grep -qE '(^|[^0-9])pass 1([^0-9]|$)' "$log"
grep -qE '(^|[^0-9])fail 0([^0-9]|$)' "$log"
grep -qE '(^|[^0-9])skipped 0([^0-9]|$)' "$log" || {
echo '::error::tests/unit/quota-redis.test.js did not execute against real Redis (non-zero skip count).'
exit 1
}