English
The frontend job
The frontend job does for Source/Chatex.Web what the backend job does for the solution. It is shorter, because every check is already an npm script of package.json (topics 15–21).
Step 1. Node and the npm cache
Why. The Angular CLI needs Node.js 24, the version of engines in package.json. As for .NET, the runner must use the same major version as the developers.
Do. The job and its setup:
yaml
frontend:
name: Frontend
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: Source/Chatex.Web
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
cache-dependency-path: Source/Chatex.Web/package-lock.jsondefaults: run: working-directorymakes everyrun:step of this job start in the folder of the Angular app, so the commands below are written exactly as you type them there.actions/setup-nodeinstalls the newest Node.js 24.cache: npmkeeps npm's download cache between runs. Its key is the hash ofpackage-lock.json, which is not in the repository root, hencecache-dependency-path. The cache stores the downloaded package archives, notnode_modules: the install in the next step is still clean.
Step 2. A clean install and the audit
Why. npm install may update package-lock.json when it finds newer versions that match the ranges in package.json; CI would then test other versions than the ones in the repository. Security problems in packages are found every week, so the audit must run on every build, not once.
Do.
yaml
- run: npm ci
# Only what ships to browsers; run a full npm audit by hand when updating dev tooling.
- run: npm audit --omit=dev --audit-level=highnpm ci("clean install") deletesnode_modules, installs exactly the versions ofpackage-lock.jsonand fails if the lock file does not matchpackage.json. It never writes the lock file.npm audit --omit=dev --audit-level=highchecks the installed packages against the npm advisory database.--omit=devlimits it to thedependencies— Angular, RxJS, the SignalR client — the code that is shipped to browsers. The build tools indevDependenciesrun only on developer machines and runners, and their advisories (often about crafted input to a build tool) are reviewed by hand when the tools are updated.--audit-level=highfails the step only for advisories of severity high or critical.
At the pinned versions the step prints:
found 0 vulnerabilitiesnpm ci itself, which looks at all packages, may report 9 moderate severity vulnerabilities in the build tools at the same time; that is the difference --omit=dev makes.
Step 3. Prettier and ESLint
Why. The same idea as dotnet format and the analyzers: style and suspicious code are rejected by a machine, before a person reviews the change.
Do.
yaml
- run: npm run format:check
- run: npm run lintnpm run format:checkrunsprettier --check "src/**/*.{ts,html,css}"(topic 15). Success isAll matched files use Prettier code style!; a file with a stray semicolon fails the step with:
[warn] src/main.ts
[warn] Code style issues found in the above file. Run Prettier with --write to fix.npm run lintrunsng lint, that is ESLint with the Angular and TypeScript rules ofeslint.config.js. Success isAll files pass linting.
Step 4. Unit tests and the production build
Why. The Vitest specs of topics 16–21 check the stores, services and components. The production build is a test of its own: it compiles the templates in strict mode with the optimiser, checks the bundle budgets of angular.json, and produces the files the server will serve in topic 24.
Do.
yaml
- run: npm test -- --watch=false
- run: npm run buildnpm test -- --watch=falserunsng testonce instead of watching the files. Everything after--is passed from npm to the script. The step ends with:
Test Files 8 passed (8)
Tests 49 passed (49)npm run buildrunsng buildwith the defaultproductionconfiguration. It prints a table of the generated files with hashed names, such asmain-IWEIRFGV.js, and finishes withApplication bundle generation complete.A template error that the development server tolerated, or a bundle that exceeds its budget, fails here.
The two jobs together contain the first five of the eight gates from the course slides: format, analyzers, audit, migrations and tests. The other three — review, health check and smoke test — belong to the deployment (topic 24).
Check
Run the frontend part on your computer, from Source/Chatex.Web:
powershell
npm cipowershell
npm audit --omit=dev --audit-level=highpowershell
npm run format:checkpowershell
npm run lintpowershell
npm test -- --watch=falsepowershell
npm run buildEach command ends with the success line quoted above. Go back to the repository root afterwards with cd ../...