Skip to content

Commit

Permalink
ci: make CI faster by separating ESLint and using node_modules cache
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Nov 13, 2021
1 parent e035b80 commit 4808e8b
Showing 1 changed file with 40 additions and 8 deletions.
48 changes: 40 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,36 @@ on:
- "*"

jobs:
lint:
name: ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
# Install node_modules
- uses: actions/cache@v2
id: cache-node_modules
with:
path: node_modules
key: ubuntu-latest-16-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
ubuntu-latest-16-${{ hashFiles('**/package-lock.json') }}
- if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: npm ci
- run: npm run lint

test:
strategy:
matrix:
# Test with Node.js v12 (LTS), v14 (LTS), and v16 (latest)
# Test with Node.js v12 (LTS), v14 (LTS), v16 (LTS), and 17 (Current)
node:
- 12
- 14
- 16
# Test with Ubuntu and macOS
- 17
# Test with Ubuntu, macOS, and Windows
os:
- ubuntu-latest
- macos-latest
Expand All @@ -36,28 +57,37 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cache: 'npm'
# Print current Node.js version
- run: node --version
# Print current npm version
- run: npm --version
# Print current Git version
- run: git --version
# Install node_modules
- run: npm ci
- uses: actions/cache@v2
id: cache-node_modules
with:
path: node_modules
key: ${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
- if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: npm ci
# Run tests
- run: npm test
# Upload coverage artifact from Node.js LTS
- uses: actions/upload-artifact@v2
if: matrix.os == 'ubuntu-latest' && matrix.node == '12'
if: matrix.os == 'ubuntu-latest' && matrix.node == '16'
with:
name: coverage
path: coverage

codecov:
name: Codecov
runs-on: ubuntu-latest
needs: test
needs:
- lint
- test
steps:
- uses: actions/checkout@v2
# Download coverage artifact
Expand All @@ -70,14 +100,16 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
needs: test
needs:
- lint
- test
# Trigger release for only pushes to branches defined above
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14' # release using Node.js LTS
node-version: 16 # release using Node.js LTS
# Release using semantic-release.
# While this runs on all branches, it will only release latest from master
- uses: codfish/semantic-release-action@v1
Expand Down

0 comments on commit 4808e8b

Please sign in to comment.