131 lines
4.6 KiB
YAML
131 lines
4.6 KiB
YAML
name: Neuron Soul CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
# Same group as deploy-gke so builds and deploys queue behind each other.
|
|
# Prevents concurrent Docker daemon exhaustion on the single GCE runner.
|
|
concurrency:
|
|
group: neuron-runner
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Free disk space
|
|
run: |
|
|
df -h /
|
|
docker system prune -af --volumes 2>/dev/null || true
|
|
df -h /
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install build dependencies
|
|
run: |
|
|
apt-get update -qq
|
|
apt-get install -y gcc libcurl4-openssl-dev apt-transport-https ca-certificates
|
|
echo "deb [trusted=yes] https://packages.cloud.google.com/apt cloud-sdk main" \
|
|
> /etc/apt/sources.list.d/google-cloud-sdk.list
|
|
apt-get update -qq && apt-get install -y google-cloud-cli
|
|
|
|
- name: Download El runtime from Artifact Registry
|
|
env:
|
|
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
|
|
run: |
|
|
echo "${GCP_SA_KEY}" > /tmp/gcp-key.json
|
|
gcloud auth activate-service-account --key-file=/tmp/gcp-key.json
|
|
gcloud config set project neuron-785695
|
|
|
|
rm -rf /opt/el/runtime
|
|
mkdir -p /opt/el/runtime
|
|
|
|
# Get latest version of each runtime package (elc/elb not needed — we compile
|
|
# dist/soul.c directly; running elb on Linux OOM-kills the runner, and we
|
|
# always use the repo's pre-built soul.c anyway).
|
|
get_latest() {
|
|
gcloud artifacts versions list \
|
|
--repository=foundation-prod \
|
|
--location=us-central1 \
|
|
--project=neuron-785695 \
|
|
--package="$1" \
|
|
--sort-by="~createTime" \
|
|
--limit=1 \
|
|
--format="value(name)" 2>/dev/null | awk -F/ '{print $NF}'
|
|
}
|
|
|
|
RC_VER=$(get_latest el-runtime-c)
|
|
RH_VER=$(get_latest el-runtime-h)
|
|
|
|
echo "Downloading runtime@${RC_VER}"
|
|
|
|
gcloud artifacts generic download \
|
|
--repository=foundation-prod --location=us-central1 --project=neuron-785695 \
|
|
--package=el-runtime-c --version="${RC_VER}" \
|
|
--destination=/opt/el/runtime/
|
|
|
|
gcloud artifacts generic download \
|
|
--repository=foundation-prod --location=us-central1 --project=neuron-785695 \
|
|
--package=el-runtime-h --version="${RH_VER}" \
|
|
--destination=/opt/el/runtime/
|
|
|
|
mv /opt/el/runtime/el_runtime.c* /opt/el/runtime/el_runtime.c 2>/dev/null || true
|
|
mv /opt/el/runtime/el_runtime.h* /opt/el/runtime/el_runtime.h 2>/dev/null || true
|
|
echo "El runtime ready: $(ls /opt/el/runtime/)"
|
|
|
|
- name: Build neuron soul binary
|
|
run: |
|
|
RUNTIME=/opt/el/runtime
|
|
|
|
# Compile the self-contained translation unit directly from dist/soul.c.
|
|
# dist/soul.c is the authoritative combined unit maintained in the repo —
|
|
# regenerated on macOS by running elb (which succeeds on arm64/macOS ld but
|
|
# fails on Linux due to duplicate strong symbols). We skip the elb step here
|
|
# entirely: elb on Linux would OOM the runner (elc uses 24GB+ virtual memory
|
|
# on a 16GB host) and we always restore from the repo's soul.c anyway.
|
|
mkdir -p dist
|
|
cc -O2 -DHAVE_CURL \
|
|
-I$RUNTIME \
|
|
dist/soul.c \
|
|
$RUNTIME/el_runtime.c \
|
|
-lssl -lcrypto -lcurl -lpthread -lm \
|
|
-o dist/neuron
|
|
|
|
# Strip debug symbols and non-essential symbol table entries.
|
|
# -s removes the symbol table + relocation info (max size reduction).
|
|
# Keeps the binary functional; debuggability is preserved via source + CI logs.
|
|
strip -s dist/neuron
|
|
ls -lh dist/neuron
|
|
|
|
- name: Smoke test
|
|
run: |
|
|
file dist/neuron
|
|
timeout 3 dist/neuron --help 2>&1 || true
|
|
echo "smoke test complete"
|
|
|
|
- name: Publish neuron binary
|
|
if: github.event_name == 'push'
|
|
env:
|
|
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
|
|
run: |
|
|
VERSION="${GITHUB_SHA:0:8}"
|
|
|
|
gcloud artifacts generic upload \
|
|
--repository=foundation-prod \
|
|
--location=us-central1 \
|
|
--project=neuron-785695 \
|
|
--package=neuron-soul \
|
|
--version="${VERSION}" \
|
|
--source=dist/neuron
|
|
|
|
echo "Published neuron-soul@${VERSION}"
|
|
rm -f /tmp/gcp-key.json
|