-
Notifications
You must be signed in to change notification settings - Fork 321
feat: add runner verify script for app image build #4895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
0vertake
wants to merge
5
commits into
superplanehq:main
Choose a base branch
from
0vertake:feat/runner-docker-image-build
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f05385a
feat: add runner verify script for app image build
0vertake a64cb25
fix: generate OpenAPI clients in runner image verify script
0vertake 87b1928
fix: resolve bugbot comments
0vertake c3ce3fd
Merge branch 'main' into feat/runner-docker-image-build
0vertake 85cf15f
fix: resolve bugbot comments
0vertake File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| #!/usr/bin/env bash | ||
| # Verify SuperPlane app image builds on a runner host (EC2) or locally. | ||
| # Full docker buildx (linux/amd64), no registry push — for #4693 / future daily builds. | ||
| # | ||
| # Env: | ||
| # REPO_URL default https://github.com/superplanehq/superplane.git | ||
| # GIT_REF branch or SHA to build (default: current HEAD when in-repo) | ||
| # ARCH default amd64 | ||
| # DEV_BASE_IMAGE default ghcr.io/superplanehq/superplane-dev-base:app-latest | ||
| # VERIFY_WORK_DIR use this checkout instead of cloning (local dev) | ||
| # SKIP_PROTO_GEN set to 1 to skip (not recommended; generated protos are not in git) | ||
| set -euo pipefail | ||
| IFS=$'\n\t' | ||
|
|
||
| ARCH="${ARCH:-amd64}" | ||
| REPO_URL="${REPO_URL:-https://github.com/superplanehq/superplane.git}" | ||
| DEV_BASE_IMAGE="${DEV_BASE_IMAGE:-ghcr.io/superplanehq/superplane-dev-base:app-latest}" | ||
| LOCAL_TAG="${LOCAL_TAG:-superplane:runner-verify}" | ||
|
|
||
| cleanup() { | ||
| if [[ -n "${TMP_WORK:-}" && -d "$TMP_WORK" ]]; then | ||
| rm -rf "$TMP_WORK" | ||
| fi | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| need_codegen() { | ||
| [[ "${SKIP_PROTO_GEN:-0}" == "1" ]] && return 1 | ||
| return 0 | ||
| } | ||
|
|
||
| make_var() { | ||
| local name="$1" | ||
| awk -v name="$name" ' | ||
| $1 == name && $2 == ":=" { | ||
| sub("^[^:]+:= ?", "") | ||
| exit | ||
| } | ||
| ' Makefile | ||
| } | ||
|
|
||
| load_codegen_modules() { | ||
| MODULES="$(make_var MODULES)" | ||
| REST_API_MODULES="$(make_var REST_API_MODULES)" | ||
| if [[ -z "$MODULES" || -z "$REST_API_MODULES" ]]; then | ||
| echo "Could not read MODULES and REST_API_MODULES from Makefile" >&2 | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| run_proto_gen() { | ||
| echo "==> Generating protobuf (dev-base container, no dev.up)" | ||
| docker pull "$DEV_BASE_IMAGE" | ||
| docker run --rm \ | ||
| -v "$(pwd):/app" \ | ||
| -w /app \ | ||
| -u "$(id -u):$(id -g)" \ | ||
| "$DEV_BASE_IMAGE" \ | ||
| bash -lc "/app/scripts/protoc.sh ${MODULES} && /app/scripts/protoc_gateway.sh ${REST_API_MODULES}" | ||
| } | ||
|
|
||
| OPENAPI_GENERATOR_IMAGE="openapitools/openapi-generator-cli:v7.13.0" | ||
|
|
||
| run_openapi_spec_gen() { | ||
| echo "==> Generating OpenAPI spec (dev-base container)" | ||
| docker run --rm \ | ||
| -v "$(pwd):/app" \ | ||
| -w /app \ | ||
| -u "$(id -u):$(id -g)" \ | ||
| "$DEV_BASE_IMAGE" \ | ||
| bash -lc "/app/scripts/protoc_openapi_spec.sh ${REST_API_MODULES}" | ||
| } | ||
|
|
||
| run_openapi_go_client_gen() { | ||
| echo "==> Generating OpenAPI Go client (openapi-generator-cli)" | ||
| rm -rf pkg/openapi_client | ||
| docker run --rm \ | ||
| -v "$(pwd):/local" \ | ||
| -u "$(id -u):$(id -g)" \ | ||
| "$OPENAPI_GENERATOR_IMAGE" generate \ | ||
| -i /local/api/swagger/superplane.swagger.json \ | ||
| -g go \ | ||
| -o /local/pkg/openapi_client \ | ||
| --additional-properties=packageName=openapi_client,enumClassPrefix=true,isGoSubmodule=true,withGoMod=false | ||
| rm -rf pkg/openapi_client/test pkg/openapi_client/docs pkg/openapi_client/api \ | ||
| pkg/openapi_client/.travis.yml pkg/openapi_client/README.md pkg/openapi_client/git_push.sh | ||
| docker run --rm \ | ||
| -v "$(pwd):/app" \ | ||
| -w /app \ | ||
| -u "$(id -u):$(id -g)" \ | ||
| "$DEV_BASE_IMAGE" \ | ||
| bash -lc "find pkg/openapi_client -name '*.go' -print0 | xargs -0 gofmt -s -w" | ||
| } | ||
|
|
||
| run_openapi_web_client_gen() { | ||
| echo "==> Generating OpenAPI web (TypeScript) client (dev-base container)" | ||
| rm -rf web_src/src/api-client | ||
| docker run --rm \ | ||
| -v "$(pwd):/app" \ | ||
| -w /app/web_src \ | ||
| -u "$(id -u):$(id -g)" \ | ||
| -e HOME=/tmp \ | ||
| -e NPM_CONFIG_CACHE=/tmp/.npm \ | ||
| "$DEV_BASE_IMAGE" \ | ||
| bash -lc "npm install --prefer-offline && npm run generate:api && npx prettier --log-level silent --write 'src/api-client/**/*.{ts,tsx}'" | ||
| } | ||
|
|
||
| run_image_build() { | ||
| echo "==> docker buildx build (linux/${ARCH}, no push)" | ||
| docker buildx build \ | ||
| --platform "linux/${ARCH}" \ | ||
| --progress=plain \ | ||
| --provenance=false \ | ||
| --target runner \ | ||
| --cache-from "$DEV_BASE_IMAGE" \ | ||
| -t "$LOCAL_TAG" \ | ||
| --load \ | ||
| -f Dockerfile \ | ||
| . | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| echo "==> OK: image loaded locally as ${LOCAL_TAG} (not pushed)" | ||
| } | ||
|
|
||
| checkout_ref() { | ||
| if [[ -z "${GIT_REF:-}" ]]; then | ||
| return | ||
| fi | ||
| git fetch origin --depth 1 "${GIT_REF}" 2>/dev/null || git fetch origin "${GIT_REF}" | ||
| git checkout "${GIT_REF}" | ||
| } | ||
|
|
||
| prepare_workdir() { | ||
| if [[ -n "${VERIFY_WORK_DIR:-}" ]]; then | ||
| cd "$VERIFY_WORK_DIR" | ||
| return | ||
| fi | ||
| if [[ -f Dockerfile && -f go.mod ]]; then | ||
| echo "==> Using current directory as repo root" | ||
| checkout_ref | ||
| return | ||
| fi | ||
| TMP_WORK="$(mktemp -d)" | ||
| echo "==> Cloning ${REPO_URL} (ref: ${GIT_REF:-default}) into ${TMP_WORK}" | ||
| git clone --depth 1 "$REPO_URL" "$TMP_WORK/repo" | ||
| cd "$TMP_WORK/repo" | ||
| checkout_ref | ||
| } | ||
|
|
||
| main() { | ||
| prepare_workdir | ||
| load_codegen_modules | ||
| if need_codegen; then | ||
| run_proto_gen | ||
| run_openapi_spec_gen | ||
| run_openapi_go_client_gen | ||
| run_openapi_web_client_gen | ||
| else | ||
| echo "==> Skipping codegen (SKIP_PROTO_GEN=1)" | ||
| fi | ||
| run_image_build | ||
| } | ||
|
|
||
| main "$@" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.