123 lines
4.1 KiB
YAML
123 lines
4.1 KiB
YAML
name: Build and Publish Patched OpenClaw
|
|
|
|
# This repo stores ONLY the patched files on top of upstream openclaw.
|
|
# CI clones upstream, overlays our patches, then tests/builds/publishes.
|
|
|
|
on:
|
|
push:
|
|
branches: [main, feature/*]
|
|
pull_request:
|
|
branches: [main]
|
|
schedule:
|
|
- cron: '0 9 * * *'
|
|
|
|
env:
|
|
NODE_VERSION: '22'
|
|
UPSTREAM_REPO: https://github.com/openclaw/openclaw.git
|
|
REGISTRY: git.moleculesai.app
|
|
IMAGE_NAME: molecule-ai/openclaw
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
path: patches
|
|
|
|
- name: Clone upstream openclaw
|
|
run: |
|
|
UPSTREAM_REF=$(awk '/^Upstream:/ {print $2; exit}' patches/PATCHED_VERSION.md)
|
|
test -n "$UPSTREAM_REF"
|
|
git init upstream
|
|
git -C upstream remote add origin ${{ env.UPSTREAM_REPO }}
|
|
git -C upstream fetch --depth 1 origin "$UPSTREAM_REF"
|
|
git -C upstream checkout --detach FETCH_HEAD
|
|
|
|
- name: Apply patches over upstream
|
|
run: |
|
|
cp -r patches/src/. upstream/src/
|
|
cp patches/Dockerfile upstream/Dockerfile 2>/dev/null || true
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- name: Install pnpm
|
|
run: npm install -g pnpm@9
|
|
|
|
- name: Install dependencies
|
|
working-directory: upstream
|
|
run: pnpm install --no-frozen-lockfile
|
|
|
|
- name: Run MCP patch tests
|
|
working-directory: upstream
|
|
run: |
|
|
pnpm exec vitest run \
|
|
src/agents/pi-bundle-mcp-runtime.test.ts \
|
|
src/agents/pi-bundle-mcp-push-notification.test.ts \
|
|
src/agents/pi-bundle-mcp-optimizations.test.ts
|
|
|
|
- name: Build patched upstream
|
|
working-directory: upstream
|
|
run: pnpm build
|
|
|
|
- name: Upload build artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: openclaw-dist
|
|
path: upstream/dist/
|
|
retention-days: 7
|
|
|
|
sync-upstream:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'schedule'
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Configure Git
|
|
run: |
|
|
git config user.name "gitea-actions[bot]"
|
|
git config user.email "gitea-actions[bot]@git.moleculesai.app"
|
|
|
|
- name: Add upstream remote
|
|
run: git remote add upstream ${{ env.UPSTREAM_REPO }}
|
|
|
|
- name: Fetch upstream
|
|
run: git fetch upstream main
|
|
|
|
- name: Check if upstream has new commits
|
|
id: check
|
|
run: |
|
|
# Compare latest upstream commit with what our patches were based on
|
|
UPSTREAM_SHA=$(git rev-parse upstream/main)
|
|
PATCHED_VERSION=$(cat PATCHED_VERSION.md 2>/dev/null | grep "^Upstream:" | cut -d' ' -f2 || echo "")
|
|
if [ "$UPSTREAM_SHA" = "$PATCHED_VERSION" ]; then
|
|
echo "sync_needed=false" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "sync_needed=true" >> $GITHUB_OUTPUT
|
|
echo "upstream_sha=$UPSTREAM_SHA" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Run tests on new upstream (smoke check before reporting)
|
|
if: steps.check.outputs.sync_needed == 'true'
|
|
run: |
|
|
git clone --depth 1 ${{ env.UPSTREAM_REPO }} /tmp/upstream-new
|
|
cp -r src/. /tmp/upstream-new/src/
|
|
cd /tmp/upstream-new
|
|
npm install -g pnpm@9
|
|
pnpm install --no-frozen-lockfile
|
|
pnpm exec vitest run src/agents/pi-bundle-mcp-runtime.test.ts || echo "::warning::Tests failed on new upstream — manual rebase may be needed"
|
|
|
|
- name: Update PATCHED_VERSION.md
|
|
if: steps.check.outputs.sync_needed == 'true'
|
|
run: |
|
|
echo "Upstream: ${{ steps.check.outputs.upstream_sha }}" > PATCHED_VERSION.md
|
|
echo "Updated: $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> PATCHED_VERSION.md
|
|
git add PATCHED_VERSION.md
|
|
git commit -m "chore: note upstream sync to ${{ steps.check.outputs.upstream_sha }}" || true
|
|
git push origin main
|