Skip to content

Commit

Permalink
fix: use @bahmutov/npm-install in templates' CI
Browse files Browse the repository at this point in the history
- have been using this internally for about 6 months and I've personally
  contributed bugfixes and optimizations to it, so should be good to
  use by general users too
  - it's a good bit less configuration, which is particularly better for
    beginners, but even for advanced users, it means that improvements
    are shared out to all users
  - I also recommended it in an actions/cache issue about needing too
    much config already too, which I wouldn't have done if I weren't
    confident in its usage now

- this properly caches node_modules by using ~/.npm or Yarn's cache dir
  as recommended, instead of `node_modules` itself, which is not
  - c.f. https://github.com/actions/cache/blob/main/examples.md#node---npm

- it's also not susceptible to the `**/yarn.lock` issue that was
  reported because it caches the _one_ lockfile directly instead of
  potentially multiple lockfiles
  • Loading branch information
agilgur5 committed Sep 21, 2020
1 parent dac1fd7 commit f109fe9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
12 changes: 2 additions & 10 deletions templates/basic/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,8 @@ jobs:
with:
node-version: 12.x

- name: Use cached node_modules
uses: actions/cache@v2
with:
path: node_modules
key: nodeModules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
nodeModules-
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1

- name: Lint
run: yarn lint
Expand Down
12 changes: 2 additions & 10 deletions templates/react-with-storybook/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,8 @@ jobs:
with:
node-version: 12.x

- name: Use cached node_modules
uses: actions/cache@v2
with:
path: node_modules
key: nodeModules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
nodeModules-
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1

- name: Lint
run: yarn lint
Expand Down
12 changes: 2 additions & 10 deletions templates/react/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,8 @@ jobs:
with:
node-version: 12.x

- name: Use cached node_modules
uses: actions/cache@v2
with:
path: node_modules
key: nodeModules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
nodeModules-
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1

- name: Lint
run: yarn lint
Expand Down

0 comments on commit f109fe9

Please sign in to comment.