Skip to content

Commit db7f297

Browse files
chaodu-agentchaodu-agent
andauthored
refactor(ci): build oab binary once per arch, fan out lightweight packaging (#1242)
Previously, all 30 matrix jobs (15 agents × 2 architectures) each ran a full Docker multi-stage build that compiled the Rust binary from source. Even with GHA cache, the builder stage was duplicated across 30 separate cache scopes. This refactor: - Adds a 'compile' job (2 parallel: amd64 + arm64) that builds openab, openab-agent, and agy-acp binaries and uploads as artifact - Introduces Dockerfile.package that copies pre-built binaries (COPY --from=bins) instead of compiling from source - The 'build' matrix jobs now only do lightweight image packaging (install agent CLI + copy binary), no Rust compilation Co-authored-by: chaodu-agent <chaodu-agent@openab.dev>
1 parent b4b1060 commit db7f297

2 files changed

Lines changed: 458 additions & 6 deletions

File tree

.github/workflows/pre-beta-build.yml

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ jobs:
3535
return;
3636
}
3737
// Scheduled run: build only if main got a commit in the last ~70min.
38-
// 70 (not 60) absorbs GitHub's cron scheduling drift so a commit just
39-
// before the hour isn't missed when the run fires a few minutes late.
4038
const since = new Date(Date.now() - 70 * 60 * 1000).toISOString();
4139
const { data: commits } = await github.rest.repos.listCommits({
4240
owner: context.repo.owner,
@@ -68,8 +66,69 @@ jobs:
6866
echo "agents=${JSON}" >> "$GITHUB_OUTPUT"
6967
echo "Building: $AGENTS"
7068
69+
# ---------------------------------------------------------------------------
70+
# Compile openab (and openab-agent, agy-acp) once per architecture.
71+
# Uploads pre-built binaries as artifacts for the packaging jobs.
72+
# ---------------------------------------------------------------------------
73+
compile:
74+
needs: [gate, matrix]
75+
if: needs.gate.outputs.should_run == 'true'
76+
strategy:
77+
fail-fast: false
78+
matrix:
79+
platform:
80+
- { os: linux/amd64, runner: ubuntu-latest, arch: amd64 }
81+
- { os: linux/arm64, runner: ubuntu-24.04-arm, arch: arm64 }
82+
runs-on: ${{ matrix.platform.runner }}
83+
permissions:
84+
contents: read
85+
steps:
86+
- uses: actions/checkout@v6
87+
88+
- name: Install Rust toolchain
89+
uses: dtolnay/rust-toolchain@stable
90+
91+
- name: Cache cargo registry & target
92+
uses: actions/cache@v4
93+
with:
94+
path: |
95+
~/.cargo/registry
96+
~/.cargo/git
97+
target
98+
key: compile-${{ matrix.platform.arch }}-${{ hashFiles('Cargo.lock') }}
99+
restore-keys: |
100+
compile-${{ matrix.platform.arch }}-
101+
102+
- name: Build openab
103+
run: cargo build --release --features unified
104+
105+
- name: Build openab-agent
106+
run: cd openab-agent && printf '\n[workspace]\n' >> Cargo.toml && cargo build --release
107+
108+
- name: Build agy-acp
109+
run: cd agy-acp && printf '\n[workspace]\n' >> Cargo.toml && cargo build --release
110+
111+
- name: Collect binaries
112+
run: |
113+
mkdir -p bins
114+
cp target/release/openab bins/
115+
cp openab-agent/target/release/openab-agent bins/
116+
cp agy-acp/target/release/agy-acp bins/
117+
118+
- name: Upload binaries
119+
uses: actions/upload-artifact@v4
120+
with:
121+
name: openab-bins-${{ matrix.platform.arch }}
122+
path: bins/
123+
if-no-files-found: error
124+
retention-days: 1
125+
126+
# ---------------------------------------------------------------------------
127+
# Package: build lightweight Docker images (no Rust compilation).
128+
# Downloads pre-built binaries and uses Dockerfile.package.
129+
# ---------------------------------------------------------------------------
71130
build:
72-
needs: matrix
131+
needs: [matrix, compile]
73132
strategy:
74133
fail-fast: false
75134
matrix:
@@ -84,6 +143,15 @@ jobs:
84143
steps:
85144
- uses: actions/checkout@v6
86145

146+
- name: Download pre-built binaries
147+
uses: actions/download-artifact@v4
148+
with:
149+
name: openab-bins-${{ matrix.platform.arch }}
150+
path: bin
151+
152+
- name: Make binaries executable
153+
run: chmod +x bin/*
154+
87155
- uses: docker/setup-buildx-action@v3
88156

89157
- uses: docker/login-action@v4
@@ -97,13 +165,14 @@ jobs:
97165
uses: docker/build-push-action@v6
98166
with:
99167
context: .
100-
file: Dockerfile.unified
168+
file: Dockerfile.package
101169
target: ${{ matrix.agent }}
170+
build-contexts: bins=bin
102171
platforms: ${{ matrix.platform.os }}
103172
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
104173
cache-from: |
105-
type=gha,scope=pre-beta-${{ matrix.agent }}-${{ matrix.platform.arch }}
106-
cache-to: type=gha,scope=pre-beta-${{ matrix.agent }}-${{ matrix.platform.arch }},mode=max
174+
type=gha,scope=pre-beta-pkg-${{ matrix.agent }}-${{ matrix.platform.arch }}
175+
cache-to: type=gha,scope=pre-beta-pkg-${{ matrix.agent }}-${{ matrix.platform.arch }},mode=max
107176

108177
- name: Export digest
109178
run: |

0 commit comments

Comments
 (0)