From b2775b922805ea52912f69e3e314d73770f52eca Mon Sep 17 00:00:00 2001 From: Will Anderson Date: Tue, 5 May 2026 02:37:56 -0500 Subject: [PATCH] fix CI paths for monorepo lang/ layout; add pre-commit hook --- .gitea/workflows/ci-dev.yaml | 3 + .gitea/workflows/ci-stage.yaml | 3 + .gitea/workflows/sdk-release.yaml | 149 +++--------------------------- .githooks/pre-commit | 50 ++++++++++ 4 files changed, 70 insertions(+), 135 deletions(-) create mode 100755 .githooks/pre-commit diff --git a/.gitea/workflows/ci-dev.yaml b/.gitea/workflows/ci-dev.yaml index d415c5f..df404f6 100644 --- a/.gitea/workflows/ci-dev.yaml +++ b/.gitea/workflows/ci-dev.yaml @@ -11,6 +11,9 @@ on: jobs: build-and-test: runs-on: ubuntu-latest + defaults: + run: + working-directory: lang steps: - name: Checkout diff --git a/.gitea/workflows/ci-stage.yaml b/.gitea/workflows/ci-stage.yaml index 185c558..06f946d 100644 --- a/.gitea/workflows/ci-stage.yaml +++ b/.gitea/workflows/ci-stage.yaml @@ -11,6 +11,9 @@ on: jobs: build-and-test: runs-on: ubuntu-latest + defaults: + run: + working-directory: lang steps: - name: Checkout diff --git a/.gitea/workflows/sdk-release.yaml b/.gitea/workflows/sdk-release.yaml index 627aa85..9304e0d 100644 --- a/.gitea/workflows/sdk-release.yaml +++ b/.gitea/workflows/sdk-release.yaml @@ -8,6 +8,9 @@ on: jobs: build-and-release: runs-on: ubuntu-latest + defaults: + run: + working-directory: lang steps: - name: Checkout @@ -56,7 +59,6 @@ jobs: echo "gen3 (self-hosted) elc built" dist/platform/elc --version || true - # Run all four test suites with gen3 elc - name: Run tests — text run: | ELC="$(pwd)/dist/platform/elc" \ @@ -88,7 +90,6 @@ jobs: GITEA_API: https://git.neuralplatform.ai/api/v1 REPO: neuron-technologies/el run: | - # Delete existing `latest` release if it exists EXISTING_ID=$(curl -sf \ -H "Authorization: token ${GITEA_TOKEN}" \ "${GITEA_API}/repos/${REPO}/releases/tags/latest" \ @@ -101,12 +102,10 @@ jobs: "${GITEA_API}/repos/${REPO}/releases/${EXISTING_ID}" fi - # Delete and re-create the `latest` tag so it points at HEAD curl -sf -X DELETE \ -H "Authorization: token ${GITEA_TOKEN}" \ "${GITEA_API}/repos/${REPO}/tags/latest" || true - # Create the release RELEASE_ID=$(curl -sf -X POST \ -H "Authorization: token ${GITEA_TOKEN}" \ -H "Content-Type: application/json" \ @@ -121,7 +120,6 @@ jobs: echo "Created release id=${RELEASE_ID}" - # Upload assets upload_asset() { local filepath="$1" local name="$2" @@ -138,7 +136,6 @@ jobs: echo "Release published successfully" - # Publish artifacts to GCP Artifact Registry (prod) - name: Publish El SDK to Artifact Registry (prod) env: GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} @@ -180,136 +177,18 @@ jobs: echo "Published El SDK version=${VERSION} to foundation-prod" rm -f /tmp/gcp-key.json - # Dispatch el-sdk-updated event to downstream repos - # Publish artifact to GCP Artifact Registry (prod) - - name: Publish elc to Artifact Registry (prod) - env: - GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} - run: | - echo "${GCP_SA_KEY}" > /tmp/gcp-key.json - apt-get install -y -qq apt-transport-https ca-certificates gnupg curl - curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg - echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] 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 - gcloud auth activate-service-account --key-file=/tmp/gcp-key.json - gcloud config set project neuron-785695 - - VERSION="${GITEA_SHA:0:8}" - gcloud artifacts generic upload \ - --repository=foundation-prod \ - --location=us-central1 \ - --project=neuron-785695 \ - --package=el/elc \ - --version="${VERSION}" \ - --source=dist/platform/elc - - echo "Published elc version=${VERSION} to foundation-prod/el/elc" - rm -f /tmp/gcp-key.json - - - name: Dispatch to foundation/engram + - name: Dispatch el-sdk-updated to downstream repos env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_API: https://git.neuralplatform.ai/api/v1 run: | - curl -sf -X POST \ - -H "Authorization: token ${GITEA_TOKEN}" \ - -H "Content-Type: application/json" \ - "${GITEA_API}/repos/neuron-technologies/engram/dispatches" \ - -d "{ - \"type\": \"el-sdk-updated\", - \"inputs\": { - \"el_version\": \"latest\", - \"commit\": \"${GITHUB_SHA}\" - } - }" - echo "Dispatched el-sdk-updated to foundation/engram" - - - name: Dispatch to neuron-technologies/forge - env: - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - GITEA_API: https://git.neuralplatform.ai/api/v1 - run: | - curl -sf -X POST \ - -H "Authorization: token ${GITEA_TOKEN}" \ - -H "Content-Type: application/json" \ - "${GITEA_API}/repos/neuron-technologies/forge/dispatches" \ - -d "{ - \"type\": \"el-sdk-updated\", - \"inputs\": { - \"el_version\": \"latest\", - \"commit\": \"${GITHUB_SHA}\" - } - }" - echo "Dispatched el-sdk-updated to neuron-technologies/forge" - - - name: Dispatch to neuron-technologies/el-ui - env: - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - GITEA_API: https://git.neuralplatform.ai/api/v1 - run: | - curl -sf -X POST \ - -H "Authorization: token ${GITEA_TOKEN}" \ - -H "Content-Type: application/json" \ - "${GITEA_API}/repos/neuron-technologies/el-ui/dispatches" \ - -d "{ - \"type\": \"el-sdk-updated\", - \"inputs\": { - \"el_version\": \"latest\", - \"commit\": \"${GITHUB_SHA}\" - } - }" - echo "Dispatched el-sdk-updated to neuron-technologies/el-ui" - - - name: Dispatch to neuron-technologies/elp - env: - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - GITEA_API: https://git.neuralplatform.ai/api/v1 - run: | - curl -sf -X POST \ - -H "Authorization: token ${GITEA_TOKEN}" \ - -H "Content-Type: application/json" \ - "${GITEA_API}/repos/neuron-technologies/elp/dispatches" \ - -d "{ - \"type\": \"el-sdk-updated\", - \"inputs\": { - \"el_version\": \"latest\", - \"commit\": \"${GITHUB_SHA}\" - } - }" - echo "Dispatched el-sdk-updated to neuron-technologies/elp" - - - name: Dispatch to neuron-technologies/elql - env: - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - GITEA_API: https://git.neuralplatform.ai/api/v1 - run: | - curl -sf -X POST \ - -H "Authorization: token ${GITEA_TOKEN}" \ - -H "Content-Type: application/json" \ - "${GITEA_API}/repos/neuron-technologies/elql/dispatches" \ - -d "{ - \"type\": \"el-sdk-updated\", - \"inputs\": { - \"el_version\": \"latest\", - \"commit\": \"${GITHUB_SHA}\" - } - }" - echo "Dispatched el-sdk-updated to neuron-technologies/elql" - - - name: Dispatch to neuron-technologies/el-ide - env: - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - GITEA_API: https://git.neuralplatform.ai/api/v1 - run: | - curl -sf -X POST \ - -H "Authorization: token ${GITEA_TOKEN}" \ - -H "Content-Type: application/json" \ - "${GITEA_API}/repos/neuron-technologies/el-ide/dispatches" \ - -d "{ - \"type\": \"el-sdk-updated\", - \"inputs\": { - \"el_version\": \"latest\", - \"commit\": \"${GITHUB_SHA}\" - } - }" - echo "Dispatched el-sdk-updated to neuron-technologies/el-ide" + for repo in neuron-technologies/forge; do + curl -sf -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + "${GITEA_API}/repos/${repo}/dispatches" \ + -d "{ + \"type\": \"el-sdk-updated\", + \"inputs\": {\"el_version\": \"latest\", \"commit\": \"${GITHUB_SHA}\"} + }" && echo "Dispatched to ${repo}" || echo "Warning: dispatch to ${repo} failed" + done diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..bbea4e6 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# El pre-commit hook: compile and run native tests before commit. +# Install once per clone: git config core.hooksPath .githooks + +set -euo pipefail + +ROOT="$(git rev-parse --show-toplevel)" +LANG_DIR="$ROOT/lang" +RUNTIME="$LANG_DIR/el-compiler/runtime" +ELC="$LANG_DIR/dist/platform/elc" + +# If elc isn't built yet, skip with a warning rather than blocking +if [ ! -x "$ELC" ]; then + echo "⚠ elc not found at lang/dist/platform/elc — skipping pre-commit tests" + echo " Build it first: cd lang && gcc -O2 -I el-compiler/runtime dist/elc-bootstrap.c el-compiler/runtime/el_runtime.c -lcurl -lpthread -o dist/elc-gen2 && ./dist/elc-gen2 el-compiler/src/compiler.el > /tmp/elc.c && gcc -O2 -I el-compiler/runtime /tmp/elc.c el-compiler/runtime/el_runtime.c -lcurl -lpthread -o dist/platform/elc" + exit 0 +fi + +echo "→ Running El native tests..." +PASS=0 +FAIL=0 +FAILED_TESTS="" + +for test_file in "$LANG_DIR"/tests/native/test_*.el; do + name=$(basename "$test_file" .el) + tmp_c="/tmp/el_hook_${name}.c" + tmp_bin="/tmp/el_hook_${name}" + + if "$ELC" --test "$test_file" > "$tmp_c" 2>/dev/null \ + && gcc -O2 -I "$RUNTIME" "$tmp_c" "$RUNTIME/el_runtime.c" \ + -lcurl -lpthread -lm -o "$tmp_bin" 2>/dev/null \ + && "$tmp_bin" 2>/dev/null; then + PASS=$((PASS + 1)) + else + echo " ✗ $name" + FAIL=$((FAIL + 1)) + FAILED_TESTS="$FAILED_TESTS $name" + fi +done + +echo " $PASS passed, $FAIL failed" + +if [ "$FAIL" -gt 0 ]; then + echo "" + echo "✗ Pre-commit failed. Fix these tests before committing:$FAILED_TESTS" + exit 1 +fi + +echo "✓ All tests passed" +exit 0