|
2 | 2 |
|
3 | 3 | set -euo pipefail |
4 | 4 |
|
5 | | -VERSIONS_FILE="${1:-firecracker_versions.txt}" |
6 | | -FIRECRACKER_REPO_URL="https://github.com/e2b-dev/firecracker.git" |
7 | 5 | FIRECRACKER_REPO_API="e2b-dev/firecracker" |
8 | 6 |
|
9 | | -if [[ ! -f "$VERSIONS_FILE" ]]; then |
10 | | - echo "Error: $VERSIONS_FILE not found" >&2 |
| 7 | +if [[ $# -lt 1 ]]; then |
| 8 | + echo "Usage: $0 <versions_json>" >&2 |
11 | 9 | exit 1 |
12 | 10 | fi |
13 | 11 |
|
14 | | -TEMP_DIR=$(mktemp -d) |
15 | | -trap "rm -rf $TEMP_DIR" EXIT |
16 | | - |
17 | | -git clone --bare "$FIRECRACKER_REPO_URL" "$TEMP_DIR/fc-repo" 2>/dev/null |
18 | | -cd "$TEMP_DIR/fc-repo" |
| 12 | +versions_json="$1" |
19 | 13 |
|
20 | 14 | all_passed=true |
21 | 15 | failed_versions="" |
22 | 16 |
|
23 | | -while IFS= read -r version || [[ -n "$version" ]]; do |
24 | | - [[ "$version" =~ ^[[:space:]]*# ]] && continue |
25 | | - [[ -z "$version" ]] && continue |
26 | | - |
27 | | - if [[ "$version" =~ ^([^_]+)_([0-9a-fA-F]+)$ ]]; then |
28 | | - tag="${BASH_REMATCH[1]}" |
29 | | - shorthash="${BASH_REMATCH[2]}" |
30 | | - commit_hash=$(git rev-parse --verify "$shorthash^{commit}" 2>/dev/null || echo "") |
31 | | - version_name="${tag}_${shorthash}" |
32 | | - else |
33 | | - commit_hash=$(git rev-parse --verify "${version}^{commit}" 2>/dev/null || echo "") |
34 | | - if [[ -n "$commit_hash" ]]; then |
35 | | - short_hash=$(git rev-parse --short "$commit_hash") |
36 | | - version_name="${version}_${short_hash}" |
37 | | - else |
38 | | - version_name="$version" |
39 | | - fi |
40 | | - fi |
41 | | - |
42 | | - if [[ -z "$commit_hash" ]]; then |
43 | | - echo " ❌ Could not resolve commit for $version" |
44 | | - all_passed=false |
45 | | - failed_versions="${failed_versions}${version}(unresolved) " |
46 | | - continue |
47 | | - fi |
48 | | - |
| 17 | +while IFS='|' read -r version commit_hash version_name; do |
49 | 18 | status_response=$(gh api "/repos/${FIRECRACKER_REPO_API}/commits/${commit_hash}/status" 2>/dev/null || echo '{"state":"unknown","total_count":0}') |
50 | 19 | status=$(echo "$status_response" | jq -r '.state') |
51 | 20 | status_count=$(echo "$status_response" | jq -r '.total_count') |
@@ -84,7 +53,7 @@ while IFS= read -r version || [[ -n "$version" ]]; do |
84 | 53 | all_passed=false |
85 | 54 | failed_versions="${failed_versions}${version_name}(unexpected) " |
86 | 55 | fi |
87 | | -done < "$OLDPWD/$VERSIONS_FILE" |
| 56 | +done < <(echo "$versions_json" | jq -r '.[] | "\(.version)|\(.hash)|\(.version_name)"') |
88 | 57 |
|
89 | 58 | echo "" |
90 | 59 | [[ "$all_passed" == "true" ]] && echo "ci_passed=true" || echo "ci_passed=false" |
0 commit comments