Skip to content

Commit 4477a50

Browse files
committed
Add extra checks
1 parent 7a35a2e commit 4477a50

File tree

4 files changed

+150
-71
lines changed

4 files changed

+150
-71
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ jobs:
1919
- name: Parse versions from file
2020
id: set-versions
2121
run: |
22-
# Read versions, skip comments and empty lines, output as JSON array
23-
versions=$(grep -v '^ *#' firecracker_versions.txt | grep -v '^$' | jq -R -s -c 'split("\n") | map(select(length > 0))')
22+
versions=$(./scripts/parse-versions.sh firecracker_versions.txt)
2423
echo "versions=$versions" >> $GITHUB_OUTPUT
2524
echo "Building versions: $versions"
2625
@@ -49,10 +48,3 @@ jobs:
4948
name: firecracker-${{ steps.build.outputs.version_name }}
5049
path: builds/
5150
retention-days: 7
52-
53-
- name: Upload version info
54-
uses: actions/upload-artifact@v4
55-
with:
56-
name: version-info-${{ steps.build.outputs.version_name }}
57-
path: built_versions.txt
58-
retention-days: 7

.github/workflows/fc-versions.yml

Lines changed: 29 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,30 @@ jobs:
1717
build:
1818
uses: ./.github/workflows/build.yml
1919

