refactor: ♻️ Update cache dependencies in GitHub Actions workflows #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
# GitHub Actions | |
# https://docs.github.com/en/actions/using-workflows | |
name: Unit Tests | |
on: | |
push: | |
branches: [main, master] | |
pull_request: | |
branches: [main, master] | |
jobs: | |
test: | |
timeout-minutes: 30 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
# give it a name for checking the cache hit-or-not | |
id: cache-dependencies | |
with: | |
path: | | |
**/node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
if: steps.cache-dependencies.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Run unit tests | |
run: npm run test:unit:coverage | |
env: | |
CI: true | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: coverage-report | |
path: reports/unit/coverage | |
retention-days: 5 |