Skip to content

Commit 28113ab

Browse files
internal change
PiperOrigin-RevId: 954666515
1 parent 4fb0cab commit 28113ab

4 files changed

Lines changed: 107 additions & 5 deletions

File tree

‎kokoro/axt_attest_artifacts.cfg‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# proto-file: google3/devtools/kokoro/config/proto/build.proto
2+
# proto-message: BuildConfig
3+
4+
build_file: "piper/google3/third_party/android/androidx_test/kokoro/axt_attest_artifacts.sh"
5+
6+
action {
7+
define_artifacts {
8+
regex: "output_dir/axt_m2repository_unsigned_and_attested.zip"
9+
strip_prefix: "output_dir"
10+
fail_if_no_artifacts: true
11+
}
12+
}

‎kokoro/axt_attest_artifacts.sh‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
3+
# Fail on any error.
4+
set -e
5+
6+
mkdir -p "${KOKORO_ARTIFACTS_DIR}/output_dir"
7+
cd "${KOKORO_ARTIFACTS_DIR}/output_dir"
8+
9+
GCS_BUCKET="androidx-test-staging/release"
10+
ATTESTATION_FILE="attestation.intoto.jsonl"
11+
INPUT_ZIP="axt_m2repository_unsigned.zip"
12+
OUTPUT_ZIP="axt_m2repository_unsigned_and_attested.zip"
13+
14+
# 1. Find the full GCS path of the zip file
15+
ZIP_GCS_PATH=$(gcloud storage ls "gs://${GCS_BUCKET}/*/*/${CANDIDATE_NAME}/axt_m2repository_unsigned.zip" | head -n 1)
16+
17+
if [[ -z "${ZIP_GCS_PATH}" ]]; then
18+
echo "Error: Could not find the zip file for candidate ${CANDIDATE_NAME}."
19+
exit 1
20+
fi
21+
22+
# 2. Extract the parent path: gs://[BUCKET_NAME]/[timestamp]/[build id]
23+
# Removes '/axt_m2repository_unsigned.zip'
24+
DIR_PATH="${ZIP_GCS_PATH%/*}"
25+
# Removes '/[CANDIDATE_NAME]'
26+
DIR_PATH="${DIR_PATH%/*}"
27+
28+
echo "Target build directory identified: ${DIR_PATH}"
29+
30+
# 3. Download and rename the ZIP file to current working directory
31+
echo "Downloading zip file..."
32+
gcloud storage cp "${ZIP_GCS_PATH}" "./${INPUT_ZIP}"
33+
34+
# 4. Download and rename the attestation file
35+
if gcloud storage ls "${DIR_PATH}/${CANDIDATE_NAME}.intoto.jsonl" > /dev/null 2>&1; then
36+
echo "Downloading attestation..."
37+
gcloud storage cp "${DIR_PATH}/${CANDIDATE_NAME}.intoto.jsonl" "./${ATTESTATION_FILE}"
38+
else
39+
echo "Error: Could not find an attestation file in ${DIR_PATH}"
40+
exit 1
41+
fi
42+
43+
SCRATCH_DIR=$(mktemp -d -t axt_attest_XXXXXX)
44+
45+
echo "Unzipping $INPUT_ZIP to temporary directory..."
46+
unzip -q "$INPUT_ZIP" -d "$SCRATCH_DIR"
47+
48+
echo "Scanning for .pom files..."
49+
find "$SCRATCH_DIR" -type f -name "*.pom" | while IFS= read -r pom_path; do
50+
pom_dir=$(dirname "$pom_path")
51+
pom_filename=$(basename "$pom_path")
52+
53+
# Remove .pom extension to get artifactid-version
54+
artifact_prefix="${pom_filename%.pom}"
55+
56+
target_attestation="$pom_dir/$artifact_prefix.intoto.jsonl"
57+
58+
cp "$ATTESTATION_FILE" "$target_attestation"
59+
echo "Added attestation: $target_attestation"
60+
done
61+
62+
echo "Re-zipping content to $OUTPUT_ZIP..."
63+
OUTPUT_ZIP_ABS="$(pwd)/$OUTPUT_ZIP"
64+
65+
# Delete output zip if it already exists to avoid appending
66+
rm -f "$OUTPUT_ZIP_ABS"
67+
68+
(cd "$SCRATCH_DIR" && zip -r -q "$OUTPUT_ZIP_ABS" .)
69+
70+
echo "Success! Created $OUTPUT_ZIP"

‎kokoro/axt_build_artifacts.cfg‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
1+
# proto-file: google3/devtools/kokoro/config/proto/build.proto
2+
# proto-message: BuildConfig
3+
14
build_file: "android-test-releases/kokoro/build_artifacts.sh"
25

3-
action {
4-
define_artifacts {
5-
regex: "github/android-test-releases/axt_m2repository_unsigned.zip"
6-
strip_prefix: "github/android-test-releases"
7-
fail_if_no_artifacts: true
6+
fileset_artifacts {
7+
# make the generated attestation bundle name equal to the Rapid candidate name
8+
name: "$[CANDIDATE_NAME]"
9+
10+
# Globs replace the legacy 'regex' field.
11+
artifact_globs: "github/android-test-releases/axt_m2repository_unsigned.zip"
12+
13+
# Removes the directory path prefix from the artifact output.
14+
strip_prefix: "github/android-test-releases"
15+
16+
# Fails the build if the zip file is not generated
17+
error_if_missing: true
18+
19+
destinations {
20+
store_attestation: true
21+
22+
gcs {
23+
gcs_root_path: "androidx-test-staging/release"
24+
}
825
}
926
}

‎kokoro/axt_test_artifacts.cfg‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# proto-file: google3/devtools/kokoro/config/proto/build.proto
2+
# proto-message: BuildConfig
3+
14
build_file: "android-test-releases/kokoro/test_artifacts.sh"
25

36
gfile_resources: "/bigstore/androidx-test-staging/release/axt_m2repository.zip"

0 commit comments

Comments
 (0)