+
Skip to content

Use sha256sum if shasum doesn't produce anything #157

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

Merged
merged 8 commits into from
Aug 4, 2022
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
26 changes: 13 additions & 13 deletions src/test/expected/with-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- run:
name: Restore cache
command: >
restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )*/.npm" "/tmp/local-ci/v2-deps*/.npm")
restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )*/.npm" "/tmp/local-ci/v2-deps*/.npm")
for directory_candidate in $restore_from_directories
do
if [ $(ls -ard $directory_candidate 2>/dev/null) ]
Expand All @@ -36,7 +36,7 @@ jobs:
break;
fi
done;
restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )*/.cache" "/tmp/local-ci/v2-deps*/.cache")
restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )*/.cache" "/tmp/local-ci/v2-deps*/.cache")
for directory_candidate in $restore_from_directories
do
if [ $(ls -ard $directory_candidate 2>/dev/null) ]
Expand All @@ -53,27 +53,27 @@ jobs:
- run:
name: Save cache
command: |2
if [ -d /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )/.npm ]
if [ -d /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )/.npm ]
then
echo "~/.npm is already cached, skipping"
elif [ ! -d ~/.npm ]
then
echo "~/.npm does not exist, skipping caching"
else
echo "Saving ~/.npm to the cache"
mkdir -p /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )
cp -rn ~/.npm /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )/.npm || cp -ru ~/.npm /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )/.npm
mkdir -p /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )
cp -rn ~/.npm /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )/.npm || cp -ru ~/.npm /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )/.npm
fi
if [ -d /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )/.cache ]
if [ -d /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )/.cache ]
then
echo "~/.cache is already cached, skipping"
elif [ ! -d ~/.cache ]
then
echo "~/.cache does not exist, skipping caching"
else
echo "Saving ~/.cache to the cache"
mkdir -p /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )
cp -rn ~/.cache /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )/.cache || cp -ru ~/.cache /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )/.cache
mkdir -p /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )
cp -rn ~/.cache /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )/.cache || cp -ru ~/.cache /tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )/.cache
fi
- run:
name: Persist to workspace
Expand Down Expand Up @@ -106,16 +106,16 @@ jobs:
- run:
name: Save cache
command: |2
if [ -d /tmp/local-ci/node-modules-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )/node_modules ]
if [ -d /tmp/local-ci/node-modules-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )/node_modules ]
then
echo "node_modules is already cached, skipping"
elif [ ! -d node_modules ]
then
echo "node_modules does not exist, skipping caching"
else
echo "Saving node_modules to the cache"
mkdir -p /tmp/local-ci/node-modules-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )
cp -rn node_modules /tmp/local-ci/node-modules-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )/node_modules || cp -ru node_modules /tmp/local-ci/node-modules-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )/node_modules
mkdir -p /tmp/local-ci/node-modules-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )
cp -rn node_modules /tmp/local-ci/node-modules-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )/node_modules || cp -ru node_modules /tmp/local-ci/node-modules-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )/node_modules
fi
run-linter:
executor: default-executor
Expand Down Expand Up @@ -192,7 +192,7 @@ jobs:
- run:
name: Restore cache
command: >
restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )*/.npm" "/tmp/local-ci/v2-deps*/.npm" "/tmp/local-ci/node-modules-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )*/.npm")
restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )*/.npm" "/tmp/local-ci/v2-deps*/.npm" "/tmp/local-ci/node-modules-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )*/.npm")
for directory_candidate in $restore_from_directories
do
if [ $(ls -ard $directory_candidate 2>/dev/null) ]
Expand All @@ -203,7 +203,7 @@ jobs:
break;
fi
done;
restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )*/.cache" "/tmp/local-ci/v2-deps*/.cache" "/tmp/local-ci/node-modules-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )*/.cache")
restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )*/.cache" "/tmp/local-ci/v2-deps*/.cache" "/tmp/local-ci/node-modules-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )*/.cache")
for directory_candidate in $restore_from_directories
do
if [ $(ls -ard $directory_candidate 2>/dev/null) ]
Expand Down
8 changes: 4 additions & 4 deletions src/test/suite/utils/getRestoreCacheCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ suite('getRestoreCacheCommand', () => {
)
),
normalize(
`restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )*/.npm")
`restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )*/.npm")
for directory_candidate in $restore_from_directories
do
if [ $(ls -ard $directory_candidate 2>/dev/null) ]
Expand All @@ -41,7 +41,7 @@ suite('getRestoreCacheCommand', () => {
break;
fi
done;
restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )*/.cache")
restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )*/.cache")
for directory_candidate in $restore_from_directories
do
if [ $(ls -ard $directory_candidate 2>/dev/null) ]
Expand Down Expand Up @@ -78,7 +78,7 @@ suite('getRestoreCacheCommand', () => {
)
),
normalize(
`restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )*/.npm" "/tmp/local-ci/v2-deps*/.npm")
`restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )*/.npm" "/tmp/local-ci/v2-deps*/.npm")
for directory_candidate in $restore_from_directories
do
if [ $(ls -ard $directory_candidate 2>/dev/null) ]
Expand All @@ -89,7 +89,7 @@ suite('getRestoreCacheCommand', () => {
break;
fi
done;
restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" | awk '{print $1}'; fi )*/.cache" "/tmp/local-ci/v2-deps*/.cache")
restore_from_directories=("/tmp/local-ci/v2-deps-$( if [ -f "package-lock.json" ]; then shasum "package-lock.json" 2>/dev/null || sha256sum "package-lock.json" 2>/dev/null | awk '{print $1}'; fi )*/.cache" "/tmp/local-ci/v2-deps*/.cache")
for directory_candidate in $restore_from_directories
do
if [ $(ls -ard $directory_candidate 2>/dev/null) ]
Expand Down
2 changes: 1 addition & 1 deletion src/utils/convertToBash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function convertToBash(command: string): string {
.replace(
/checksum (\S+)/g,
(fullMatch: string, fileName: string) =>
`if [ -f ${fileName} ]; then shasum ${fileName} | awk '{print $1}'; fi`
`if [ -f ${fileName} ]; then shasum ${fileName} 2>/dev/null || sha256sum ${fileName} 2>/dev/null | awk '{print $1}'; fi`
)
.replace(
/\.Environment\.(\S+)/,
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载