Skip to content

Use setup-node

Use setup-node #684

Workflow file for this run

name: Node.js CI
on: [push, pull_request]
jobs:
install:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
- name: Install
run: npm ci
- name: "[node-modules-archive] Pack"
run: tar --exclude *.log -czf node-modules-archive.tar node_modules/
- name: "[node-modules-archive] Upload"
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: node-modules-archive
path: node-modules-archive.tar
lint:
needs: install
runs-on: ubuntu-latest
timeout-minutes: 5
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
- name: "[node-modules-archive] Download"
uses: actions/download-artifact@v4
with:
name: node-modules-archive
- name: "[node-modules-archive] Unpack"
run: tar -xzf node-modules-archive.tar
- name: Check Linting
run: npm run lint
test-with-codecov:
needs: install
runs-on: ubuntu-latest
timeout-minutes: 5
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
- name: "[node-modules-archive] Download"
uses: actions/download-artifact@v4
with:
name: node-modules-archive
- name: "[node-modules-archive] Unpack"
run: tar -xzf node-modules-archive.tar
- name: Run Tests
run: npm test -- --coverage
- name: Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
build:
needs: install
runs-on: ubuntu-latest
timeout-minutes: 5
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
- name: "[node-modules-archive] Download"
uses: actions/download-artifact@v4
with:
name: node-modules-archive
- name: "[node-modules-archive] Unpack"
run: tar -xzf node-modules-archive.tar
- name: Build
run: npm run build
- name: "[dist] Upload"
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: dist
path: |
dist/
dist.module/
bundlewatch:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 5
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
- name: "[node-modules-archive] Download"
uses: actions/download-artifact@v4
with:
name: node-modules-archive
- name: "[node-modules-archive] Unpack"
run: tar -xzf node-modules-archive.tar
- name: "[dist] Download"
uses: actions/download-artifact@v4
with:
name: dist
- name: Check and Report Bundlesize
run: npx bundlewatch
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
test:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 5
env:
CI: true
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 21.x, 22.x, latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: "[node-modules-archive] Download"
uses: actions/download-artifact@v4
with:
name: node-modules-archive
- name: "[node-modules-archive] Unpack"
run: tar -xzf node-modules-archive.tar
- name: "[dist] Download"
uses: actions/download-artifact@v4
with:
name: dist
- name: Run Tests
run: npm run test-dist
cleanup:
needs: [lint, test-with-codecov, bundlewatch, test]
runs-on: ubuntu-latest
timeout-minutes: 5
env:
CI: true
steps:
- name: Cleanup artifacts
uses: geekyeggo/delete-artifact@v1
with:
name: |
dist
node-modules-archive