Skip to content

Commit

Permalink
Fix kicker manual_build
Browse files Browse the repository at this point in the history
Diskspace is limited in GitHub Actions, so we need to manually clean the middle artifacts
  • Loading branch information
Flouse committed Oct 15, 2023
1 parent 66b1a1a commit b6e8201
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions kicker
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

set -o errexit

# FIXME
GITHUB_ACTIONS_CLEAN_MID_ARTIFACTS=true
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
if [ "$CI" = "true" ] && [ -n "$GITHUB_RUN_ID" ]; then
echo "This script is running in GitHub Actions. GITHUB_RUN_ID: $GITHUB_RUN_ID"

# Diskspace is limited in GitHub Actions, so we need to manually clean the middle artifacts
GITHUB_ACTIONS_CLEAN_MID_ARTIFACTS=true
fi

EXECUTABLE=$0
WORKSPACE="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

Expand Down Expand Up @@ -486,6 +496,10 @@ function manual_build() {
$srcdir/node_modules \
$srcdir/yarn.lock \
$dstdir

if [[ "$GITHUB_ACTIONS_CLEAN_MID_ARTIFACTS" = "true" ]]; then
erun sudo rm -rf $srcdir/node_modules
fi
else
info "skip building godwoken-web3"
fi
Expand Down Expand Up @@ -518,7 +532,9 @@ function manual_build() {
erun cp $srcdir/web3/target/debug/gw-web3-indexer $dstdir

# Remove Rust target to avoid `out of disk` issue in CI
sudo rm -rf $srcdir/target
if [[ "$GITHUB_ACTIONS_CLEAN_MID_ARTIFACTS" = "true" ]]; then
sudo rm -rf $srcdir/web3/target
fi
else
info "skip building godwoken-web3-indexer (gw-web3-indexer)"
fi
Expand All @@ -534,29 +550,32 @@ function manual_build() {

# Cargo fetch Rust dependencies (in order to access network via
# host network).
erun "cd $srcdir && CARGO_HOME=$WORKSPACE/packages/.cargo cargo fetch --locked && cd -"

# Note:
# 1. The docker image must have installed cargo and molecule
# 2. The builtin consensus config and binaries are not required on a
# Godwoken devnet, so `--features gw-config/no-builtin` is appended
# to `cargo build` arguments.
erun docker run \
--rm \
erun docker run --rm \
--env CARGO_HOME=$WORKSPACE/packages/.cargo \
--volume $srcdir:/app \
--volume $WORKSPACE/packages/.rustup:/root/.rustup \
--workdir /app \
godwoken \
cargo build --locked --release --features gw-config/no-builtin
$DOCKER_MANUAL_BUILD_IMAGE \
cargo build --locked --features gw-config/no-builtin

# Copy the built artifacts to `docker/manual-artifacts/`
#
# More: ./docker/manual-godwoken.compose.yml
erun mkdir -p $dstdir
erun cp $srcdir/target/release/godwoken $dstdir
erun cp $srcdir/target/release/gw-tools $dstdir
erun cp $srcdir/target/debug/godwoken $dstdir
erun cp $srcdir/target/debug/gw-tools $dstdir

# Remove Rust target to avoid `out of disk` issue in CI
sudo rm -rf $srcdir/target/release
if [[ "$GITHUB_ACTIONS_CLEAN_MID_ARTIFACTS" = "true" ]]; then
sudo rm -rf $srcdir/target
fi
else
info "skip building Godwoken"
fi
Expand Down Expand Up @@ -611,7 +630,12 @@ function manual_build() {
info "skip building Scripts"
fi

docker rmi $DOCKER_MANUAL_BUILD_IMAGE
if [[ "$GITHUB_ACTIONS_CLEAN_MID_ARTIFACTS" = "true" ]]; then
docker images --format '{{.Repository}}:{{.Tag}}' \
| grep '$DOCKER_MANUAL_BUILD_IMAGE' | xargs docker rmi \
&& echo "Image removed." \
|| echo "Image does not exist."
fi

info "End building." | tee --append /tmp/kicker.log
du -hd6 $WORKSPACE | egrep G | tee --append /tmp/kicker.log
Expand Down

0 comments on commit b6e8201

Please sign in to comment.