This project is an Express.js application set up to demonstrate an ALM (Application Lifecycle Management) pipeline. It uses various technologies like linting, unit testing, integration testing, and a CI/CD pipeline using GitHub Actions.
- Node.js: Runtime environment
- Express.js: Web application framework
- EJS: Template engine
- Mocha: Testing framework
- ESLint: Code linting
- Husky: Git hooks
- NYC: Code coverage
- Prettier: Code formatting
- Supertest: HTTP assertions
- GitHub Actions: CI/CD
-
Clone the repository:
git clone https://github.com/claudeloba/webb22_alm_slutuppgift.git
-
Navigate to the project folder:
cd webb22-alm-slutuppgift
-
Install dependencies:
npm install
-
Run the application:
DEBUG=webb22-alm-slutuppgift:* npm start
Visit
http://localhost:5050
to access the application.
npm run format
: Format code using Prettiernpm run lint
: Lint codebase using ESLintnpm run lint-fix
: Auto-fix linting issuesnpm run test:unit
: Run unit testsnpm run test:integration
: Run integration testsnpm run test
: Run all testsnpm run coverage
: Run test coverage
Husky is pre-configured and should install automatically during npm install
. If it doesn't, you can manually trigger Husky installation using:
npm run prepare
Unit tests are located in the /test
directory. To execute them, run:
npm run test:unit
Integration tests are also in the /test
directory. To execute them, run:
npm run test:integration
ESLint is used for linting with Prettier for formatting. ESLint is configured to work seamlessly with the Prettier configuration, thereby avoiding conflicts between the two.
To lint the code, execute:
npm run lint
To fix auto-fixable lint issues, execute:
npm run lint-fix
The project utilizes GitHub Actions for the CI/CD pipeline. Upon each push or pull request, the pipeline runs unit tests, linting, and integration tests. It also includes job steps for fake deployment to test and production environments.
This project meets the VG requirements, optimizing for both the inner and outer loops.
- We use a small image in our build: alpine.
- We use the eslint-config-prettier.
- We configure test reports using Xunit Reporter
- We utilize nyc coverage
- We fail the pipeline if coverage does not reach at least 80% for each category
- We run tests against a running container
- We make sure NODE_ENV='production' is set when fake deploying to production.
- We make sure NODE_ENV='development' is set when fake deploying to test
- We validate commit messages with commitlint