Skip to content

Commit 1d90ec2

Browse files
committed
Cleanup
1 parent 9b6acfe commit 1d90ec2

File tree

2 files changed

+7
-37
lines changed

2 files changed

+7
-37
lines changed

.github/workflows/fc-versions.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
version_name: ${{ matrix.version_name }}
3939

4040
check-ci:
41+
needs: prepare
4142
runs-on: ubuntu-latest
4243
outputs:
4344
ci_passed: ${{ steps.ci-check.outputs.ci_passed }}
@@ -48,7 +49,7 @@ jobs:
4849
env:
4950
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5051
run: |
51-
output=$(./scripts/check-fc-ci.sh firecracker_versions.txt)
52+
output=$(./scripts/check-fc-ci.sh '${{ needs.prepare.outputs.matrix }}')
5253
echo "$output"
5354
ci_passed=$(echo "$output" | grep "^ci_passed=" | cut -d= -f2)
5455
echo "ci_passed=$ci_passed" >> $GITHUB_OUTPUT

scripts/check-fc-ci.sh

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,19 @@
22

33
set -euo pipefail
44

5-
VERSIONS_FILE="${1:-firecracker_versions.txt}"
6-
FIRECRACKER_REPO_URL="https://github.com/e2b-dev/firecracker.git"
75
FIRECRACKER_REPO_API="e2b-dev/firecracker"
86

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
119
exit 1
1210
fi
1311

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"
1913

2014
all_passed=true
2115
failed_versions=""
2216

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
4918
status_response=$(gh api "/repos/${FIRECRACKER_REPO_API}/commits/${commit_hash}/status" 2>/dev/null || echo '{"state":"unknown","total_count":0}')
5019
status=$(echo "$status_response" | jq -r '.state')
5120
status_count=$(echo "$status_response" | jq -r '.total_count')
@@ -84,7 +53,7 @@ while IFS= read -r version || [[ -n "$version" ]]; do
8453
all_passed=false
8554
failed_versions="${failed_versions}${version_name}(unexpected) "
8655
fi
87-
done < "$OLDPWD/$VERSIONS_FILE"
56+
done < <(echo "$versions_json" | jq -r '.[] | "\(.version)|\(.hash)|\(.version_name)"')
8857

8958
echo ""
9059
[[ "$all_passed" == "true" ]] && echo "ci_passed=true" || echo "ci_passed=false"

0 commit comments

Comments
 (0)