Skip to content

Commit d3dc8af

Browse files
committed
Refactor
1 parent 94b51ac commit d3dc8af

File tree

3 files changed

+52
-18
lines changed

3 files changed

+52
-18
lines changed

.github/workflows/build.yml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name: Build Firecracker Versions
22

33
on:
4-
push:
5-
branches: [main]
6-
pull_request:
7-
branches: [main]
4+
workflow_call:
5+
outputs:
6+
versions:
7+
description: "JSON array of versions that were built"
8+
value: ${{ jobs.prepare.outputs.versions }}
89
workflow_dispatch:
910

1011
jobs:
@@ -33,6 +34,32 @@ jobs:
3334
steps:
3435
- uses: actions/checkout@v4
3536

37+
# Set up Docker Buildx for better caching
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v3
40+
41+
# Cache Docker layers
42+
- name: Cache Docker layers
43+
uses: actions/cache@v4
44+
with:
45+
path: /tmp/.buildx-cache
46+
key: docker-buildx-${{ runner.os }}-${{ matrix.version }}-${{ github.sha }}
47+
restore-keys: |
48+
docker-buildx-${{ runner.os }}-${{ matrix.version }}-
49+
docker-buildx-${{ runner.os }}-
50+
51+
# Cache Cargo registry and git dependencies
52+
- name: Cache Cargo
53+
uses: actions/cache@v4
54+
with:
55+
path: |
56+
~/.cargo/registry
57+
~/.cargo/git
58+
key: cargo-${{ runner.os }}-${{ matrix.version }}-${{ github.sha }}
59+
restore-keys: |
60+
cargo-${{ runner.os }}-${{ matrix.version }}-
61+
cargo-${{ runner.os }}-
62+
3663
- name: Build Firecracker ${{ matrix.version }}
3764
run: ./build.sh "${{ matrix.version }}"
3865

.github/workflows/fc-versions.yml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@ name: FC Versions
22

33
on:
44
push:
5+
workflow_dispatch:
56

67
permissions:
78
id-token: write
89
contents: write
910

1011
jobs:
12+
# Run parallel builds via reusable workflow
13+
build:
14+
uses: ./.github/workflows/build.yml
15+
16+
# Collect artifacts and publish
1117
publish:
12-
name: Build Firecracker and upload
18+
name: Collect and upload builds
19+
needs: build
1320
runs-on: ubuntu-22.04
1421
steps:
1522
- name: Checkout repository
@@ -47,23 +54,24 @@ jobs:
4754
- name: Test next version
4855
run: echo "Next version is ${{ steps.get-version.outputs.version }}"
4956

57+
# Download all build artifacts
58+
- name: Download all build artifacts
59+
uses: actions/download-artifact@v4
60+
with:
61+
path: builds
62+
pattern: firecracker-*
63+
merge-multiple: true
64+
65+
- name: List downloaded builds
66+
run: find builds -type f | head -20
67+
5068
- name: Setup Service Account
69+
if: github.ref_name == 'main'
5170
uses: google-github-actions/auth@v2
5271
with:
5372
project_id: ${{ secrets.GCP_PROJECT_ID }}
5473
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
5574

56-
- name: Build firecrackers
57-
run: sudo make build
58-
59-
- name: Upload firecrackers as artifact
60-
if: github.ref_name != 'main'
61-
uses: actions/upload-artifact@v4
62-
with:
63-
name: firecracker-${{ github.run_id }}
64-
path: ./builds
65-
retention-days: 7
66-
6775
- name: Upload firecrackers to GCS
6876
if: github.ref_name == 'main'
6977
uses: "google-github-actions/upload-cloud-storage@v1"
@@ -83,7 +91,6 @@ jobs:
8391
env:
8492
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8593

86-
8794
- name: Prepare release assets
8895
if: github.ref_name == 'main'
8996
run: |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ This project automates the building of custom Firecracker. It supports building
2929

3030
## License
3131

32-
This project is licensed under the Apache License 2.0. See [LICENSE](LICENSE) for details.
32+
This project is licensed under the Apache License 2.0. See [LICENSE](LICENSE) for details.

0 commit comments

Comments
 (0)