+
Skip to content

Give feedback when persisting to workspace #217

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 13 commits into from
Oct 18, 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
"lint:js": "eslint src --ext ts",
"lint:fix": "npm run lint:js -- --fix",
"lint:sh": "shellcheck src/script/*.sh",
"test": "jest",
"test": "jest src",
"test:watch": "jest --watch"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions src/cache/getSaveCacheCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function getSaveCacheCommand(
path.basename(directory)
);

// BusyBox doesn't allow cp -n.
return `${accumulator} if [ -d ${destinationWhenCopied} ]
then
echo "${directory} is already cached, skipping"
Expand Down
4 changes: 2 additions & 2 deletions src/config/getAttachWorkspaceCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export default function getAttachWorkspaceCommand(step: Step): string {

const attachFrom = `${path.join(CONTAINER_STORAGE_DIRECTORY, path.sep)}.`;

// BusyBox doesn't allow cp -n.
return `if [ ! -d ${CONTAINER_STORAGE_DIRECTORY} ]
then
echo "Warning: tried to attach_workspace to ${CONTAINER_STORAGE_DIRECTORY}, but it's not a directory. It might require a job to run before it."
elif [ ! "$(ls -A ${CONTAINER_STORAGE_DIRECTORY})" ]
then
echo "Warning: tried to attach_workspace to ${CONTAINER_STORAGE_DIRECTORY}, but it's empty. It might require a job to run before it."
else
cp -rn ${attachFrom} ${step?.attach_workspace?.at} || cp -ru ${attachFrom} ${step?.attach_workspace?.at}
echo "Attaching ${attachFrom}"
cp -Lr ${attachFrom} ${step?.attach_workspace?.at}
fi`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ describe('getAttachWorkspaceCommand', () => {
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
cp -rn /tmp/local-ci/. /foo/baz || cp -ru /tmp/local-ci/. /foo/baz
echo "Attaching /tmp/local-ci/."
cp -Lr /tmp/local-ci/. /foo/baz
fi`
)
);
Expand Down
8 changes: 4 additions & 4 deletions src/process/ProcessFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ export default class ProcessFile {
step?.persist_to_workspace?.paths
);

// BusyBox doesn't have the -n option.
return `cp -rn ${pathToPersist} ${CONTAINER_STORAGE_DIRECTORY} || cp -ru ${pathToPersist} ${CONTAINER_STORAGE_DIRECTORY}`;
return `echo "Persisting ${pathToPersist}"
cp -Lr ${pathToPersist} ${CONTAINER_STORAGE_DIRECTORY}`;
}

