Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: saveCache shouldn't error on existing cache, warn instead #40

Merged
merged 2 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/example-basic.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: example-basic
on: [push]
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/example-subfolders.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: example-subfolders
on: [push]
on: [push, pull_request]
jobs:
separate-actions:
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/example-without-lock-file.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: example-without-lock-file
on: [push]
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/example-yarn.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: example-yarn
on: [push]
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: main
on: [push]
on: [push, pull_request]

jobs:
build-and-test:
Expand Down
14 changes: 13 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2756,7 +2756,19 @@ const restoreCachedNpm = npmCache => {

const saveCachedNpm = npmCache => {
console.log('saving NPM modules')
return cache.saveCache(npmCache.inputPaths, npmCache.primaryKey)

return cache
.saveCache(npmCache.inputPaths, npmCache.primaryKey)
.catch(err => {
// don't throw an error if cache already exists, which may happen due to
// race conditions
if (err.message.includes('Cache already exists')) {
console.warn(err.message)
return -1
}
// otherwise re-throw
throw err
})
}

const hasOption = (name, o) => name in o
Expand Down
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,19 @@ const restoreCachedNpm = npmCache => {

const saveCachedNpm = npmCache => {
console.log('saving NPM modules')
return cache.saveCache(npmCache.inputPaths, npmCache.primaryKey)

return cache
.saveCache(npmCache.inputPaths, npmCache.primaryKey)
.catch(err => {
// don't throw an error if cache already exists, which may happen due to
// race conditions
if (err.message.includes('Cache already exists')) {
console.warn(err.message)
return -1
}
// otherwise re-throw
throw err
})
}

const hasOption = (name, o) => name in o
Expand Down