ci: migrasi CI/Dockerfile/install.sh ke Bun — setup-bun + bun install/check/test + --compile single binary; release gate ke bun run check

This commit is contained in:
asepharyana
2026-09-02 22:50:38 +07:00
parent 5d65c78fb4
commit 170b1d3d19
5 changed files with 63 additions and 52 deletions
+15 -11
View File
@@ -7,7 +7,7 @@ on:
branches: [main]
env:
CARGO_TERM_COLOR: always
BUN_INSTALL: "${{ github.workspace }}/.bun"
jobs:
check:
@@ -16,16 +16,20 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Format check
run: cargo fmt --all -- --check
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Clippy workspace
run: cargo clippy --workspace --all-targets -- -D warnings
- name: Type-check
run: bun run check
- name: Test workspace
run: cargo test --workspace
- name: Test
run: bun test
- name: Build CLI bundle
run: bun build apps/interfaces/cli/src/index.ts --target=bun --outdir=/tmp/zesdex-build
- name: Smoke — CLI help
run: bun /tmp/zesdex-build/index.js --help
+10 -12
View File
@@ -16,14 +16,17 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Build
run: cargo build --release --workspace
- name: Install
run: bun install --frozen-lockfile
- name: Type-check
run: bun run check
- name: Test
run: cargo test --workspace
run: bun test
release:
name: Semantic Release
@@ -34,13 +37,8 @@ jobs:
with:
fetch-depth: 0
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install semantic-release
run: |
+1 -1
View File
@@ -5,7 +5,7 @@
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
["@semantic-release/exec", {
"prepareCmd": "sed -i 's/^version = \"[^\"]*\"/version = \"${nextRelease.version}\"/' Cargo.toml && cargo check"
"prepareCmd": "sed -i 's/^version = \\\"[^\\\"]*\\\"/version = \\\"${nextRelease.version}\\\"/' Cargo.toml && bun run check"
}],
["@semantic-release/git", {
"assets": ["Cargo.toml", "CHANGELOG.md"],
+13 -14
View File
@@ -1,30 +1,29 @@
# syntax=docker/dockerfile:1
# Zesdex — Multi-stage Docker build
# ===================================
# Stage 1: Build with Rust toolchain
FROM rust:1.85-slim-bookworm AS builder
RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config libsqlite3-dev && \
rm -rf /var/lib/apt/lists/*
# Zesdex — Multi-stage Docker build (Bun)
# ========================================
# Stage 1: Build with Bun → compile single self-contained CLI binary
FROM oven/bun:1.2 AS builder
WORKDIR /app
COPY . .
COPY bun.lockb bun.lock ./
COPY package.json tsconfig.json ./
COPY apps ./apps
# Build with release profile (treats warnings as errors via lints)
RUN cargo build --release -p zesdex-gateway --bin zesdex
RUN bun install --frozen-lockfile
# Compile a standalone self-contained executable (bundles JS + native addons).
RUN bun build apps/interfaces/cli/src/index.ts --compile --outfile=/app/zesdex
# Stage 2: Minimal runtime image
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates libsqlite3-0 && \
ca-certificates && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/zesdex /usr/local/bin/zesdex
COPY --from=builder /app/zesdex /usr/local/bin/zesdex
ENV ZESDEX_DATA_DIR=/data
VOLUME ["/data"]
ENTRYPOINT ["/usr/local/bin/zesdex"]
+24 -14
View File
@@ -3,29 +3,39 @@ set -euo pipefail
BIN_NAME="zesdex"
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
TARGET_DIR="$REPO_DIR/target/release"
BIN_PATH="$TARGET_DIR/$BIN_NAME"
TMP_BIN="/tmp/$BIN_NAME"
echo "==> Building $BIN_NAME (release)..."
cargo build --release --manifest-path "$REPO_DIR/Cargo.toml"
if [ ! -f "$BIN_PATH" ]; then
echo "ERROR: build succeeded but binary not found at $BIN_PATH" >&2
# Need Bun to compile the CLI.
if ! command -v bun >/dev/null 2>&1; then
echo "ERROR: 'bun' is required to build $BIN_NAME." >&2
echo "Install it from https://bun.sh (curl -fsSL https://bun.sh/install | bash)" >&2
exit 1
fi
echo "==> Binary built: $BIN_PATH"
echo "==> Installing dependencies..."
bun install --cwd "$REPO_DIR" --frozen-lockfile
echo "==> Compiling $BIN_NAME (self-contained executable)..."
bun build "$REPO_DIR/apps/interfaces/cli/src/index.ts" --compile --outfile "$TMP_BIN"
if [ ! -f "$TMP_BIN" ]; then
echo "ERROR: build succeeded but binary not found at $TMP_BIN" >&2
exit 1
fi
chmod +x "$TMP_BIN"
echo "==> Binary built: $TMP_BIN"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
mkdir -p "$INSTALL_DIR"
SYMLINK_PATH="$INSTALL_DIR/$BIN_NAME"
BIN_PATH="$INSTALL_DIR/$BIN_NAME"
if [ -L "$SYMLINK_PATH" ] || [ -f "$SYMLINK_PATH" ]; then
echo "==> Removing existing symlink or file at $SYMLINK_PATH"
rm -f "$SYMLINK_PATH"
if [ -L "$BIN_PATH" ] || [ -f "$BIN_PATH" ]; then
echo "==> Removing existing symlink or file at $BIN_PATH"
rm -f "$BIN_PATH"
fi
ln -s "$BIN_PATH" "$SYMLINK_PATH"
echo "==> Symlinked: $SYMLINK_PATH -> $BIN_PATH"
mv "$TMP_BIN" "$BIN_PATH"
echo "==> Installed: $BIN_PATH"
echo ""
echo "Done. Make sure $INSTALL_DIR is in your PATH."