Skip to content

Commit

Permalink
ci: use node version file
Browse files Browse the repository at this point in the history
  • Loading branch information
homj committed Dec 15, 2023
1 parent 916a037 commit 09f352a
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 121 deletions.
115 changes: 57 additions & 58 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,81 +13,80 @@ jobs:
install-deps:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}
- uses: actions/setup-node@v3
if: steps.cache.outputs.cache-hit != 'true'
with:
node-version: 16.x
- name: NPM install
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Checkout
uses: actions/checkout@v4
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}
- uses: actions/setup-node@v3
if: steps.cache.outputs.cache-hit != 'true'
with:
node-version-file: '.nvmrc'
- name: NPM install
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci

lint:
runs-on: ubuntu-latest
needs: install-deps
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --no-tags --prune --depth=1 origin develop
- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --no-tags --prune --depth=1 origin develop
- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}

- run: npx nx affected --target=lint --parallel=3 --base=origin/develop
- run: npx nx affected --target=lint --parallel=3 --base=origin/develop

test:
runs-on: ubuntu-latest
needs: install-deps
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --no-tags --prune --depth=1 origin develop
- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --no-tags --prune --depth=1 origin develop
- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}

- run: npx nx affected --target=test --parallel=3 --configuration=ci --base=origin/develop --codeCoverage
- run: npx nx affected --target=test --parallel=3 --configuration=ci --base=origin/develop --codeCoverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

build:
runs-on: ubuntu-latest
needs: install-deps
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --no-tags --prune --depth=1 origin develop
- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --no-tags --prune --depth=1 origin develop
- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}

- run: npx nx affected:build --parallel=3 --base=origin/develop

- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
- run: npx nx affected:build --parallel=3 --base=origin/develop

- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
70 changes: 35 additions & 35 deletions .github/workflows/deploy-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Deploy Demo to Github Pages
on:
# Runs on pushes targeting the default branch
push:
branches: [ "main" ]
branches: ['main']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -18,27 +18,27 @@ permissions:
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
group: 'pages'
cancel-in-progress: false

jobs:
install-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}
- uses: actions/setup-node@v4
if: steps.cache.outputs.cache-hit != 'true'
with:
node-version: 20.x
- name: NPM install
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- uses: actions/checkout@v4
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}
- uses: actions/setup-node@v4
if: steps.cache.outputs.cache-hit != 'true'
with:
node-version-file: '.nvmrc'
- name: NPM install
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci

# Single deploy job since we're just deploying
deploy:
Expand All @@ -48,24 +48,24 @@ jobs:
runs-on: ubuntu-latest
needs: install-deps
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Checkout
uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}
- name: Setup Pages
uses: actions/configure-pages@v3

- name: Build Demo
run: npx nx build demo -c github
- name: Build Demo
run: npx nx build demo -c github

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload entire repository
path: './dist/apps/demo'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload entire repository
path: './dist/apps/demo'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
56 changes: 28 additions & 28 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish Docs to the Wiki

on:
push:
branches: [ "main" ]
branches: ['main']

workflow_dispatch:

Expand All @@ -17,36 +17,36 @@ jobs:
install-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}
- uses: actions/setup-node@v4
if: steps.cache.outputs.cache-hit != 'true'
with:
node-version: 20.x
- name: NPM install
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- uses: actions/checkout@v4
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}
- uses: actions/setup-node@v4
if: steps.cache.outputs.cache-hit != 'true'
with:
node-version-file: '.nvmrc'
- name: NPM install
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci

publish:
runs-on: ubuntu-latest
needs: install-deps
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}
- name: Build Docs
run: scripts/build-docs.sh
- name: Checkout
uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: cache-node-modules-${{ hashFiles('package-lock.json') }}
- name: Build Docs
run: scripts/build-docs.sh

- name: Upload Docs to Wiki
uses: Andrew-Chen-Wang/github-wiki-action@v4
with:
path: 'docs'
- name: Upload Docs to Wiki
uses: Andrew-Chen-Wang/github-wiki-action@v4
with:
path: 'docs'

0 comments on commit 09f352a

Please sign in to comment.