updated flows

This commit is contained in:
Juan Hernández Serrano 2023-04-11 11:21:16 +02:00
parent 96ab0b5332
commit e56e214ecf
2 changed files with 83 additions and 71 deletions

View File

@ -1,98 +1,116 @@
name: build name: build, test (node and browser), coverage, publish to NPM
on: on:
push: push:
branches: [ main ] tags:
pull_request: - "v*.*.*"
branches: [ main ] workflow_dispatch:
jobs: jobs:
build: build:
name: build and node tests name: build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: "https://registry.npmjs.org"
- name: install
run: npm ci
- name: build
run: npm run build
nodetests:
name: tests in Node.js
needs: [build]
runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ] os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [14.x, 16.x, 18.x] node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
# When set to true, GitHub cancels all in-progress jobs if any matrix job fails.
fail-fast: false
# The maximum number of jobs that can run simultaneously. Set to 1 if you can't run tests in parallel
# max-parallel: 1
steps: steps:
- uses: actions/checkout@v2 - name: Git checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1 uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
registry-url: "https://registry.npmjs.org"
- name: install - name: install
run: npm ci run: npm ci
- name: lint - name: node esm tests
run: npm run lint run: npm run test:node-esm
# env:
# VARIABLE1: ${{ secrets.VARIABLE1 }}
# VARIABLE2: ${{ secrets.VARIABLE2 }}
- name: build - name: node cjs tests
run: npm run build:js run: npm run test:node-cjs
# env:
# VARIABLE1: ${{ secrets.VARIABLE1 }}
# VARIABLE2: ${{ secrets.VARIABLE2 }}
- if: matrix.node-version == '16.x' browsertests:
name: docs needs: [build]
run: npm run docs name: tests in browser
- name: node tests
run: npm run test:node
- if: matrix.node-version == '16.x'
name: browser tests
run: npm run test:browser-headless
publication:
needs: build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - name: Git checkout
uses: actions/checkout@v3
- uses: EndBug/version-check@v1 - name: Use Node.js 18
id: check uses: actions/setup-node@v3
- name: check version changes
if: steps.check.outputs.changed == 'true'
run: 'echo "Version change found! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"'
- uses: actions/setup-node@v1
if: steps.check.outputs.changed == 'true'
with: with:
node-version: 16 node-version: 18.x
registry-url: https://registry.npmjs.org/ registry-url: "https://registry.npmjs.org"
- name: install - name: install
if: steps.check.outputs.changed == 'true'
run: npm ci run: npm ci
- name: lint
if: steps.check.outputs.changed == 'true'
run: npm run lint
- name: build
if: steps.check.outputs.changed == 'true'
run: npm run build:js
- name: docs
if: steps.check.outputs.changed == 'true'
run: npm run docs
- name: browser tests - name: browser tests
if: steps.check.outputs.changed == 'true'
run: npm run test:browser-headless run: npm run test:browser-headless
# env:
# VARIABLE1: ${{ secrets.VARIABLE1 }}
# VARIABLE2: ${{ secrets.VARIABLE2 }}
- name: node tests and coverage publish:
if: steps.check.outputs.changed == 'true' needs: [nodetests, browsertests]
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
- name: install
run: npm ci
- name: coverage
run: npm run coverage run: npm run coverage
- name: send report to coveralls.io - name: send report to coveralls.io
if: steps.check.outputs.changed == 'true'
uses: coverallsapp/github-action@master uses: coverallsapp/github-action@master
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
- name: publish to NPM - name: NPM publish
if: steps.check.outputs.changed == 'true' run: npm publish --access public
run: npm publish
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@ -14,20 +14,14 @@ jobs:
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 18
registry-url: https://registry.npmjs.org/ registry-url: https://registry.npmjs.org/
- name: install - name: install
run: npm ci run: npm ci
- name: lint
run: npm run lint
- name: build - name: build
run: npm run build:js run: npm run build
- name: docs
run: npm run docs
- name: browser tests - name: browser tests
run: npm run test:browser-headless run: npm run test:browser-headless