Skip to content

Commit 1253e0b

Browse files
committed
Fix ci checks
1 parent 2707785 commit 1253e0b

File tree

3 files changed

+80
-8
lines changed

3 files changed

+80
-8
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ jobs:
3838
id: build
3939
run: |
4040
./build.sh "${{ matrix.version }}"
41-
# Read the computed version name (with hash)
42-
version_name=$(cat built_versions.txt | tail -1)
41+
# Read the computed version name (with hash) - format is "version_name:commit_hash"
42+
version_info=$(cat built_versions.txt | tail -1)
43+
version_name=$(echo "$version_info" | cut -d: -f1)
4344
echo "version_name=$version_name" >> $GITHUB_OUTPUT
4445
4546
- name: Upload build artifact
@@ -48,3 +49,10 @@ jobs:
4849
name: firecracker-${{ steps.build.outputs.version_name }}
4950
path: builds/
5051
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: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,77 @@ jobs:
3838
- name: List downloaded builds
3939
run: find builds -type f | head -20
4040

41-
- name: Setup Service Account
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 before publishing
50+
- name: Check CI status for all versions
51+
id: ci-check
4252
if: github.ref_name == 'main'
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
run: |
56+
FIRECRACKER_REPO="e2b-dev/firecracker"
57+
all_passed=true
58+
failed_versions=""
59+
60+
# Read all version:hash pairs
61+
for line in $(cat version-info/built_versions.txt 2>/dev/null || echo ""); do
62+
version_name=$(echo "$line" | cut -d: -f1)
63+
commit_hash=$(echo "$line" | cut -d: -f2)
64+
65+
echo "Checking CI for $version_name (commit: $commit_hash)..."
66+
67+
# Check combined commit status
68+
status=$(gh api "/repos/${FIRECRACKER_REPO}/commits/${commit_hash}/status" --jq '.state' 2>/dev/null || echo "unknown")
69+
70+
# Check check-runs (GitHub Actions)
71+
check_conclusion=$(gh api "/repos/${FIRECRACKER_REPO}/commits/${commit_hash}/check-runs" --jq '
72+
if .total_count == 0 then "no_checks"
73+
elif ([.check_runs[].conclusion] | all(. == "success" or . == "skipped" or . == null)) then "success"
74+
elif ([.check_runs[].status] | any(. == "in_progress" or . == "queued")) then "pending"
75+
else "failure"
76+
end
77+
' 2>/dev/null || echo "unknown")
78+
79+
echo " Status: $status, Check runs: $check_conclusion"
80+
81+
if [[ "$status" == "failure" ]] || [[ "$check_conclusion" == "failure" ]]; then
82+
echo " ❌ CI failed for $version_name"
83+
all_passed=false
84+
failed_versions="${failed_versions}${version_name} "
85+
elif [[ "$status" == "pending" ]] || [[ "$check_conclusion" == "pending" ]]; then
86+
echo " ⏳ CI still running for $version_name"
87+
all_passed=false
88+
failed_versions="${failed_versions}${version_name}(pending) "
89+
else
90+
echo " ✅ CI passed for $version_name"
91+
fi
92+
done
93+
94+
if [[ "$all_passed" == "true" ]]; then
95+
echo "All CI checks passed!"
96+
echo "ci_passed=true" >> $GITHUB_OUTPUT
97+
else
98+
echo "CI checks failed or pending for: $failed_versions"
99+
echo "ci_passed=false" >> $GITHUB_OUTPUT
100+
echo "Skipping GCS upload and release creation."
101+
fi
102+
103+
- name: Setup Service Account
104+
if: github.ref_name == 'main' && steps.ci-check.outputs.ci_passed == 'true'
43105
uses: google-github-actions/auth@v2
44106
with:
45107
project_id: ${{ secrets.GCP_PROJECT_ID }}
46108
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
47109

48110
- name: Upload firecrackers to GCS
49-
if: github.ref_name == 'main'
111+
if: github.ref_name == 'main' && steps.ci-check.outputs.ci_passed == 'true'
50112
uses: "google-github-actions/upload-cloud-storage@v1"
51113
with:
52114
path: "./builds"
@@ -55,7 +117,7 @@ jobs:
55117
parent: false
56118

57119
- name: Create releases for each Firecracker version
58-
if: github.ref_name == 'main'
120+
if: github.ref_name == 'main' && steps.ci-check.outputs.ci_passed == 'true'
59121
env:
60122
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61123
run: |

build.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ function build_version {
3636
echo "Starting build for Firecracker at commit: $version"
3737
echo "Checking out repo for Firecracker at commit: $version"
3838
git checkout "${version}"
39+
40+
fullhash=$(git rev-parse HEAD)
3941
# The format will be: latest_tag_latest_commit_hash — v1.7.0-dev_g8bb88311
40-
version_name=$(git describe --tags --abbrev=0 "$(git rev-parse HEAD)")_$(git rev-parse --short HEAD)
42+
version_name=$(git describe --tags --abbrev=0 "$fullhash")_$(git rev-parse --short HEAD)
4143
fi
4244

4345
echo "Version name: $version_name"
@@ -50,8 +52,8 @@ function build_version {
5052
mkdir -p "../builds/${version_name}"
5153
cp build/cargo_target/x86_64-unknown-linux-musl/release/firecracker "../builds/${version_name}/firecracker"
5254

53-
# Write version name to file for CI to use
54-
echo "$version_name" >> ../built_versions.txt
55+
# Write version name and commit hash to file for CI to use
56+
echo "${version_name}:${fullhash}" >> ../built_versions.txt
5557
}
5658

5759
# If a version is passed as argument, build only that version

0 commit comments

Comments
 (0)