This reusable workflow is part of the City of Helsinki’s GitHub Actions setup, specifically designed to provide an opinionated and consistent CI process for City of Helsinki’s Node projects.
- Commit Linting: Enforces commit message standards using commitlint.
- Build and Lint: Build and verifies code style and formatting via yarn.
- Automated Testing: Runs project tests via yarn.
- Code Quality Analysis: Performs a SonarQube Cloud scan.
- Dependency Review: Scans dependency changes in pull requests for known vulnerabilities using GitHub's dependency review action.
- commitlint config file is present in the root of the project.
- SonarQube Cloud is configured with
SONAR_TOKENset in the repository or organization secrets.
- build the project.
- lint run eslint or another lint tool.
- test:coverage runs project tests with coverage.
- typecheck run tsc check
- check-size run browser bundle size limits check. The command is run if the
.size-limit.jsfile is found in the app directory. - check-dist: run ecmascript checks for build files. The command is run if the
.escheckrcfile is found in the app directory.
To use this reusable workflow, create a project-specific workflow file in your .github/workflows directory. Ensure the uses value is set to City-of-Helsinki/.github/.github/workflows/ci-node.yml@main and secrets is set to inherit. Also provide the following inputs as needed:
node-version(string): Specifies the Node version to use in the workflow.
extra-commands(string): Additional setup commands or checks to execute before running tests. Can be used to set environment variables:echo "EXTRA_TEST_ENV_VAR=test" >> $GITHUB_ENV.typecheck(boolean): Run typecheck command. Default isfalse.working-directory(string): Repository working directory where to run yarn installation and the tests. Default is.(the repository root).app-directory(string): The subdirectory of the application where the tests are run. Default isworking-directory.commitlint-config-file(string): Path to the commitlint config file. If not set, commitlint uses its default config discovery.artifact-name(string): Name for the uploaded build artifact. If empty, defaults tobuild-artifacts-<node-version>.
SONAR_TOKEN: Token for SonarQube Cloud Scan. Required.
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
common:
uses: City-of-Helsinki/.github/.github/workflows/ci-node.yml@main
secrets: inherit
with:
node-version: 20
extra-commands: |
echo "EXTRA_TEST_ENV_VAR=test" >> $GITHUB_ENV