ci: add neuron soul build pipeline
Downloads El SDK from Artifact Registry, generates ELP declarations header, builds the neuron soul binary with elb, smoke-tests it, and publishes to foundation-dev on push to main.
This commit is contained in:
@@ -0,0 +1,140 @@
|
|||||||
|
name: Neuron Soul CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- 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 python3
|
||||||
|
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 SDK 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
|
||||||
|
|
||||||
|
mkdir -p /opt/el/dist/platform /opt/el/dist/bin /opt/el/runtime
|
||||||
|
|
||||||
|
# Get latest version of each package
|
||||||
|
get_latest() {
|
||||||
|
gcloud artifacts versions list \
|
||||||
|
--repository=foundation-dev \
|
||||||
|
--location=us-central1 \
|
||||||
|
--project=neuron-785695 \
|
||||||
|
--package="$1" \
|
||||||
|
--sort-by="~createTime" \
|
||||||
|
--limit=1 \
|
||||||
|
--format="value(name)" 2>/dev/null | awk -F/ '{print $NF}'
|
||||||
|
}
|
||||||
|
|
||||||
|
ELC_VER=$(get_latest el-elc)
|
||||||
|
ELB_VER=$(get_latest el-elb)
|
||||||
|
RC_VER=$(get_latest el-runtime-c)
|
||||||
|
RH_VER=$(get_latest el-runtime-h)
|
||||||
|
|
||||||
|
echo "Downloading elc@${ELC_VER} elb@${ELB_VER} runtime@${RC_VER}"
|
||||||
|
|
||||||
|
gcloud artifacts generic download \
|
||||||
|
--repository=foundation-dev --location=us-central1 --project=neuron-785695 \
|
||||||
|
--package=el-elc --version="${ELC_VER}" \
|
||||||
|
--destination=/opt/el/dist/platform/
|
||||||
|
|
||||||
|
gcloud artifacts generic download \
|
||||||
|
--repository=foundation-dev --location=us-central1 --project=neuron-785695 \
|
||||||
|
--package=el-elb --version="${ELB_VER}" \
|
||||||
|
--destination=/opt/el/dist/bin/
|
||||||
|
|
||||||
|
gcloud artifacts generic download \
|
||||||
|
--repository=foundation-dev --location=us-central1 --project=neuron-785695 \
|
||||||
|
--package=el-runtime-c --version="${RC_VER}" \
|
||||||
|
--destination=/opt/el/runtime/
|
||||||
|
|
||||||
|
gcloud artifacts generic download \
|
||||||
|
--repository=foundation-dev --location=us-central1 --project=neuron-785695 \
|
||||||
|
--package=el-runtime-h --version="${RH_VER}" \
|
||||||
|
--destination=/opt/el/runtime/
|
||||||
|
|
||||||
|
# Downloaded files keep original names; rename to canonical paths
|
||||||
|
mv /opt/el/dist/platform/elc* /opt/el/dist/platform/elc 2>/dev/null || true
|
||||||
|
mv /opt/el/dist/bin/elb* /opt/el/dist/bin/elb 2>/dev/null || true
|
||||||
|
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
|
||||||
|
|
||||||
|
chmod +x /opt/el/dist/platform/elc /opt/el/dist/bin/elb
|
||||||
|
echo "El SDK ready"
|
||||||
|
/opt/el/dist/platform/elc --version || true
|
||||||
|
|
||||||
|
- name: Generate ELP master declarations header
|
||||||
|
run: |
|
||||||
|
python3 - <<'PYEOF'
|
||||||
|
import os, re
|
||||||
|
dist = 'dist'
|
||||||
|
decls = set()
|
||||||
|
guard_pat = re.compile(r'^(el_val_t|void|int|char\*|const char\*)\s+\w+\s*\(')
|
||||||
|
for fn in sorted(os.listdir(dist)):
|
||||||
|
if not fn.endswith('.c'):
|
||||||
|
continue
|
||||||
|
with open(os.path.join(dist, fn)) as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.rstrip()
|
||||||
|
if guard_pat.match(line) and line.endswith(';'):
|
||||||
|
decls.add(line)
|
||||||
|
header = ['/* Auto-generated C forward declarations for ELP cross-module calls */',
|
||||||
|
'#pragma once', '#include "el_runtime.h"', '']
|
||||||
|
header += sorted(decls)
|
||||||
|
with open(os.path.join(dist, 'elp-c-decls.h'), 'w') as f:
|
||||||
|
f.write('\n'.join(header) + '\n')
|
||||||
|
print(f"Generated elp-c-decls.h with {len(decls)} declarations")
|
||||||
|
PYEOF
|
||||||
|
|
||||||
|
- name: Build neuron soul binary
|
||||||
|
run: |
|
||||||
|
ELB=/opt/el/dist/bin/elb
|
||||||
|
ELC=/opt/el/dist/platform/elc
|
||||||
|
RUNTIME=/opt/el/runtime
|
||||||
|
|
||||||
|
$ELB --elc=$ELC --runtime=$RUNTIME
|
||||||
|
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="${GITEA_SHA:0:8}"
|
||||||
|
|
||||||
|
gcloud artifacts generic upload \
|
||||||
|
--repository=foundation-dev \
|
||||||
|
--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
|
||||||
Reference in New Issue
Block a user