Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generating Code Report Automatically

Demo

https://c1495616js.github.io/api-document

About

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.

Structure

The difficult part running in github action is schemaspy,

  1. We run backend first, using typeorm syncronize entity with database table.
- name: Build Database
  run: docker-compose --file docker-compose.yml up -d --build backend
  1. Generating jest coverage and typedoc is compared easier as we don't need any database.

  2. I found schemaspy in docker-compose won't wait until backend syncronizing database, therefore we have to run two time docker-compose, first time is for generating database and table, then second time is generating schemaspy.

- name: Generate Schemaspy
  run: docker-compose --file docker-compose.yml up --build schemaspy

Installing

npm i -D npm-run-all

.gitignore

# documentation
documentation/jest
documentation/typedocs
documentation/schema
documentation/sonar
.scannerwork

Typedoc

typedoc

npm i -D typedoc

in package.json

{
  "compilerOptions": {
   ...
  },
  "typedocOptions": {
    "inputFiles": ["./src"],
    "mode": "modules",
    "out": "./documentation/typedocs"
  }
}

Schemaspy

schemaspy

  • add schemaspy.properties to your root folder.

For Backend Api

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.js in root folder of backend

Docker

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:
    - backend

Jest Coverage

jest

in 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"
  }

SonarQube

npm i -D sonarqube-scanner

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages