Skip to content

Commit 547951f

Browse files
committed
Fix caching
1 parent b8df0bf commit 547951f

File tree

5 files changed

+37
-38
lines changed

5 files changed

+37
-38
lines changed

.github/workflows/kuksa_databroker-cli_build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
~/.cargo/.crates.toml
9090
~/.cargo/.crates2.json
9191
~/.cache/pip/
92-
target-*/
92+
target/
9393
key: databroker-cli-release-${{ matrix.platform.name }}-${{ hashFiles('**/Cargo.lock') }}
9494
- name: Install build prerequisites
9595
working-directory: ${{github.workspace}}/

.github/workflows/kuksa_databroker_build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
~/.cargo/.crates.toml
8181
~/.cargo/.crates2.json
8282
~/.cache/pip/
83-
target-*/
83+
target/
8484
key: databroker-coverage-${{ hashFiles('**/Cargo.lock') }}
8585
- name: Install cargo-llvm-cov
8686
uses: taiki-e/install-action@cargo-llvm-cov

scripts/build-databroker-cli.sh

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ echo >${TARGET_MAP}/amd64 x86_64-unknown-linux-musl
6060
# yet supported
6161
echo >${TARGET_MAP}/riscv64 riscv64gc-unknown-linux-gnu
6262

63-
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
64-
65-
6663
# Check if a certain feature set was requested
6764
if [ -z "$KUKSA_DATABROKERCLI_FEATURES" ]; then
6865
# If not set, assign a default value
@@ -71,7 +68,7 @@ fi
7168

