-
-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a data-only image for cache in CI. (#2227)
The previous cache strategy is left in place for Mac, but it was too expensive for the 10GB limit GitHub imposes on total cache size and was leading to cache thrash. The new strategy sidesteps the cache size limit by creating a cache offline in a data-only image and switching the Linux CI jobs - the lion's share - to run via docker / `./dtox.sh`. It takes ~3 minutes to download the images now whereas loading the cache took ~30 seconds previously, but there is no longer any worry about cache size limits. Obviously running the same thing you run locally in CI is a big benefit and was one of the goals when I introduced `./dtox.sh` in ~2018. The downside of the image load times could possibly be overcome by using the GH cache with docker save / load, but this is good enough for now.
- Loading branch information
Showing
16 changed files
with
425 additions
and
434 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# A data image with the necessary binaries and libraries to develop pex. | ||
|
||
# Populate the ~/.pex_dev cache. | ||
FROM ghcr.io/pantsbuild/pex/base:latest as cache | ||
|
||
ARG PEX_REPO=https:/pantsbuild/pex | ||
ARG GIT_REF=HEAD | ||
|
||
# These must be set as a comma-separated list of all tox envs to cache. | ||
ARG TOX_ENVS | ||
|
||
RUN git clone "${PEX_REPO}" /development/pex && \ | ||
cd /development/pex && \ | ||
git reset --hard "${GIT_REF}" | ||
|
||
WORKDIR /development/pex | ||
COPY populate_cache.sh /root/ | ||
RUN /root/populate_cache.sh /development/pex_dev "${TOX_ENVS}" | ||
|
||
# Grab just the ~/.pex_dev cache files for the final data-only image. | ||
FROM scratch | ||
VOLUME /development/pex_dev | ||
COPY --from=cache /development/pex_dev /development/pex_dev | ||
CMD ["I am a pure data image meant only for volume mounting."] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -xuo pipefail | ||
|
||
if (( $# != 2 )); then | ||
echo >&2 "usage: $0 [pex dev cache dir] [tox env][,tox env]*" | ||
echo >&2 "Expected 2 arguments, got $#: $*" | ||
exit 1 | ||
fi | ||
|
||
function run_tox() { | ||
local env="$1" | ||
tox -e "${env}" -- --color --devpi --require-devpi -vvs | ||
if (( $? == 42 )); then | ||
echo >&2 "tox -e ${env} failed to start or connect to the devpi-server, exiting..." | ||
exit 1 | ||
elif (( $? != 0 )); then | ||
echo >&2 "tox -e ${env} failed, continuing..." | ||
fi | ||
} | ||
|
||
export _PEX_TEST_DEV_ROOT="$1" | ||
for tox_env in $(echo "$2" | tr , ' '); do | ||
run_tox "${tox_env}" | ||
|
||
# Tox test environments can leave quite large /tmp/pytest-of-<user> trees; relieve disk pressure | ||
# by cleaning these up as we go. | ||
rm -rf /tmp/pytest* | ||
done | ||
|
||
echo "Cached ${_PEX_TEST_DEV_ROOT}:" | ||
du -sh "${_PEX_TEST_DEV_ROOT}"/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.