- Config loader with env var expansion and validation - SQLite database with tasks and toolchain_versions tables - Gitea REST API client for repository and branch operations - K8s client for Job lifecycle management (with noop fallback for local dev) - REST API: tasks CRUD, retry, plugins, version management - Worker/scheduler with polling, concurrency control, and job tracking - Static frontend: generate, tasks, settings pages - Toolchain images: Go and Node.js Dockerfiles with entrypoint scripts - Helm chart with deployment, service, configmap, ingress, PVC - Multi-stage Dockerfile for service - Unit tests for config, database, gitclient, k8s, api, worker - E2E tests for idempotency, version switch, failure recovery
60 lines
1.8 KiB
Bash
60 lines
1.8 KiB
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
echo "=== Proto-Gen Node.js Toolchain ==="
|
|
echo "PROTO_REPO: ${PROTO_REPO}"
|
|
echo "PROTO_BRANCH: ${PROTO_BRANCH}"
|
|
echo "TARGET_REPO: ${TARGET_REPO}"
|
|
|
|
REPO_DIR=$(mktemp -d)
|
|
OUT_DIR=${OUT_DIR:-/out}
|
|
mkdir -p "${OUT_DIR}"
|
|
|
|
echo "--- Cloning proto repository ---"
|
|
git clone --branch "${PROTO_BRANCH}" --depth 1 \
|
|
"https://${GIT_TOKEN}@${GIT_BASE_URL}/${PROTO_REPO}.git" "${REPO_DIR}/proto"
|
|
|
|
PROTO_SHA=$(cd "${REPO_DIR}/proto" && git rev-parse HEAD)
|
|
echo "Proto commit: ${PROTO_SHA}"
|
|
|
|
echo "--- Running protoc ---"
|
|
PROTO_FILES=$(find "${REPO_DIR}/proto" -name "*.proto" -type f)
|
|
for proto_file in ${PROTO_FILES}; do
|
|
protoc \
|
|
--proto_path="${REPO_DIR}/proto" \
|
|
--ts_out="${OUT_DIR}" --ts_opt=long_type_string
|
|
"${proto_file#${REPO_DIR}/proto/}"
|
|
done
|
|
|
|
echo "--- Cloning target repository ---"
|
|
TARGET_DIR=$(mktemp -d)
|
|
if git clone "https://${GIT_TOKEN}@${GIT_BASE_URL}/${TARGET_REPO}.git" "${TARGET_DIR}/target" 2>/dev/null; then
|
|
echo "Target repo exists"
|
|
else
|
|
echo "Creating target repository..."
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${GIT_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"name\": \"${TARGET_REPO}\", \"auto_init\": false}" \
|
|
"${GIT_BASE_URL}/api/v1/user/repos"
|
|
git clone "https://${GIT_TOKEN}@${GIT_BASE_URL}/${TARGET_REPO}.git" "${TARGET_DIR}/target"
|
|
fi
|
|
|
|
echo "--- Checking for changes ---"
|
|
cd "${TARGET_DIR}/target"
|
|
cp -r "${OUT_DIR}"/* . 2>/dev/null || true
|
|
git add -A
|
|
|
|
if git diff --cached --quiet; then
|
|
echo "No changes detected, idempotent exit"
|
|
exit 0
|
|
fi
|
|
|
|
echo "--- Committing and pushing ---"
|
|
git config user.email "proto-gen@bot"
|
|
git config user.name "Proto-Gen Bot"
|
|
git commit -m "gen(nodejs): from ${PROTO_REPO}@${PROTO_SHA}"
|
|
git push origin "${PROTO_BRANCH}"
|
|
|
|
echo "=== Done ==="
|