Skip to content

Commit

Permalink
Feat: Cache npm dependencies (#1162)
Browse files Browse the repository at this point in the history
* Feat: Cache npm dependencies

* Add required changes

* Replace with npm ci

* Replace with npm install

* Remove continue_on_error
  • Loading branch information
bhav-khurana authored Dec 8, 2023
1 parent 696017c commit 76d7fed
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 8 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,22 @@ jobs:
- name: Checkout the Repository
uses: actions/checkout@v3

- name: Install Dependencies
- name: Restore node_modules from cache
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-generate-docs-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-generate-docs-${{ env.cache-name }}-
${{ runner.os }}-generate-docs-
${{ runner.os }}-
- name: Install dependencies
run: npm install --legacy-peer-deps

- name: Run linting check
Expand Down Expand Up @@ -71,8 +86,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: '16.14.1'
- name: resolve dependency

- name: Resolve dependency
run: npm install -g @graphql-inspector/cli

- name: Clone API repository
Expand Down
43 changes: 38 additions & 5 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,33 @@ on:
env:
CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }}

jobs:
jobs:
Code-Coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install --legacy-peer-deps

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-code-coverage-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-code-coverage-${{ env.cache-name }}-
${{ runner.os }}-code-coverage-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
run: npm install --legacy-peer-deps
- run: npm run test -- --watchAll=false --coverage
- name: Present and upload coverage to Codecov as ${{env.CODECOV_UNIQUE_NAME}}
uses: codecov/codecov-action@v3
Expand All @@ -42,9 +60,24 @@ jobs:
steps:
- name: Checkout the Repository
uses: actions/checkout@v3

- name: Install Dependencies
run: yarn install --legacy-peer-deps

- name: Restore node_modules from cache
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-generate-docs-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-generate-docs-${{ env.cache-name }}-
${{ runner.os }}-generate-docs-
${{ runner.os }}-
name: Install dependencies
run: npm install --legacy-peer-deps

- name: Install TypeScript Globally and add GraphQL tag
run: yarn global add typescript
Expand Down

0 comments on commit 76d7fed

Please sign in to comment.