forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpost-artifact
31 lines (29 loc) · 1.2 KB
/
post-artifact
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# This script is executed by Buildkite on the host machine.
# In contrast, our build jobs are run in Docker containers.
# This means that even though our build jobs write to
# `/artifact-mount`, the directory on the host machine is
# actually `/tmp/artifacts`.
# We clean up the artifacts directory before any command and
# after uploading artifacts to make sure no stale artifacts
# remain on the node when a Buildkite runner is re-used.
set -ex
if [ -d "/tmp/artifacts" ]; then
echo "Cleaning up artifacts after upload."
echo "Artifact directory contents before cleanup:"
find /tmp/artifacts -print || true
if [ "$(ls -A /tmp/artifacts)" ]; then
echo "Directory not empty, cleaning up..."
if [[ "${OSTYPE}" = darwin* ]]; then
rm -rf /tmp/artifacts
mkdir -p /tmp/artifacts
else
# Need to run in docker to avoid permission issues
docker run --rm -v /tmp/artifacts:/artifact-mount alpine:latest /bin/sh -c 'rm -rf /artifact-mount/*; rm -rf /artifact-mount/.[!.]*' || true
fi
else
echo "Directory already empty, no need to clean up."
fi
echo "Artifact directory contents after cleanup:"
find /tmp/artifacts -print || true
fi