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] branches: [main]
env: env:
CARGO_TERM_COLOR: always BUN_INSTALL: "${{ github.workspace }}/.bun"
jobs: jobs:
check: check:
@@ -16,16 +16,20 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Rust toolchain - name: Setup Bun
uses: actions-rust-lang/setup-rust-toolchain@v1 uses: oven-sh/setup-bun@v2
with:
components: clippy
- name: Format check - name: Install dependencies
run: cargo fmt --all -- --check run: bun install --frozen-lockfile
- name: Clippy workspace - name: Type-check
run: cargo clippy --workspace --all-targets -- -D warnings run: bun run check
- name: Test workspace - name: Test
run: cargo test --workspace 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: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Rust toolchain - name: Setup Bun
uses: actions-rust-lang/setup-rust-toolchain@v1 uses: oven-sh/setup-bun@v2
- name: Build - name: Install
run: cargo build --release --workspace run: bun install --frozen-lockfile
- name: Type-check
run: bun run check
- name: Test - name: Test
run: cargo test --workspace run: bun test
release: release:
name: Semantic Release name: Semantic Release
@@ -34,13 +37,8 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Rust toolchain - name: Setup Bun
uses: actions-rust-lang/setup-rust-toolchain@v1 uses: oven-sh/setup-bun@v2
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Install semantic-release - name: Install semantic-release
run: | run: |
+1 -1
View File
@@ -5,7 +5,7 @@
"@semantic-release/release-notes-generator", "@semantic-release/release-notes-generator",
"@semantic-release/changelog", "@semantic-release/changelog",
["@semantic-release/exec", { ["@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", { ["@semantic-release/git", {
"assets": ["Cargo.toml", "CHANGELOG.md"], "assets": ["Cargo.toml", "CHANGELOG.md"],
+13 -14
View File
@@ -1,30 +1,29 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
# Zesdex — Multi-stage Docker build # Zesdex — Multi-stage Docker build (Bun)
# =================================== # ========================================
# Stage 1: Build with Rust toolchain # Stage 1: Build with Bun → compile single self-contained CLI binary
FROM rust:1.85-slim-bookworm AS builder FROM oven/bun:1.2 AS builder
RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config libsqlite3-dev && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app 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 bun install --frozen-lockfile
RUN cargo build --release -p zesdex-gateway --bin zesdex
# 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 # Stage 2: Minimal runtime image
FROM debian:bookworm-slim FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates libsqlite3-0 && \ ca-certificates && \
rm -rf /var/lib/apt/lists/* 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 ENV ZESDEX_DATA_DIR=/data
VOLUME ["/data"] VOLUME ["/data"]
ENTRYPOINT ["/usr/local/bin/zesdex"] ENTRYPOINT ["/usr/local/bin/zesdex"]
+24 -14
View File
@@ -3,29 +3,39 @@ set -euo pipefail
BIN_NAME="zesdex" BIN_NAME="zesdex"
REPO_DIR="$(cd "$(dirname "$0")" && pwd)" REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
TARGET_DIR="$REPO_DIR/target/release" TMP_BIN="/tmp/$BIN_NAME"
BIN_PATH="$TARGET_DIR/$BIN_NAME"
echo "==> Building $BIN_NAME (release)..." # Need Bun to compile the CLI.
cargo build --release --manifest-path "$REPO_DIR/Cargo.toml" if ! command -v bun >/dev/null 2>&1; then
echo "ERROR: 'bun' is required to build $BIN_NAME." >&2
if [ ! -f "$BIN_PATH" ]; then echo "Install it from https://bun.sh (curl -fsSL https://bun.sh/install | bash)" >&2
echo "ERROR: build succeeded but binary not found at $BIN_PATH" >&2
exit 1 exit 1
fi 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}" INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
mkdir -p "$INSTALL_DIR" mkdir -p "$INSTALL_DIR"
SYMLINK_PATH="$INSTALL_DIR/$BIN_NAME" BIN_PATH="$INSTALL_DIR/$BIN_NAME"
if [ -L "$SYMLINK_PATH" ] || [ -f "$SYMLINK_PATH" ]; then if [ -L "$BIN_PATH" ] || [ -f "$BIN_PATH" ]; then
echo "==> Removing existing symlink or file at $SYMLINK_PATH" echo "==> Removing existing symlink or file at $BIN_PATH"
rm -f "$SYMLINK_PATH" rm -f "$BIN_PATH"
fi fi
ln -s "$BIN_PATH" "$SYMLINK_PATH" mv "$TMP_BIN" "$BIN_PATH"
echo "==> Symlinked: $SYMLINK_PATH -> $BIN_PATH" echo "==> Installed: $BIN_PATH"
echo "" echo ""
echo "Done. Make sure $INSTALL_DIR is in your PATH." echo "Done. Make sure $INSTALL_DIR is in your PATH."