Skip to content

Commit

Permalink
feat(ci): improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Badisi committed Apr 13, 2022
1 parent 76b0300 commit 8e1ff8e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/ci_docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy docs to GitHub Pages
name: Deploy docs

on:
push:
Expand All @@ -13,22 +13,27 @@ on:
jobs:
ci_docs:
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 14.x
registry-url: https://registry.npmjs.org/
cache: npm
- name: Make sure npm is latest

- name: Install latest npm
run: npm install -g npm@latest

- name: Build docs
working-directory: projects/docs
run: |
npm clean-install
npm clean-install --engine-strict
npm run build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
21 changes: 14 additions & 7 deletions .github/workflows/ci_publish.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
name: Publish library to NPM
name: Publish library

on:
release:
types: [created]

jobs:
ci_tests:
uses: ./.github/workflows/ci_tests.yml

ci_publish:
needs: ci_tests
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 14.x
registry-url: https://registry.npmjs.org/
- name: Make sure npm is latest
cache: npm

- name: Install latest npm
run: npm install -g npm@latest

- name: Install dependencies
run: npm clean-install
- name: Lint
run: npm run lint
- name: Test
run: npm run test
run: npm clean-install --engine-strict

- name: Build
run: npm run build:lib

- name: Publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
23 changes: 20 additions & 3 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI tests
name: Run tests

on:
push:
Expand All @@ -9,8 +9,13 @@ on:
paths-ignore:
- 'projects/docs/**'
pull_request:
workflow_call:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ci_tests:
name: Tests on ${{ matrix.os }} node${{ matrix.node }}
Expand All @@ -19,7 +24,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [12, 14, 16]
node: [14, 16]

steps:
- name: Checkout sources
Expand All @@ -30,6 +35,7 @@ jobs:
with:
node-version: ${{ matrix.node }}
registry-url: https://registry.npmjs.org/
cache: npm

# https://github.com/actions/setup-node/issues/411
# https://github.com/npm/cli/issues/4341
Expand All @@ -40,8 +46,19 @@ jobs:
- name: Install latest npm
run: npm install -g npm@latest

- name: Cache node_modules
uses: actions/cache@v3
id: cache-step
with:
key: cache-${{ matrix.os }}-node${{ matrix.node }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
cache-${{ matrix.os }}-node${{ matrix.node }}-
path: |
node_modules
- name: Install dependencies
run: npm clean-install
if: steps.cache-step.outputs.cache-hit != 'true'
run: npm clean-install --engine-strict

- name: Lint
run: npm run lint
Expand Down

0 comments on commit 8e1ff8e

Please sign in to comment.