7269
SBOM=0
7370
# Check whether to build SBOM
74-
if [ ! -z "$KUKSA_DATABROKERCLI_SBOM" ]; then
71+
if [ -n "$KUKSA_DATABROKERCLI_SBOM" ]; then
7572
# If set, check whether it is "y"
7673
if [[ $KUKSA_DATABROKERCLI_SBOM =~ ^[Yy](es)?$ || $KUKSA_DATABROKER_SBOM =~ ^[Tt](rue)?$ ]]; then
7774
SBOM=1
@@ -91,8 +88,8 @@ echo "Building with features: $KUKSA_DATABROKERCLI_FEATURES"
9188
# Rust target triplett (i.e. x86_64-unknown-linux-musl) and the corresponding docker
9289
# architecture (i.e. amd64) as input
9390
function build_target() {
94-
target_rust=$1
95-
target_docker=$2
91+
target=$1
92+
platform=$2
9693

9794
# Need to set different target dir for different platforms, becasue cargo mixes things up
9895
# when recycling the default target dir. When you do not do this, and e.g. first build amd64
@@ -106,20 +103,22 @@ function build_target() {
106103
# /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)
107104
#
108105
# this is solved by using different target-dirs for each platform
109-
echo "Building databroker-cli for target $target_rust"
110-
cross build --target $target_rust --target-dir ./target-$target_docker --features $KUKSA_DATABROKERCLI_FEATURES --bin databroker-cli --release
106+
echo "Building databroker-cli for target $target"
107+
target_dir="./target/cross-$target"
108+
cross build --target "$target" --target-dir "$target_dir" --features "$KUKSA_DATABROKERCLI_FEATURES" --bin databroker-cli --release
111109

112-
echo "Prepare $target_docker dist folder"
113-
rm -rf ./dist/$target_docker || true
114-
mkdir ./dist/$target_docker
115-
cp ./target-$target_docker/$target_rust/release/databroker-cli ./dist/$target_docker
110+
echo "Prepare $platform dist folder"
111+
dist_dir="./dist/$platform"
112+
rm -rf "$dist_dir" || true
113+
mkdir "$dist_dir"
114+
cp "$target_dir/$target"/release/databroker-cli "$dist_dir"
116115

117116
if [[ $SBOM -eq 1 ]]; then
118-
echo "Create $target_rust SBOM"
119-
cargo cyclonedx -v -f json --describe binaries --spec-version 1.4 --target $target_rust --manifest-path ./Cargo.toml
120-
cp ./databroker-cli/databroker-cli_bin.cdx.json ./dist/$target_docker/sbom.json
121-
rm -rf ./dist/$target_docker/thirdparty-licenses || true
122-
collectlicensefiles ./databroker-cli/databroker-cli_bin.cdx.json ./dist/$target_docker/thirdparty-licenses --curation ./scripts/licensecuration.yaml
117+
echo "Create $target SBOM"
118+
cargo cyclonedx -v -f json --describe binaries --spec-version 1.4 --target "$target" --manifest-path ./Cargo.toml
119+
cp ./databroker-cli/databroker-cli_bin.cdx.json "$dist_dir/sbom.json"
120+
rm -rf "$dist_dir"/thirdparty-licenses || true
121+
collectlicensefiles ./databroker-cli/databroker-cli_bin.cdx.json "$dist_dir"/thirdparty-licenses --curation ./scripts/license_curation.yaml
123122
fi
124123
}
125124

@@ -142,7 +141,7 @@ mkdir -p ./dist
142141
for platform in "$@"
143142
do
144143
target=$(cat ${TARGET_MAP}/$platform)
145-
build_target $target $platform
144+
build_target "$target" "$platform"
146145
done
147146

148147
rm -rf ${TARGET_MAP}

scripts/build-databroker.sh

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ echo >${TARGET_MAP}/amd64 x86_64-unknown-linux-musl
6464
# yet supported
6565
echo >${TARGET_MAP}/riscv64 riscv64gc-unknown-linux-gnu
6666

67-
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
68-
6967
# Check if a certain feature set was requested
7068
if [ -z "$KUKSA_DATABROKER_FEATURES" ]; then
7169
# If not set, assign a default value
@@ -74,7 +72,7 @@ fi
7472

7573
SBOM=0
7674
# Check whether to build SBOM
77-
if [ ! -z "$KUKSA_DATABROKER_SBOM" ]; then
75+
if [ -n "$KUKSA_DATABROKER_SBOM" ]; then
7876
# If set, check whether it is "y"
7977
if [[ $KUKSA_DATABROKER_SBOM =~ ^[Yy](es)?$ || $KUKSA_DATABROKER_SBOM =~ ^[Tt](rue)?$ ]]; then
8078
SBOM=1
@@ -96,8 +94,8 @@ echo "Building with features: $KUKSA_DATABROKER_FEATURES"
9694
# Rust target triplett (i.e. x86_64-unknown-linux-musl) and the corresponding docker
9795
# architecture (i.e. amd64) as input
9896
function build_target() {
99-
target_rust=$1
100-
target_docker=$2
97+
target=$1
98+
platform=$2
10199

102100
# Need to set different target dir for different platforms, becasue cargo mixes things up
103101
# when recycling the default target dir. When you do not do this, and e.g. first build amd64
@@ -111,20 +109,22 @@ function build_target() {
111109
# /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)
112110
#
113111
# this is solved by using different target-dirs for each platform
114-
echo "Building databroker for target $target_rust"
115-
cross build --target $target_rust --target-dir ./target-$target_docker --features $KUKSA_DATABROKER_FEATURES --bin databroker --release
112+
echo "Building databroker for target $target"
113+
target_dir="./target-$platform"
114+
cross build --target "$target" --target-dir "$target_dir" --features "$KUKSA_DATABROKER_FEATURES" --bin databroker --release
116115

117-
echo "Prepare $target_docker dist folder"
118-
rm -rf ./dist/$target_docker || true
119-
mkdir ./dist/$target_docker
120-
cp ./target-$target_docker/$target_rust/release/databroker ./dist/$target_docker
116+
echo "Prepare $platform dist folder"
117+
dist_dir="./dist/$platform"
118+
rm -rf "$dist_dir" || true
119+
mkdir "$dist_dir"
120+
cp "$target_dir/$target"/release/databroker "$dist_dir"
121121

122122
if [[ $SBOM -eq 1 ]]; then
123-
echo "Create $target_rust SBOM"
124-
cargo cyclonedx -v -f json --describe binaries --spec-version 1.4 --target $target_rust --manifest-path ./Cargo.toml
125-
cp ./databroker/databroker_bin.cdx.json ./dist/$target_docker/sbom.json
126-
rm -rf ./dist/$target_docker/thirdparty-licenses || true
127-
collectlicensefiles ./databroker/databroker_bin.cdx.json ./dist/$target_docker/thirdparty-licenses --curation ./scripts/licensecuration.yaml
123+
echo "Create $target SBOM"
124+
cargo cyclonedx -v -f json --describe binaries --spec-version 1.4 --target "$target" --manifest-path ./Cargo.toml
125+
cp ./databroker/databroker_bin.cdx.json "$dist_dir"/sbom.json
126+
rm -rf "$dist_dir"/thirdparty-licenses || true
127+
collectlicensefiles ./databroker/databroker_bin.cdx.json "$dist_dir"/thirdparty-licenses --curation ./scripts/license_curation.yaml
128128
fi
129129
}
130130

@@ -147,8 +147,8 @@ mkdir -p ./dist
147147

148148
for platform in "$@"
149149
do
150-
target=$(cat ${TARGET_MAP}/$platform)
151-
build_target $target $platform
150+
target=$(cat "${TARGET_MAP}/$platform")
151+
build_target "$target" "$platform"
152152
done
153153

154154
rm -rf ${TARGET_MAP}

0 commit comments

Comments
 (0)