-
Notifications
You must be signed in to change notification settings - Fork 9
[WIP] Add Prow CI scripts and OWNERS #218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| approvers: | ||
| - agonzalezrh | ||
| - carbonin | ||
| - danielerez | ||
| - eliorerz | ||
| - eurijon | ||
| - javipolo | ||
| - maorfr | ||
| - mlorenzofr | ||
| - rporres | ||
| reviewers: | ||
| - agonzalezrh | ||
| - carbonin | ||
| - danielerez | ||
| - eliorerz | ||
| - eurijon | ||
| - javipolo | ||
| - maorfr | ||
| - mlorenzofr | ||
| - rporres |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| #!/usr/bin/env bash | ||
| # Build and optionally push the enclave distribution tarball. | ||
| # | ||
| # Usage: | ||
| # scripts/ci/build_tarball.sh build # Build and validate only | ||
| # scripts/ci/build_tarball.sh build-push # Build, validate, and push to Quay | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| ACTION="${1:-build}" | ||
|
|
||
| TAG="${TARBALL_TAG:-$(git rev-parse --short HEAD 2>/dev/null || echo dev)}" | ||
| TARBALL="enclave.tar.gz" | ||
| MAX_SIZE=1073741824 # 1GB | ||
|
|
||
| # --- Build --- | ||
|
|
||
| cleanup() { | ||
| rm -f .version /tmp/tarball-contents.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| echo "Building distribution tarball..." | ||
| echo -n "$TAG" > .version | ||
|
|
||
| tar --exclude='.git' --exclude='.gitignore' --exclude='.github' --exclude='scripts' \ | ||
| --exclude='Makefile.ci' --exclude="$TARBALL" \ | ||
| -czvf "/tmp/$TARBALL" . | ||
| mv "/tmp/$TARBALL" . | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| echo "" | ||
| echo "Validating tarball..." | ||
|
|
||
| # Check size | ||
| SIZE=$(stat -c%s "$TARBALL") | ||
| echo "Tarball size: $(numfmt --to=iec-i --suffix=B "$SIZE")" | ||
| if [ "$SIZE" -gt "$MAX_SIZE" ]; then | ||
| echo "Error: Tarball exceeds 1GB" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Extract file list | ||
| tar -tzf "$TARBALL" > /tmp/tarball-contents.txt | ||
|
|
||
| # Check required files | ||
| REQUIRED_FILES=(".version" "Makefile") | ||
| for file in "${REQUIRED_FILES[@]}"; do | ||
| if ! grep -q "^\./${file}$" /tmp/tarball-contents.txt; then | ||
| echo "Error: Required file '${file}' not found in tarball" | ||
|
Comment on lines
+47
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
cat >/tmp/grep-check.txt <<'EOF'
./agit/example.txt
./.github/workflows/x.yml
EOF
echo "Current regex check (should NOT match .git/, but does):"
if grep -q '^\./.git/' /tmp/grep-check.txt; then
echo "false-positive reproduced"
else
echo "no match"
fi
echo "Fixed string check:"
if grep -Fq './.git/' /tmp/grep-check.txt; then
echo "matched"
else
echo "correctly no match"
fiRepository: rh-ecosystem-edge/enclave Length of output: 189 🏁 Script executed: sed -n '40,80p' scripts/ci/build_tarball.shRepository: rh-ecosystem-edge/enclave Length of output: 1316 🏁 Script executed: # Also check the variable assignments for REQUIRED_FILES and EXCLUDED_PATHS
grep -n "REQUIRED_FILES\|EXCLUDED_PATHS" scripts/ci/build_tarball.shRepository: rh-ecosystem-edge/enclave Length of output: 258 Use fixed-string matching for tarball path assertions. Lines 48 and 72 interpolate filenames/paths into regex patterns without escaping. Entries like 🛠️ Proposed fix for file in "${REQUIRED_FILES[@]}"; do
- if ! grep -q "^\./${file}$" /tmp/tarball-contents.txt; then
+ if ! grep -Fxq "./${file}" /tmp/tarball-contents.txt; then
echo "Error: Required file '${file}' not found in tarball"
head -20 /tmp/tarball-contents.txt
exit 1
@@
for path in "${EXCLUDED_PATHS[@]}"; do
- if grep -q "^\./${path}" /tmp/tarball-contents.txt; then
+ if grep -Fq "./${path}" /tmp/tarball-contents.txt; then
echo "Error: Excluded path '${path}' found in tarball"
exit 1
fi🤖 Prompt for AI Agents |
||
| head -20 /tmp/tarball-contents.txt | ||
| exit 1 | ||
| fi | ||
| echo " Found ${file}" | ||
| done | ||
|
|
||
| # Check required directories (only if they exist in source) | ||
| REQUIRED_DIRS=("playbooks" "operators" "configs") | ||
| for dir in "${REQUIRED_DIRS[@]}"; do | ||
| if [ -d "$dir" ]; then | ||
| if ! grep -q "^\./${dir}/" /tmp/tarball-contents.txt; then | ||
| echo "Error: Required directory '${dir}/' not found in tarball" | ||
| head -20 /tmp/tarball-contents.txt | ||
| exit 1 | ||
| fi | ||
| echo " Found ${dir}/" | ||
| fi | ||
| done | ||
|
|
||
| # Check excluded paths are absent | ||
| EXCLUDED_PATHS=(".git/" ".github/" "Makefile.ci" "scripts/") | ||
| for path in "${EXCLUDED_PATHS[@]}"; do | ||
| if grep -q "^\./${path}" /tmp/tarball-contents.txt; then | ||
| echo "Error: Excluded path '${path}' found in tarball" | ||
| exit 1 | ||
| fi | ||
| echo " ${path} correctly excluded" | ||
| done | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| # Validate file counts for critical directories | ||
| echo "Validating file counts..." | ||
| for dir in "${REQUIRED_DIRS[@]}"; do | ||
| if [ -d "$dir" ]; then | ||
| SOURCE_COUNT=$(find "$dir" -type f | wc -l) | ||
| TARBALL_COUNT=$(grep "^\./${dir}/" /tmp/tarball-contents.txt | grep -v '/$' | wc -l) | ||
| echo " ${dir}/: source=${SOURCE_COUNT}, tarball=${TARBALL_COUNT}" | ||
| if [ "$SOURCE_COUNT" -ne "$TARBALL_COUNT" ]; then | ||
| echo "Error: File count mismatch in ${dir}/" | ||
| echo " Expected: ${SOURCE_COUNT} files" | ||
| echo " Found in tarball: ${TARBALL_COUNT} files" | ||
| exit 1 | ||
| fi | ||
| fi | ||
| done | ||
|
|
||
| echo "Tarball validation passed" | ||
|
|
||
| # --- Push (optional) --- | ||
|
|
||
| if [ "$ACTION" = "build-push" ]; then | ||
| if [ -z "${QUAY_USER:-}" ] || [ -z "${QUAY_TOKEN:-}" ]; then | ||
| echo "Error: QUAY_USER and QUAY_TOKEN must be set" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "$QUAY_TOKEN" | podman login quay.io -u "$QUAY_USER" --password-stdin | ||
|
|
||
| echo "Pushing tarball with tag: $TAG" | ||
| oras push "quay.io/edge-infrastructure/enclave:${TAG}" \ | ||
| "${TARBALL}:application/vnd.oci.image.layer.v1.tar+gzip" | ||
|
|
||
| rm -f "$TARBALL" | ||
| echo "Tarball pushed successfully" | ||
| elif [ "$ACTION" = "build" ]; then | ||
| echo "Tarball built: $TARBALL" | ||
| else | ||
| echo "Unknown action: $ACTION" | ||
| echo "Usage: $0 build|build-push" | ||
| exit 1 | ||
| fi | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fail fast on invalid
ACTIONbefore building artifacts.Invalid values currently run build+validation first, then fail at the end. Validate
ACTIONimmediately after parsing.🛠️ Proposed fix
ACTION="${1:-build}" +case "$ACTION" in + build|build-push) ;; + *) + echo "Unknown action: $ACTION" + echo "Usage: $0 build|build-push" + exit 1 + ;; +esac @@ if [ "$ACTION" = "build-push" ]; then @@ elif [ "$ACTION" = "build" ]; then echo "Tarball built: $TARBALL" -else - echo "Unknown action: $ACTION" - echo "Usage: $0 build|build-push" - exit 1 fiAlso applies to: 23-33, 99-118
🤖 Prompt for AI Agents