Skip to content

Latest commit

 

History

History
114 lines (90 loc) · 4.58 KB

js.md

File metadata and controls

114 lines (90 loc) · 4.58 KB

Reusable workflows – JavaScript

Unit tests JavaScript

This workflow runs Jest. It does so by executing the binary in the ./node_modules/.bin/ folder.

Simplest possible example:

name: Unit tests JavaScript
on:
  pull_request:
jobs:
  tests-unit-js:
    uses: inpsyde/reusable-workflows/.github/workflows/tests-unit-js.yml@main

Configuration parameters

Inputs

Name Default Description
NPM_REGISTRY_DOMAIN 'https://npm.pkg.github.com/' Domain of the private npm registry
NODE_VERSION 18 Node version with which the unit tests are to be executed
JEST_ARGS '--reporters=default --reporters=github-actions' Set of arguments passed to Jest

Note: The default github-actions reporter requires Jest 28 or higher.

Secrets

Name Description
NPM_REGISTRY_TOKEN Authentication for the private npm registry
GITHUB_USER_EMAIL Email address for the GitHub user configuration
GITHUB_USER_NAME Username for the GitHub user configuration
GITHUB_USER_SSH_KEY Private SSH key associated with the GitHub user passed as GITHUB_USER_NAME
ENV_VARS Additional environment variables as a JSON formatted object

Example with configuration parameters:

name: Unit tests JavaScript
on:
  pull_request:
jobs:
  tests-unit-js:
    uses: inpsyde/reusable-workflows/.github/workflows/tests-unit-js.yml@main
    secrets:
      NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
      ENV_VARS: >-
        [{"name":"EXAMPLE_USERNAME", "value":"${{ secrets.USERNAME }}"}]
    with:
      NODE_VERSION: 14
      JEST_ARGS: 'my-test --reporters=jest-junit --coverage'

Static analysis JavaScript

This workflow runs the TypeScript compiler with the --noEmit argument. It does so by executing the tsc binary in the ./node_modules/.bin/ folder.

Simplest possible example:

name: Static code analysis JavaScript
on:
  push:
jobs:
  static-analysis-js:
    uses: inpsyde/reusable-workflows/.github/workflows/static-analysis-js.yml@main

Configuration parameters

Inputs

Name Default Description
NODE_OPTIONS '' Space-separated list of command-line Node options
NODE_VERSION 18 Node version with which the assets will be compiled
NPM_REGISTRY_DOMAIN 'https://npm.pkg.github.com/' Domain of the private npm registry

Secrets

Name Description
NPM_REGISTRY_TOKEN Authentication for the private npm registry
GITHUB_USER_EMAIL Email address for the GitHub user configuration
GITHUB_USER_NAME Username for the GitHub user configuration
GITHUB_USER_SSH_KEY Private SSH key associated with the GitHub user passed as GITHUB_USER_NAME
ENV_VARS Additional environment variables as a JSON formatted object

Example with configuration parameters:

name: Static code analysis JavaScript
on:
  pull_request:
jobs:
  static-analysis-js:
    uses: inpsyde/reusable-workflows/.github/workflows/static-analysis-js.yml@main
    secrets:
      NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
      ENV_VARS: >-
        [{"name":"EXAMPLE_USERNAME", "value":"${{ secrets.USERNAME }}"}]
    with:
      NODE_VERSION: 18