Skip to content

Commit

Permalink
github: set up separate workflow for docs, add caching
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavohenke committed Apr 7, 2023
1 parent ba160e4 commit 3177f64
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 15 deletions.
14 changes: 14 additions & 0 deletions .github/actions/npm-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# See https://github.com/actions/cache/blob/main/examples.md#node---npm
name: Setup NPM cache
runs:
using: composite
steps:
- id: npm-cache-dir
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v3
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
19 changes: 4 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
with:
node-version: ${{ matrix.node }}
cache: npm
- name: Set up npm cache
uses: ./.github/actions/npm-cache.yml
- name: Install dependencies
run: npm ci
- name: Test
Expand Down Expand Up @@ -48,22 +50,9 @@ jobs:
with:
node-version: 16
cache: npm
- name: Set up npm cache
uses: ./.github/actions/npm-cache.yml
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint

docs:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
- name: Install dependencies
run: npm ci
- name: Build docs
run: npm run docs:build
40 changes: 40 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Docs
on:
pull_request:
paths:
- 'docs/**'
- 'website/**'
# Keep the following in sync with website/scripts/regenerate-api.js
- src/options.ts
- src/chain/validators.ts
- src/chain/sanitizers.ts
push:
paths:
- 'docs/**'
- 'website/**'
# Keep the following in sync with website/scripts/regenerate-api.js
- src/options.ts
- src/chain/validators.ts
- src/chain/sanitizers.ts

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
- name: Set up npm cache
uses: ./.github/actions/npm-cache.yml
- name: Install dependencies
run: npm ci
- name: Update validator APIs
run: npm run docs:regenerate-api
- name: Verify up-to-date
run: git diff --quiet --exit-code || echo "Docs not up-to-date, please rerun `npm run docs:regenerate-api`"
- name: Build
run: npm run docs:build
2 changes: 2 additions & 0 deletions website/scripts/regenerate-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const validator = require('validator');
const ts = require('typescript');

const generatedDocsPath = path.resolve(__dirname, '../../docs/api/validator');

// Keep the following in sync with .github/workflows/docs.yml
const optionsPath = path.resolve(__dirname, '../../src/options.ts');
const validatorsPath = path.resolve(__dirname, '../../src/chain/validators.ts');
const sanitizersPath = path.resolve(__dirname, '../../src/chain/sanitizers.ts');
Expand Down

0 comments on commit 3177f64

Please sign in to comment.