chore: improve workflow by caching node_modules #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Frontend CI | |
on: | |
push: | |
branches: | |
- master | |
- 'feature/*' | |
pull_request: | |
branches: | |
- master | |
jobs: | |
install-dependencies: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'npm' | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
id: cache-primes | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }} | |
- name: Install dependencies | |
run: npm ci | |
type-check: | |
runs-on: ubuntu-latest | |
needs: install-dependencies | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'npm' | |
- name: Load cached node_modules | |
uses: actions/cache@v3 | |
id: cache-primes | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }} | |
- name: Check TypeScript | |
run: npm run type-check | |
style-check: | |
runs-on: ubuntu-latest | |
needs: install-dependencies | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'npm' | |
- name: Load cached node_modules | |
uses: actions/cache@v3 | |
id: cache-primes | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }} | |
- name: Run Prettier | |
run: npm run style-check | |
test: | |
runs-on: ubuntu-latest | |
needs: install-dependencies | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'npm' | |
- name: Load cached node_modules | |
uses: actions/cache@v3 | |
id: cache-primes | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }} | |
- name: Run tests | |
run: npm run test:ci |