https://c1495616js.github.io/api-document
We want to know how healthy about the codes and how database looks like. If we can have some tool automatically generating these reports while pipeline.
The difficult part running in github action is schemaspy,
- We run
backendfirst, using typeorm syncronizeentitywith database table.
- name: Build Database
run: docker-compose --file docker-compose.yml up -d --build backend-
Generating
jest coverageandtypedocis compared easier as we don't need any database. -
I found
schemaspyin docker-compose won't wait untilbackendsyncronizing database, therefore we have to run two time docker-compose, first time is for generating database and table, then second time is generatingschemaspy.
- name: Generate Schemaspy
run: docker-compose --file docker-compose.yml up --build schemaspynpm i -D npm-run-all# documentation
documentation/jest
documentation/typedocs
documentation/schema
documentation/sonar
.scannerworknpm i -D typedocin package.json
{
"compilerOptions": {
...
},
"typedocOptions": {
"inputFiles": ["./src"],
"mode": "modules",
"out": "./documentation/typedocs"
}
}- add
schemaspy.propertiesto your root folder.
Using typeorm here.
The reason for having nest.js backend here is because I can use syncronize to create tables with entity, saving me some time to run migration during pipeline.
npm i @nestjs/typeorm typeorm pg- add
ormconfig.jsin root folder of backend
schemaspy:
image: schemaspy/schemaspy:latest
user: ${UID}:${GID}
depends_on:
- postgres
- backend
command: ["-configFile", "/config/schemaspy.properties"]
volumes:
- ./backend/documentation/schema:/output ## where you want to output
- ./backend/schemaspy.properties:/config/schemaspy.properties ## read schemaspy config
networks:
- backendin package.json,
Setting this to documentation folder: "coverageDirectory": "../documentation/jest"
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"coverageDirectory": "../documentation/jest",
"testEnvironment": "node"
}npm i -D sonarqube-scanner

