revisit CLI options #10
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
# For details of what checks are run for PRs please refer below | |
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions | |
name: CI/CT | |
on: | |
push: | |
branches: [ 'main', 'master', '1.0-dev' ] | |
pull_request: | |
workflow_dispatch: | |
schedule: | |
# schedule weekly tests, since dependencies might not be intended to be locked | |
# this means: at 23:42 on Fridays | |
- cron: '42 23 * * 5' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
NODE_ACTIVE_LTS: '20' # https://nodejs.org/en/about/releases/ | |
YARN_VERSION: '4.x' # https://yarnpkg.com/blog/ | |
DIST_DIR: bundles | |
REPORTS_DIR: "CI_reports" | |
TESTS_REPORTS_ARTIFACT: tests-reports | |
jobs: | |
build: | |
name: build | |
runs-on: 'ubuntu-latest' | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js ${{ env.NODE_ACTIVE_LTS }} | |
# see https://github.com/actions/setup-node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_ACTIVE_LTS }} | |
# cache: 'yarn' | |
- name: Setup yarn ${{ env.YARN_VERSION }} | |
run: | | |
corepack enable yarn | |
yarn set version ${{ env.YARN_VERSION }} | |
- name: Setup subject | |
run: yarn install --immutable | |
- name: build | |
run: yarn build --source-map | |
- name: artifact build result | |
# see https://github.com/actions/upload-artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.DIST_DIR }} | |
path: ${{ env.DIST_DIR }} | |
if-no-files-found: error | |
# test-standards: | |
# # TODO | |
test-node: | |
needs: [ 'build' ] | |
name: jest (node${{ matrix.node-version }} ${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
node-version: | |
## action based on https://github.com/actions/node-versions/releases | |
## see also: https://nodejs.org/en/about/releases/ | |
- '21' # Current | |
- '20' # LTS | |
- '18' # lowest supported | |
os: | |
- ubuntu-latest | |
- windows-latest | |
- macos-latest | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js ${{ matrix.node-version }} | |
# see https://github.com/actions/setup-node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
# cache: 'npm' | |
- name: Setup yarn ${{ env.YARN_VERSION }} | |
run: | | |
corepack enable yarn | |
yarn set version ${{ env.YARN_VERSION }} | |
- name: Setup subject | |
run: yarn install --immutable | |
- name: setup-tests | |
run: yarn setup-tests | |
- name: fetch build artifact | |
# see https://github.com/actions/download-artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.DIST_DIR }} | |
path: ${{ env.DIST_DIR }} | |
- name: run tests | |
run: yarn test | |
- name: collect coverage | |
if: ${{ failure() || success() }} | |
run: > | |
yarn c8 report | |
--reporter clover | |
--reports-dir '${{ env.REPORTS_DIR }}/coverage/${{ matrix.os }}_node${{ matrix.node-version }}' | |
- name: artifact test reports | |
if: ${{ ! cancelled() }} | |
# see https://github.com/actions/upload-artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.TESTS_REPORTS_ARTIFACT }} | |
path: ${{ env.REPORTS_DIR }} | |
dogfooding: | |
needs: [ 'build' ] | |
name: dogfooding | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
node-version: | |
## action based on https://github.com/actions/node-versions/releases | |
## see also: https://nodejs.org/en/about/releases/ | |
- '21' # Current | |
- '20' # LTS | |
- '18' # lowest supported | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- run: mkdir -p ${{ env.REPORTS_DIR }} | |
- name: Setup Node.js ${{ matrix.node-version }} | |
# see https://github.com/actions/setup-node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
# cache: 'yarn' | |
- name: Setup yarn ${{ env.YARN_VERSION }} | |
run: | | |
corepack enable yarn | |
yarn set version ${{ env.YARN_VERSION }} | |
- name: Setup subject | |
run: yarn install --immutable | |
- name: fetch build artifact | |
# see https://github.com/actions/download-artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.DIST_DIR }} | |
path: ${{ env.DIST_DIR }} | |
- name: dogfooding | |
run: > | |
yarn dogfooding | |
--production | |
--output-file=${{ env.REPORTS_DIR }}/bom.json | |
- name: artifact test reports | |
if: ${{ failure() }} | |
# see https://github.com/actions/upload-artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dogfooding-direct_npm${{ matrix.npm-version }} | |
path: ${{ env.REPORTS_DIR }} | |
if-no-files-found: error | |
report-coverage: | |
name: Publish test coverage | |
needs: [ "test-node" ] | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: fetch test artifacts | |
# see https://github.com/actions/download-artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.TESTS_REPORTS_ARTIFACT }} | |
path: ${{ env.REPORTS_DIR }} | |
- name: Run codacy-coverage-reporter | |
env: | |
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
if: ${{ env.CODACY_PROJECT_TOKEN != '' }} ## see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-secrets | |
# see https://github.com/codacy/codacy-coverage-reporter-action | |
uses: codacy/codacy-coverage-reporter-action@v1 | |
with: | |
project-token: ${{ env.CODACY_PROJECT_TOKEN }} | |
coverage-reports: ${{ env.REPORTS_DIR }}/coverage/*/* | |