https://github.com/dvsa/cvs-tsk-atf-report-gen-init
task that processes DynamoDB Stream and pushes onto a queue for onward processing
https://github.com/dvsa/cvs-tsk-atf-report-gen-init
app-dev cvs-project
Last synced: about 1 year ago
JSON representation
task that processes DynamoDB Stream and pushes onto a queue for onward processing
- Host: GitHub
- URL: https://github.com/dvsa/cvs-tsk-atf-report-gen-init
- Owner: dvsa
- License: mit
- Created: 2019-03-13T12:12:26.000Z (over 7 years ago)
- Default Branch: develop
- Last Pushed: 2024-04-15T14:04:46.000Z (about 2 years ago)
- Last Synced: 2025-02-08T22:28:36.194Z (over 1 year ago)
- Topics: app-dev, cvs-project
- Language: TypeScript
- Homepage:
- Size: 840 KB
- Stars: 0
- Watchers: 11
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cvs-tsk-atf-report-gen-init
## Introduction
The atf gen report init service is a lambda which is used to generate atf reports, it will marshall the data received to be prepared and processed for report generation.
## Dependencies
The project runs on node >10 with typescript and serverless framework. For further details about project dependencies, please refer to the `package.json` file.
[nvm](https://github.com/nvm-sh/nvm/blob/master/README.md) is used to managed node versions and configuration explicitly done per project using an `.npmrc` file.
### Prerequisites
Please install and run the following securiy programs as part of your development process:
- [git-secrets](https://github.com/awslabs/git-secrets)
After installing, do a one-time set up with `git secrets --register-aws`. Run with `git secrets --scan`.
- [repo-security-scanner](https://github.com/UKHomeOffice/repo-security-scanner)
These will be run as part of your projects hooks so you don't accidentally introduce any new security vulnerabilities.
You will also require Docker to run the service locally if you wish to mock external dependencies.
## Architecture
### End to end design
[All in one view](https://wiki.dvsacloud.uk/pages/viewpage.action?pageId=79254695)
### ATF report gen init microservice
More information about technical designs can be found under the [atf report gen init](https://wiki.dvsacloud.uk/display/HVT/Certificate+Generation+Design) section.
## Getting started
Set up your nodejs environment running `nvm use` and once the dependencies are installed using `npm i`, you can run the scripts from `package.json` to build your project.
This code repository uses [serverless framework](https://www.serverless.com/framework/docs/) to mock AWS capabilities for local development.
### Environmental variables
- The `BRANCH` environment variable indicates in which environment is this application running. Not setting this variable will result in defaulting to `local`.
### Scripts
The following scripts are available, however you can refer to the `package.json` to see the details:
- installing dependencies: `npm install`
- local development by starting the service: `npm start`
- building the project: `npm run build`
- unit tests: `npm t`
- integration tests: `npm run test-i`
- building docker containers - `npm run build:docker`
### Configuration
The configuration file can be found under `src/config/config.yml`.
Environment variable injection is possible with the syntax:
`${BRANCH}`, or you can specify a default value: `${BRANCH:local}`.
#### SQS
SQS contains configuration for the local environment or the AWS environment. Locally, you need to provide the `localhost` region and the SQS endpoint, which in this case is the address of a docker image. `apiVersion` and `queueName` need to be provided for both environments.
```yml
sqs:
local:
params:
region: localhost
endpoint: http://sqs:9324
apiVersion: "2012-11-05"
queueName: atf-gen-q
remote:
params:
apiVersion: "2012-11-05"
queueName: atf-gen-q
```
### Debugging
The following environmental variables can be given to your serverless scripts to trace and debug your service:
```shell
AWS_XRAY_CONTEXT_MISSING = LOG_ERROR
SLS_DEBUG = *
BRANCH = local
```
## Testing
### Unit testing
In order to test, you need to run the following:
```sh
npm run test # unit tests
```
### End to end
- [Automation test repository](https://github.com/dvsa/cvs-auto-svc)
- [Java](https://docs.oracle.com/en/java/javase/11/)
- [Serenity Cucumber with Junit](https://serenity-bdd.github.io/theserenitybook/latest/junit-basic.html)
## Infrastructure
We follow a [gitflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) approach for development.
For the CI/CD and automation please refer to the following pages for further details:
- [Development process](https://wiki.dvsacloud.uk/display/HVT/CVS+Pipeline+Infrastructure)
- [Pipeline](https://wiki.dvsacloud.uk/pages/viewpage.action?pageId=36870584)
## Contributing
Please familiarise yourself with [commitlint](https://commitlint.js.org/#/) and [conventional commits conventions](https://www.conventionalcommits.org/en/v1.0.0-beta.2/) as a hook is in place to enforce standards.
### Hooks and code standards
The projects has multiple hooks configured using [husky](https://github.com/typicode/husky#readme) which will execute the following scripts: `security-checks`, `audit`, `tslint`, `prepush`.
The codebase uses [typescript clean code standards](https://github.com/labs42io/clean-code-typescript) as well as sonarqube for static analysis.
SonarQube is available locally, please follow the instructions below if you wish to run the service locally (brew is the preferred approach).
### Static code analysis
_Brew_ (recommended):
- Install sonarqube using brew
- Change `sonar.host.url` to point to localhost, by default, sonar runs on `http://localhost:9000`
- run the sonar server `sonar start`, then perform your analysis `npm run sonar-scanner`
_Manual_:
- [Download sonarqube](https://www.sonarqube.org/downloads/)
- Add sonar-scanner in environment variables in your profile file add the line: `export PATH=/sonar-scanner-3.3.0.1492-macosx/bin:$PATH`
- Start the SonarQube server: `cd /bin/macosx-universal-64 ./sonar.sh start`
- In the microservice folder run the command: `npm run sonar-scanner`
## Linting
### Linting during development
Please run this command: `npm run lint:fix`
This command will display linting errors and fix the ones that it can
### Linting for CI and Sonar Qube
This command `npm run lint` will produce a `report.json` file in the root directory. This file will be read by Sonar Qube to display stats about code quality.