Housekeeping - second pass of the JSDocs #10084
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: push | |
jobs: | |
build: | |
# You must use a Linux environment when using service containers or container jobs | |
runs-on: ubuntu-latest | |
env: | |
ADMIN_CLIENT_ID: shortvaluefullofnumbersandlettersinlowercase | |
AIRBRAKE_HOST: https://my-errbit-instance.com | |
AIRBRAKE_KEY: longvaluefullofnumbersandlettersinlowercase | |
PORT: 3000 | |
# External services - they don't exist here but we have code that depends on these values being present | |
EA_ADDRESS_FACADE_URL: http://localhost:8009 | |
CHARGING_MODULE_URL: http://localhost:8020 | |
SERVICE_FOREGROUND_URL: http://localhost:8001 | |
SERVICE_BACKGROUND_URL: http://localhost:8012 | |
REPORTING_URL: http://localhost:8011 | |
IMPORT_URL: http://localhost:8007 | |
TACTICAL_CRM_URL: http://localhost:8002 | |
EXTERNAL_UI_URL: http://localhost:8000 | |
INTERNAL_UI_URL: http://localhost:8008 | |
TACTICAL_IDM_URL: http://localhost:8003 | |
PERMIT_REPOSITORY_URL: http://localhost:8004 | |
RETURNS_URL: http://localhost:8006 | |
# JWT Auth token shared by all legacy external services | |
LEGACY_AUTH_TOKEN: longvalueofnumbersandletters.inbothcases.splitin3by2periods | |
# External Charging Module JWT (AWS Cognito) service | |
CHARGING_MODULE_TOKEN_URL: https://myinstance.amazoncognito.com | |
CHARGING_MODULE_TOKEN_USERNAME: valuefullofnumbersandlettersinlowercase | |
CHARGING_MODULE_TOKEN_PASSWORD: longvaluefullofnumbersandlettersinlowercase | |
# These need to be duplicated in services section for postgres. Unfortunately, there is not a way to reuse them | |
POSTGRES_USER: water_user | |
POSTGRES_PASSWORD: password | |
POSTGRES_HOST: localhost | |
POSTGRES_PORT: 5432 | |
POSTGRES_DB: wabs_system_test | |
POSTGRES_DB_TEST: wabs_system_test | |
ENVIRONMENT: dev | |
COOKIE_SECRET: 1a1028df-a2af-468a-929b-e3a274be1208 | |
DEFAULT_USER_PASSWORD: P@55word | |
# Service containers to run with `runner-job` | |
services: | |
# Label used to access the service container | |
postgres: | |
# Docker Hub image | |
image: postgres:12-alpine | |
# Provide the password for postgres | |
env: | |
POSTGRES_USER: water_user | |
POSTGRES_PASSWORD: password | |
POSTGRES_DB: wabs_system_test | |
# Maps tcp port 5432 on service container to the host | |
ports: | |
- 5432:5432 | |
# Set health checks to wait until postgres has started. You must have this so the runner knows to wait till | |
# postgres is up and running before proceeding | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
# Downloads a copy of the code in your repository before running CI tests | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of sonarcloud analysis | |
# Before we do anything, check we haven't accidentally left any `describe.only()` or `it.only(` statements in the | |
# tests | |
# | |
# Reworking of https://stackoverflow.com/a/21788642/6117745 | |
- name: Temporary tag check | |
run: | | |
! grep -R 'describe.only(\|it.only(' test | |
# Alongside this, check we haven't accidentally left any `console.log()` while checking results in app and tests | |
- name: Temporary log check | |
run: | | |
if grep -R 'console.log(' ./app/ ./test/; then | |
echo "console.log statement found. Please remove it." | |
exit 1 | |
fi | |
- name: Install Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
# Speeds up workflows by reading the node modules from cache. Obviously you need to run it at least once, and the | |
# cache will be updated should the package-lock.json file change | |
- name: Cache Node modules | |
uses: actions/cache@v4 | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.OS }}-node- | |
${{ runner.OS }}- | |
# Performs a clean installation of all dependencies in the `package.json` file | |
# For more information, see https://docs.npmjs.com/cli/ci.html | |
- name: Install dependencies | |
run: npm ci | |
# Run editorconfig check first. No point running the tests if there are issues with the format of the files | |
- name: Run editorconfig check | |
uses: editorconfig-checker/action-editorconfig-checker@main | |
- run: editorconfig-checker | |
# Next run linting. No point running the tests if there is a linting issue | |
- name: Run lint check | |
run: | | |
npm run lint | |
# Next generate docs. This checks any JSDoc changes are valid | |
- name: Run docs check | |
run: | | |
npm run docs | |
- name: Database migrations | |
run: | | |
npm run migrate:test | |
# This includes an extra run step. The sonarcloud analysis will be run in a docker container with the current | |
# folder mounted as `/github/workspace`. The problem is when the lcov.info file is generated it will reference the | |
# code in the current folder. So to enable sonarcloud to matchup code coverage with the files we use sed to update | |
# the references in lcov.info | |
# https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/6 | |
- name: Run unit tests | |
run: | | |
npm test | |
sed -i 's/\/home\/runner\/work\/water-abstraction-system\/water-abstraction-system\//\/github\/workspace\//g' coverage/lcov.info | |
- name: Analyze with SonarCloud | |
if: github.actor != 'dependabot[bot]' | |
uses: sonarsource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This is provided automatically by GitHub | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # This needs to be set in your repo; settings -> secrets |