return step?.persist_to_workspace?.paths.reduce(
Expand All @@ -205,8 +205,8 @@ export default class ProcessFile {
workspacePath
);

// BusyBox doesn't have the -n option.
return `${accumulator} cp -rn ${pathToPersist} ${CONTAINER_STORAGE_DIRECTORY} || cp -ru ${pathToPersist} ${CONTAINER_STORAGE_DIRECTORY} \n`;
return `${accumulator} echo "Persisting ${pathToPersist}"
cp -Lr ${pathToPersist} ${CONTAINER_STORAGE_DIRECTORY}\n`;
},
''
);
Expand Down
91 changes: 51 additions & 40 deletions src/test-tool/expected/with-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ jobs:
fi
- run:
name: Persist to workspace
command: cp -rn . /tmp/local-ci || cp -ru . /tmp/local-ci
command: |-
echo "Persisting ."
cp -Lr . /tmp/local-ci
run-prettier:
executor: default-executor
steps:
Expand Down Expand Up @@ -107,8 +109,9 @@ jobs:
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
cp -rn /tmp/local-ci/. . || cp -ru /tmp/local-ci/. .
fi
echo "Attaching /tmp/local-ci/."
cp -Lr /tmp/local-ci/. .
fi
- run:
name: Run prettier check on project files
command: npm run prettier:check
Expand Down Expand Up @@ -147,13 +150,14 @@ jobs:
name: Attach workspace
command: |-
if [ ! -d /tmp/local-ci ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's not a directory. It might require a job to run before it."
elif [ ! "$(ls -A /tmp/local-ci)" ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
cp -rn /tmp/local-ci/. . || cp -ru /tmp/local-ci/. .
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's not a directory. It might require a job to run before it."
elif [ ! "$(ls -A /tmp/local-ci)" ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
echo "Attaching /tmp/local-ci/."
cp -Lr /tmp/local-ci/. .
fi
- run:
name: Run linter
Expand All @@ -179,13 +183,14 @@ jobs:
name: Attach workspace
command: |-
if [ ! -d /tmp/local-ci ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's not a directory. It might require a job to run before it."
elif [ ! "$(ls -A /tmp/local-ci)" ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
cp -rn /tmp/local-ci/. . || cp -ru /tmp/local-ci/. .
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's not a directory. It might require a job to run before it."
elif [ ! "$(ls -A /tmp/local-ci)" ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
echo "Attaching /tmp/local-ci/."
cp -Lr /tmp/local-ci/. .
fi
- run:
name: Run unit tests
Expand All @@ -211,13 +216,14 @@ jobs:
name: Attach workspace
command: |-
if [ ! -d /tmp/local-ci ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's not a directory. It might require a job to run before it."
elif [ ! "$(ls -A /tmp/local-ci)" ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
cp -rn /tmp/local-ci/. . || cp -ru /tmp/local-ci/. .
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's not a directory. It might require a job to run before it."
elif [ ! "$(ls -A /tmp/local-ci)" ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
echo "Attaching /tmp/local-ci/."
cp -Lr /tmp/local-ci/. .
fi
- run:
name: Restore cache
Expand Down Expand Up @@ -270,20 +276,23 @@ jobs:
name: Attach workspace
command: |-
if [ ! -d /tmp/local-ci ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's not a directory. It might require a job to run before it."
elif [ ! "$(ls -A /tmp/local-ci)" ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
cp -rn /tmp/local-ci/. . || cp -ru /tmp/local-ci/. .
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's not a directory. It might require a job to run before it."
elif [ ! "$(ls -A /tmp/local-ci)" ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
echo "Attaching /tmp/local-ci/."
cp -Lr /tmp/local-ci/. .
fi
- run:
name: Build
command: npm run build
- run:
name: Persist to workspace
command: cp -rn . /tmp/local-ci || cp -ru . /tmp/local-ci
command: |-
echo "Persisting ."
cp -Lr . /tmp/local-ci
verify-bundles-sizes:
executor: default-executor
steps:
Expand All @@ -305,13 +314,14 @@ jobs:
name: Attach workspace
command: |-
if [ ! -d /tmp/local-ci ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's not a directory. It might require a job to run before it."
elif [ ! "$(ls -A /tmp/local-ci)" ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
cp -rn /tmp/local-ci/. . || cp -ru /tmp/local-ci/. .
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's not a directory. It might require a job to run before it."
elif [ ! "$(ls -A /tmp/local-ci)" ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
echo "Attaching /tmp/local-ci/."
cp -Lr /tmp/local-ci/. .
fi
- run:
name: Check bundles sizes
Expand All @@ -337,13 +347,14 @@ jobs:
name: Attach workspace
command: |-
if [ ! -d /tmp/local-ci ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's not a directory. It might require a job to run before it."
elif [ ! "$(ls -A /tmp/local-ci)" ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
cp -rn /tmp/local-ci/. . || cp -ru /tmp/local-ci/. .
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's not a directory. It might require a job to run before it."
elif [ ! "$(ls -A /tmp/local-ci)" ]
then
echo "Warning: tried to attach_workspace to /tmp/local-ci, but it's empty. It might require a job to run before it."
else
echo "Attaching /tmp/local-ci/."
cp -Lr /tmp/local-ci/. .
fi
- run:
name: Firebase deploy
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载