Continuous integration runs your tests on every push. YAML configs call Bash steps—understand exit codes, env vars, and working directories.
Typical CI step
#!/usr/bin/env bash
set -euo pipefail
npm ci
npm test
npm run buildEach line failing stops the job when set -e is on—CI marks the build failed.
GitHub Actions style
- name: Test
run: |
chmod +x ./scripts/test.sh
./scripts/test.sh
Multi-line run blocks are Bash on Ubuntu runners—same syntax as local.
Artifacts and secrets
CI injects secrets as env vars—never echo them. Cache dependencies between runs; use Bash only for glue, not heavy logic—compare with language-specific test runners.
Important interview questions and answers
- Q: Why set -e in CI?
A: Ensures failing tests fail the pipeline visibly. - Q: Secrets in logs?
A: Printing env vars can leak tokens—mask secrets in CI settings.
Self-check
- What happens when npm test fails under set -e?
- Why chmod +x before running a script in CI?
Tip: Keep CI scripts idempotent—re-running should not corrupt state.
Interview prep
- set -e in CI?
Ensures failing tests fail the build.
- Secrets in logs?
Avoid echoing tokens—use masked CI variables.