A CI/CD pipeline lab. The application code is deliberately trivial — two recursive algorithms and their unit tests. The deliverable is everything around it: the pipelines, the failure alerting, and the published coverage report.
Runs on every push to any branch and on pull requests targeting main.
- Checkout, Node 20 with npm cache.
npm install, thennpm test(Jest).- On failure, a second job (
notify-failure) runsactions/github-scriptto open an issue automatically, labelledci-failure, containing the workflow name, a direct link to the failed run, the branch, the commit SHA, and the triggering event. It requests onlyissues: write— least privilege, not a blanket token.
The point of the alert job is that a red build should not depend on somebody noticing a red checkmark.
Runs on push to main.
- Checkout, Node 20 with npm cache, install.
npx jest --coverage --coverageReporters=html, withcontinue-on-error: trueso a coverage dip never blocks the report from being published.- Publishes
coverage/lcov-reportto GitHub Pages viapeaceiris/actions-gh-pages.
The coverage report becomes a browsable artifact on every merge to main instead
of a number buried in CI logs.
Dockerfile builds on node:24-alpine:
npm ci --omit=devruns as its own layer via bind mounts, so dependencies are cached independently of source changes.- A cache mount on
/root/.npmspeeds up repeat builds. - Drops to the non-root
nodeuser before copying source.
compose.yaml brings the service up locally.
npm install
npm test
# or, containerised
docker compose up --buildsrc/algorithms.js exports fibonacci(n) and fatoracao(n) (factorial).
fatoracao throws on negative input; tests/algorithms.test.js covers the base
cases, a few larger values, and the throwing path.
Coursework for the DevOps discipline at PUCPR.