Skip to content

Commit

Permalink
cache wasm32 release [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
Buckram123 committed Dec 21, 2023
1 parent 3c9c843 commit a689541
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 deletions.
12 changes: 8 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,20 @@ jobs:
- save_cache:
paths:
- /usr/local/cargo/registry
# Schema artifacts
- framework/target/debug/.fingerprint
- framework/target/debug/build
- framework/target/debug/deps
- modules/target/debug/.fingerprint
- modules/target/debug/build
- modules/target/debug/deps
- framework/target/release/build
- framework/target/release/deps
- modules/target/release/build
- modules/target/release/deps
# wasm builds
- framework/target/wasm32-unknown-unknown/release/.fingerprint
- framework/target/wasm32-unknown-unknown/release/build
- framework/target/wasm32-unknown-unknown/release/deps
- modules/target/wasm32-unknown-unknown/release/.fingerprint
- modules/target/wasm32-unknown-unknown/release/build
- modules/target/wasm32-unknown-unknown/release/deps
key: cargocache-v2-build-rust:1.72.0-{{ checksum "framework/Cargo.lock" }}-{{ checksum "modules/Cargo.lock" }}
- discord/status:
fail_only: true
Expand Down
48 changes: 25 additions & 23 deletions scripts/wasm-all-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ set -e

# Detect the architecture #
if [[ $(arch) == "arm64" ]]; then
image="cosmwasm/rust-optimizer-arm64"
workspace_image="cosmwasm/workspace-optimizer-arm64"
abstract_image="abstractmoney/workspace-optimizer-arm64"
image="cosmwasm/rust-optimizer-arm64"
workspace_image="cosmwasm/workspace-optimizer-arm64"
abstract_image="abstractmoney/workspace-optimizer-arm64"
else
image="cosmwasm/rust-optimizer"
workspace_image="cosmwasm/workspace-optimizer"
abstract_image="abstractmoney/workspace-optimizer"
image="cosmwasm/rust-optimizer"
workspace_image="cosmwasm/workspace-optimizer"
abstract_image="abstractmoney/workspace-optimizer"
fi

starting_dir=$(pwd)
Expand All @@ -29,33 +29,34 @@ rm packages/abstract-interface/artifacts || true

# Create lock file if it does not exist
if [ ! -f Cargo.lock ]; then
cargo generate-lockfile
cargo generate-lockfile
fi

docker rm -v with_code || true
docker rm -v build_with_code || true

# create a dummy container which will hold a volume with config
docker create -v /code --name with_code alpine /bin/true
docker create -v /code -v /target/wasm32-unknown-unknown/release --name with_code alpine /bin/true
# copy a config file into this volume
docker cp Cargo.toml with_code:/code
docker cp Cargo.lock with_code:/code
# copy code into this volume
docker cp ./contracts with_code:/code
docker cp ./packages with_code:/code
# Copy cache if any
docker cp ./target/release/build with_code:/target/release/build || true
docker cp ./target/release/deps with_code:/target/release/deps || true
docker cp ./target/wasm32-unknown-unknown/release/.fingerprint with_code:/target/wasm32-unknown-unknown/release/ || true
docker cp ./target/wasm32-unknown-unknown/release/build with_code:/target/wasm32-unknown-unknown/release/ || true
docker cp ./target/wasm32-unknown-unknown/release/deps with_code:/target/wasm32-unknown-unknown/release/ || true
docker cp /usr/local/cargo/registry with_code:/usr/local/cargo/registry || true
# Run the build
docker run --name build_with_code --volumes-from with_code ${abstract_image}:0.15.0
# Copy the artifacts back out
docker cp with_code:/code/artifacts/ .
# Copy cache back out
mkdir -p ./target/release/build
mkdir -p ./target/release/deps
docker cp build_with_code:/target/release/build ./target/release/build
docker cp build_with_code:/target/release/deps ./target/release/deps
mkdir -p ./target/wasm32-unknown-unknown/release
docker cp build_with_code:/target/wasm32-unknown-unknown/release/.fingerprint ./target/wasm32-unknown-unknown/release
docker cp build_with_code:/target/wasm32-unknown-unknown/release/build ./target/wasm32-unknown-unknown/release
docker cp build_with_code:/target/wasm32-unknown-unknown/release/deps ./target/wasm32-unknown-unknown/release
ls artifacts

cd $starting_dir
Expand All @@ -66,7 +67,7 @@ docker rm -v modules_with_code || true
docker rm -v build_modules_with_code || true

# create a dummy container which will hold a volume with config
docker create -v /code -v /integrations -v /framework --name modules_with_code alpine /bin/true
docker create -v /code -v /integrations -v /framework -v /target/wasm32-unknown-unknown/release --name modules_with_code alpine /bin/true

# copy directories to container.
docker cp ./integrations modules_with_code:/
Expand All @@ -77,7 +78,7 @@ cd ./modules

# Create lock file if it does not exist
if [ ! -f Cargo.lock ]; then
cargo generate-lockfile
cargo generate-lockfile
fi

# Delete the current artifacts folder.
Expand All @@ -86,20 +87,21 @@ fi
docker cp Cargo.toml modules_with_code:/code
docker cp Cargo.lock modules_with_code:/code
# Copy cache if any
docker cp ./target/release/build modules_with_code:/target/release/build || true
docker cp ./target/release/build modules_with_code:/target/release/deps || true
docker cp ./target/wasm32-unknown-unknown/release/.fingerprint modules_with_code:/target/wasm32-unknown-unknown/release/ || true
docker cp ./target/wasm32-unknown-unknown/release/build modules_with_code:/target/wasm32-unknown-unknown/release/ || true
docker cp ./target/wasm32-unknown-unknown/release/deps modules_with_code:/target/wasm32-unknown-unknown/release/ || true
docker cp /usr/local/cargo/registry modules_with_code:/usr/local/cargo/registry || true
# copy code into this volume
docker cp ./contracts modules_with_code:/code

# Run the build
docker run --name build_modules_with_code --volumes-from modules_with_code ${abstract_image}:0.15.0
docker run --name build_modules_with_code --volumes-from modules_with_code ${abstract_image}:0.15.0
# Copy the artifacts back out
docker cp modules_with_code:/code/artifacts/ .
# Copy cache back out
mkdir -p ./target/release/build
mkdir -p ./target/release/deps
docker cp build_modules_with_code:/target/release/build ./target/release/build
docker cp build_modules_with_code:/target/release/deps ./target/release/deps
mkdir -p ./target/wasm32-unknown-unknown/release
docker cp build_modules_with_code:/target/wasm32-unknown-unknown/release/.fingerprint ./target/wasm32-unknown-unknown/release
docker cp build_modules_with_code:/target/wasm32-unknown-unknown/release/build ./target/wasm32-unknown-unknown/release
docker cp build_modules_with_code:/target/wasm32-unknown-unknown/release/deps ./target/wasm32-unknown-unknown/release
ls artifacts
cd $starting_dir

0 comments on commit a689541

Please sign in to comment.