diff --git a/.github/workflows/validate-n-build-api.yml b/.github/workflows/validate-n-build-api.yml index db3492f13..1e399426f 100644 --- a/.github/workflows/validate-n-build-api.yml +++ b/.github/workflows/validate-n-build-api.yml @@ -7,7 +7,7 @@ on: branches: ["main"] jobs: - build: + validate-n-build: runs-on: ubuntu-latest steps: @@ -24,12 +24,44 @@ jobs: shared: - 'shared/**' + - name: Check node_modules cache + id: deps-cache + uses: martijnhols/actions-cache/check@v3 + env: + cache-name: api-deps-cache + with: + path: node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install Dependencies + if: steps.deps-cache.outputs.cache-hit != 'true' + run: | + cd api + npm install + + - name: Cache node modules + if: steps.deps-cache.outputs.cache-hit != 'true' + uses: actions/cache@v3 + env: + cache-name: api-deps-cache + with: + path: node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Validate API if: steps.filter.outputs.api == 'true' || steps.filter.outputs.shared == 'true' run: | cd api - npm install - npm run test:unit + npm test:unit + - name: Build the Docker image for API if: steps.filter.outputs.api == 'true' || steps.filter.outputs.shared == 'true'