Skip to content

Commit

Permalink
Improve build caching
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schildt <[email protected]>
  • Loading branch information
SebastianSchildt committed May 7, 2024
1 parent ca02fc9 commit 6605ce3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/kuksa_databroker-cli_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ jobs:
~/.cargo/git/db/
~/.cargo/.crates.toml
~/.cargo/.crates2.json
target/
~/.cache/pip/
target-*/
key: databroker-cli-release-${{ matrix.platform.name }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install build prerequisites
working-directory: ${{github.workspace}}/
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/kuksa_databroker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ jobs:
~/.cargo/git/db/
~/.cargo/.crates.toml
~/.cargo/.crates2.json
target/
~/.cache/pip/
target-*/
key: databroker-coverage-${{ hashFiles('**/Cargo.lock') }}
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target/
target-*/
dist/
__pycache__
databroker/thirdparty
Expand Down
19 changes: 7 additions & 12 deletions scripts/build-databroker-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,25 @@ function build_target() {
target_rust=$1
target_docker=$2

# We need to clean this folder in target, otherwise we get weird side
# effects building the aarch image, complaining libc crate can not find
# GLIBC, i.e
# Compiling libc v0.2.149
# Need to set different target dir for different platforms, becasue cargo mixes things up
# when recycling the default target dir. When you do not do this, and e.g. first build amd64
# followed by riscv64 you will get effects like
# Compiling libc v0.2.149
#error: failed to run custom build command for `libc v0.2.149`
#
#Caused by:
# process didn't exit successfully: `/target/release/build/libc-2dd22ab6b5fb9fd2/#build-script-build` (exit status: 1)
# --- stderr
# /target/release/build/libc-2dd22ab6b5fb9fd2/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.29' not found (required by /target/release/build/libc-2dd22ab6b5fb9fd2/build-script-build)
#
# It seems cross/cargo is reusing something from previous builds it shouldn't.
# the finished artifact resides in ../target/x86_64-unknown-linux-musl/release
# so deleting the temporary files in target/release is no problem
echo "Cleaning up...."
rm -rf ./target/release

# this is solved by using different target-dirs for each platform
echo "Building databroker-cli for target $target_rust"
cross build --target $target_rust --features $KUKSA_DATABROKERCLI_FEATURES --bin databroker-cli --release
cross build --target $target_rust --target-dir ./target-$target_docker --features $KUKSA_DATABROKERCLI_FEATURES --bin databroker-cli --release

echo "Prepare $target_docker dist folder"
rm -rf ./dist/$target_docker || true
mkdir ./dist/$target_docker
cp ./target/$target_rust/release/databroker-cli ./dist/$target_docker
cp ./target-$target_docker/$target_rust/release/databroker-cli ./dist/$target_docker

if [[ $SBOM -eq 1 ]]; then
echo "Create $target_rust SBOM"
Expand Down
19 changes: 7 additions & 12 deletions scripts/build-databroker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,30 +99,25 @@ function build_target() {
target_rust=$1
target_docker=$2

# We need to clean this folder in target, otherwise we get weird side
# effects building the aarch image, complaining libc crate can not find
# GLIBC, i.e
# Compiling libc v0.2.149
# Need to set different target dir for different platforms, becasue cargo mixes things up
# when recycling the default target dir. When you do not do this, and e.g. first build amd64
# followed by riscv64 you will get effects like
# Compiling libc v0.2.149
#error: failed to run custom build command for `libc v0.2.149`
#
#Caused by:
# process didn't exit successfully: `/target/release/build/libc-2dd22ab6b5fb9fd2/#build-script-build` (exit status: 1)
# --- stderr
# /target/release/build/libc-2dd22ab6b5fb9fd2/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.29' not found (required by /target/release/build/libc-2dd22ab6b5fb9fd2/build-script-build)
#
# It seems cross/cargo is reusing something from previous builds it shouldn't.
# the finished artifact resides in ../target/x86_64-unknown-linux-musl/release
# so deleting the temporary files in target/release is no problem
echo "Cleaning up...."
rm -rf ./target/release

# this is solved by using different target-dirs for each platform
echo "Building databroker for target $target_rust"
cross build --target $target_rust --features $KUKSA_DATABROKER_FEATURES --bin databroker --release
cross build --target $target_rust --target-dir ./target-$target_docker --features $KUKSA_DATABROKER_FEATURES --bin databroker --release

echo "Prepare $target_docker dist folder"
rm -rf ./dist/$target_docker || true
mkdir ./dist/$target_docker
cp ./target/$target_rust/release/databroker ./dist/$target_docker
cp ./target-$target_docker/$target_rust/release/databroker ./dist/$target_docker

if [[ $SBOM -eq 1 ]]; then
echo "Create $target_rust SBOM"
Expand Down

0 comments on commit 6605ce3

Please sign in to comment.