ci: add caching

This commit is contained in:
Anthony Potdevin 2023-05-26 16:05:01 +02:00
parent ab72b1607f
commit 4b99ccfc8e
No known key found for this signature in database
GPG Key ID: 4403F1DFBE779457

View File

@ -1,4 +1,4 @@
name: Build
name: Test, lint and build
on:
push:
@ -14,6 +14,24 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
run: npm list
- name: Install modules
run: npm ci
@ -23,6 +41,10 @@ jobs:
- name: Run tests
run: npm run test
- name: Setup Docker Buildx Driver
id: docker_driver_setup
uses: docker/setup-buildx-action@v1
- name: Run docker build
id: docker_build
uses: docker/build-push-action@v2
@ -30,3 +52,5 @@ jobs:
context: ./
file: ./Dockerfile
push: false
cache-from: type=gha
cache-to: type=gha,mode=max