From 38cd4289e959c673e156454fc4ce75addcddac78 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Wed, 22 Mar 2023 00:41:07 -0400 Subject: [PATCH] Ci/caching (#306) * ci: add caching to CI * ci: job dependencies * ci: typo in ci func ci: typo in ci func ci: typo in ci func ci: typo in ci func ci: typo in ci func --- .github/workflows/nodejs.yml | 66 +++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 7dddb3a..e543c21 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -6,19 +6,50 @@ on: branches: [master] jobs: - lint: + dependencies: runs-on: ubuntu-latest + strategy: + matrix: + node-version: [14, 16, 18] + steps: - uses: actions/checkout@v3 - - name: Use Node.js 12.x - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - uses: actions/cache@v3 + id: dependencies-cache + env: + cache-name: dependencies-cache + with: + path: .yarn + key: ${{ runner.os }}-build-${{env.cache-name}}-${{ hashFiles('**/yarn.lock') }}-node-${{ matrix.node-version }} + - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} + run: yarn + + lint: + runs-on: ubuntu-latest + needs: dependencies + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: 18 - - run: yarn - - run: yarn lint + - uses: actions/cache@v3 + id: dependencies-cache + env: + cache-name: dependencies-cache + with: + path: .yarn + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}-node-18 + - run: | + yarn + yarn lint test: runs-on: ubuntu-latest + needs: dependencies strategy: matrix: @@ -30,8 +61,16 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - - run: yarn - - run: yarn test:coverage + - uses: actions/cache@v3 + id: dependencies-cache + env: + cache-name: dependencies-cache + with: + path: .yarn + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}-node-${{ matrix.node-version }} + - run: | + yarn + yarn test:coverage - name: Coverage uses: codecov/codecov-action@v1 with: @@ -40,6 +79,7 @@ jobs: build: runs-on: ubuntu-latest + needs: dependencies strategy: matrix: node-version: [14, 16, 18] @@ -50,5 +90,13 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - - run: yarn --immutable - - run: yarn build + - uses: actions/cache@v3 + id: dependencies-cache + env: + cache-name: dependencies-cache + with: + path: .yarn + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}-node-${{ matrix.node-version }} + - run: | + yarn + yarn build