20+
# Check CI status in parallel with builds (for faster feedback)
21+
check-ci:
22+
name: Check FC repo CI status
23+
runs-on: ubuntu-latest
24+
outputs:
25+
ci_passed: ${{ steps.ci-check.outputs.ci_passed }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Check CI status for all versions
30+
id: ci-check
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
run: |
34+
output=$(./scripts/check-fc-ci.sh firecracker_versions.txt)
35+
echo "$output"
36+
# Extract ci_passed from last line
37+
ci_passed=$(echo "$output" | grep "^ci_passed=" | cut -d= -f2)
38+
echo "ci_passed=$ci_passed" >> $GITHUB_OUTPUT
39+
40+
# Collect artifacts and publish (waits for both build and CI check)
2041
publish:
2142
name: Collect and upload builds
22-
needs: build
43+
needs: [build, check-ci]
2344
runs-on: ubuntu-22.04
2445
steps:
2546
- name: Checkout repository
@@ -38,76 +59,22 @@ jobs:
3859
- name: List downloaded builds
3960
run: find builds -type f | head -20
4061

41-
# Download version info to get commit hashes
42-
- name: Download version info
43-
uses: actions/download-artifact@v4
44-
with:
45-
path: version-info
46-
pattern: version-info-*
47-
merge-multiple: true
48-
49-
# Check CI status for all commits (runs on all branches for visibility)
50-
- name: Check CI status for all versions
51-
id: ci-check
52-
env:
53-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
- name: CI check result
5463
run: |
55-
FIRECRACKER_REPO="e2b-dev/firecracker"
56-
all_passed=true
57-
failed_versions=""
58-
59-
# Read all version:hash pairs
60-
for line in $(cat version-info/built_versions.txt 2>/dev/null || echo ""); do
61-
version_name=$(echo "$line" | cut -d: -f1)
62-
commit_hash=$(echo "$line" | cut -d: -f2)
63-
64-
echo "Checking CI for $version_name (commit: $commit_hash)..."
65-
66-
# Check combined commit status
67-
status=$(gh api "/repos/${FIRECRACKER_REPO}/commits/${commit_hash}/status" --jq '.state' 2>/dev/null || echo "unknown")
68-
69-
# Check check-runs (GitHub Actions)
70-
check_conclusion=$(gh api "/repos/${FIRECRACKER_REPO}/commits/${commit_hash}/check-runs" --jq '
71-
if .total_count == 0 then "no_checks"
72-
elif ([.check_runs[].conclusion] | all(. == "success" or . == "skipped" or . == null)) then "success"
73-
elif ([.check_runs[].status] | any(. == "in_progress" or . == "queued")) then "pending"
74-
else "failure"
75-
end
76-
' 2>/dev/null || echo "unknown")
77-
78-
echo " Status: $status, Check runs: $check_conclusion"
79-
80-
if [[ "$status" == "failure" ]] || [[ "$check_conclusion" == "failure" ]]; then
81-
echo " ❌ CI failed for $version_name"
82-
all_passed=false
83-
failed_versions="${failed_versions}${version_name} "
84-
elif [[ "$status" == "pending" ]] || [[ "$check_conclusion" == "pending" ]]; then
85-
echo " ⏳ CI still running for $version_name"
86-
all_passed=false
87-
failed_versions="${failed_versions}${version_name}(pending) "
88-
else
89-
echo " ✅ CI passed for $version_name"
90-
fi
91-
done
92-
93-
if [[ "$all_passed" == "true" ]]; then
94-
echo "All CI checks passed!"
95-
echo "ci_passed=true" >> $GITHUB_OUTPUT
96-
else
97-
echo "CI checks failed or pending for: $failed_versions"
98-
echo "ci_passed=false" >> $GITHUB_OUTPUT
99-
echo "Skipping GCS upload and release creation."
64+
echo "CI check passed: ${{ needs.check-ci.outputs.ci_passed }}"
65+
if [[ "${{ needs.check-ci.outputs.ci_passed }}" != "true" ]]; then
66+
echo "⚠️ CI checks did not pass - skipping GCS upload and release"
10067
fi
10168
10269
- name: Setup Service Account
103-
if: github.ref_name == 'main' && steps.ci-check.outputs.ci_passed == 'true'
70+
if: github.ref_name == 'main' && needs.check-ci.outputs.ci_passed == 'true'
10471
uses: google-github-actions/auth@v2
10572
with:
10673
project_id: ${{ secrets.GCP_PROJECT_ID }}
10774
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
10875

10976
- name: Upload firecrackers to GCS
110-
if: github.ref_name == 'main' && steps.ci-check.outputs.ci_passed == 'true'
77+
if: github.ref_name == 'main' && needs.check-ci.outputs.ci_passed == 'true'
11178
uses: "google-github-actions/upload-cloud-storage@v1"
11279
with:
11380
path: "./builds"
@@ -116,7 +83,7 @@ jobs:
11683
parent: false
11784

11885
- name: Create releases for each Firecracker version
119-
if: github.ref_name == 'main' && steps.ci-check.outputs.ci_passed == 'true'
86+
if: github.ref_name == 'main' && needs.check-ci.outputs.ci_passed == 'true'
12087
env:
12188
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12289
run: |

scripts/check-fc-ci.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/bash
2+
# Check CI status for all Firecracker versions
3+
# Outputs: ci_passed=true|false to stdout (for GitHub Actions)
4+
5+
set -euo pipefail
6+
7+
VERSIONS_FILE="${1:-firecracker_versions.txt}"
8+
FIRECRACKER_REPO_URL="https://github.com/e2b-dev/firecracker.git"
9+
FIRECRACKER_REPO_API="e2b-dev/firecracker"
10+
11+
if [[ ! -f "$VERSIONS_FILE" ]]; then
12+
echo "Error: $VERSIONS_FILE not found" >&2
13+
exit 1
14+
fi
15+
16+
# Clone FC repo to resolve commit hashes
17+
TEMP_DIR=$(mktemp -d)
18+
trap "rm -rf $TEMP_DIR" EXIT
19+
20+
echo "Cloning FC repo to resolve commit hashes..."
21+
git clone --bare "$FIRECRACKER_REPO_URL" "$TEMP_DIR/fc-repo" 2>/dev/null
22+
cd "$TEMP_DIR/fc-repo"
23+
24+
all_passed=true
25+
failed_versions=""
26+
27+
# Read versions from file
28+
while IFS= read -r version || [[ -n "$version" ]]; do
29+
# Skip comments and empty lines
30+
[[ "$version" =~ ^[[:space:]]*# ]] && continue
31+
[[ -z "$version" ]] && continue
32+
33+
echo "Processing version: $version"
34+
35+
# Resolve commit hash
36+
if [[ "$version" =~ ^([^_]+)_([0-9a-fA-F]+)$ ]]; then
37+
# Format: tag_shorthash
38+
tag="${BASH_REMATCH[1]}"
39+
shorthash="${BASH_REMATCH[2]}"
40+
commit_hash=$(git rev-parse --verify "$shorthash^{commit}" 2>/dev/null || echo "")
41+
version_name="${tag}_${shorthash}"
42+
else
43+
# Plain tag
44+
commit_hash=$(git rev-parse --verify "${version}^{commit}" 2>/dev/null || echo "")
45+
if [[ -n "$commit_hash" ]]; then
46+
short_hash=$(git rev-parse --short "$commit_hash")
47+
version_name="${version}_${short_hash}"
48+
else
49+
version_name="$version"
50+
fi
51+
fi
52+
53+
if [[ -z "$commit_hash" ]]; then
54+
echo " ⚠️ Could not resolve commit for $version"
55+
continue
56+
fi
57+
58+
echo " Checking CI for $version_name (commit: $commit_hash)..."
59+
60+
# Check combined commit status
61+
status=$(gh api "/repos/${FIRECRACKER_REPO_API}/commits/${commit_hash}/status" --jq '.state' 2>/dev/null || echo "unknown")
62+
63+
# Check check-runs (GitHub Actions)
64+
# Order matters: check pending BEFORE success (null conclusion means in-progress)
65+
check_conclusion=$(gh api "/repos/${FIRECRACKER_REPO_API}/commits/${commit_hash}/check-runs" --jq '
66+
if .total_count == 0 then "no_checks"
67+
elif ([.check_runs[].status] | any(. == "in_progress" or . == "queued")) then "pending"
68+
elif ([.check_runs[].conclusion] | any(. == "failure" or . == "cancelled" or . == "timed_out")) then "failure"
69+
elif ([.check_runs[].conclusion] | all(. == "success" or . == "skipped" or . == "neutral")) then "success"
70+
else "unknown"
71+
end
72+
' 2>/dev/null || echo "unknown")
73+
74+
echo " Status: $status, Check runs: $check_conclusion"
75+
76+
# Treat unknown as failure (API errors should block release)
77+
if [[ "$status" == "failure" ]] || [[ "$check_conclusion" == "failure" ]]; then
78+
echo " ❌ CI failed for $version_name"
79+
all_passed=false
80+
failed_versions="${failed_versions}${version_name} "
81+
elif [[ "$status" == "pending" ]] || [[ "$check_conclusion" == "pending" ]]; then
82+
echo " ⏳ CI still running for $version_name"
83+
all_passed=false
84+
failed_versions="${failed_versions}${version_name}(pending) "
85+
elif [[ "$status" == "unknown" ]] || [[ "$check_conclusion" == "unknown" ]]; then
86+
echo " ⚠️ Could not verify CI status for $version_name (API error)"
87+
all_passed=false
88+
failed_versions="${failed_versions}${version_name}(unknown) "
89+
elif [[ "$status" == "success" ]] || [[ "$check_conclusion" == "success" ]]; then
90+
echo " ✅ CI passed for $version_name"
91+
else
92+
# Catch-all for unexpected states
93+
echo " ⚠️ Unexpected CI state for $version_name: status=$status, check_conclusion=$check_conclusion"
94+
all_passed=false
95+
failed_versions="${failed_versions}${version_name}(unexpected) "
96+
fi
97+
done < "$OLDPWD/$VERSIONS_FILE"
98+
99+
echo ""
100+
if [[ "$all_passed" == "true" ]]; then
101+
echo "All CI checks passed!"
102+
echo "ci_passed=true"
103+
else
104+
echo "CI checks failed or pending for: $failed_versions"
105+
echo "ci_passed=false"
106+
fi

scripts/parse-versions.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
# Parse versions from firecracker_versions.txt and output as JSON array
3+
4+
set -euo pipefail
5+
6+
VERSIONS_FILE="${1:-firecracker_versions.txt}"
7+
8+
if [[ ! -f "$VERSIONS_FILE" ]]; then
9+
echo "Error: $VERSIONS_FILE not found" >&2
10+
exit 1
11+
fi
12+
13+
# Read versions, skip comments and empty lines, output as JSON array
14+
grep -v '^ *#' "$VERSIONS_FILE" | grep -v '^$' | jq -R -s -c 'split("\n") | map(select(length > 0))'

0 commit comments

Comments
 (0)