Skip to content

#176

#176 #184

Workflow file for this run

name: CI
on:
push:
branches:
- master
release:
types: [published]
pull_request:
branches:
- '**'
env:
PRIMARY_NODE_VERSION: 18.x
PRIMARY_OS: ubuntu-latest
REGISTRY: https://registry.npmjs.org/
jobs:
test:
name: CI
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: [18.x, 20.x, 22.x]
steps:
- name: Echo env variables
run: |
echo ref: ${{ github.event.client_payload.ref || github.ref }}
echo sha: ${{ github.event.client_payload.sha || github.sha }}
echo head ref: ${{ github.event.client_payload.head_ref || github.head_ref }}
echo base ref: ${{ github.event.client_payload.base_ref || github.base_ref }}
echo action: ${{ github.action }}
echo event: ${{ github.event_name }}
- uses: actions/checkout@v2
name: Checkout
with:
ref: ${{ github.event.client_payload.ref || github.ref }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Get yarn cache directory
id: yarn-cache-dir
run: |
echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ matrix.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.node-version }}-yarn-
- name: Install dependencies and build
run: |
yarn install --frozen-lockfile
yarn build
- name: Snyk security check
if: matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS && !github.event.pull_request.head.repo.fork
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
- name: Run unit tests with coverage
if: matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS && !github.event.pull_request.head.repo.fork
uses: paambaati/codeclimate-action@v2.7.5
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: yarn cover
- name: Run unit tests
if: "!(matrix.node-version == env.PRIMARY_NODE_VERSION && matrix.os == env.PRIMARY_OS)"
run: yarn test
publish_version:
name: Publish
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [18.x]
needs: [test]
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: fetch
run: |
git fetch --prune --unshallow
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
registry-url: ${{ env.REGISTRY }}
- name: Get yarn cache directory
id: yarn-cache-dir
run: |
echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ matrix.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.node-version }}-yarn-
- name: Install dependencies and build
run: |
yarn install --frozen-lockfile
yarn build
- name: Publish
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_AUTH_TOKEN }}
registry: ${{ env.REGISTRY }}