Configure Renovate to label patch/minor/pin/digest/lockFileMaintenance updates with 'automerge'. Add a merge-renovate job to ci.yml that runs after the check job passes on Renovate branches and merges PRs carrying that label; major-version PRs are left for manual review. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
160 lines
5.6 KiB
YAML
160 lines
5.6 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'lib/**'
|
|
- 'test/**'
|
|
- 'integration_test/**'
|
|
- 'android/**'
|
|
- 'linux/**'
|
|
- 'assets/**'
|
|
- '!assets/changelog.txt'
|
|
- 'pubspec.yaml'
|
|
- 'pubspec.lock'
|
|
- 'analysis_options.yaml'
|
|
- 'scripts/**'
|
|
- 'stalwart-dev/**'
|
|
- 'ci/**'
|
|
- 'Taskfile.yml'
|
|
- 'drift_schemas/**'
|
|
- '.forgejo/workflows/ci.yml'
|
|
pull_request:
|
|
paths:
|
|
- 'lib/**'
|
|
- 'test/**'
|
|
- 'integration_test/**'
|
|
- 'android/**'
|
|
- 'linux/**'
|
|
- 'assets/**'
|
|
- '!assets/changelog.txt'
|
|
- 'pubspec.yaml'
|
|
- 'pubspec.lock'
|
|
- 'analysis_options.yaml'
|
|
- 'scripts/**'
|
|
- 'stalwart-dev/**'
|
|
- 'ci/**'
|
|
- 'Taskfile.yml'
|
|
- 'drift_schemas/**'
|
|
- '.forgejo/workflows/ci.yml'
|
|
|
|
jobs:
|
|
check:
|
|
name: Full Project Check
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 50
|
|
|
|
- name: Check runner tools
|
|
run: |
|
|
command -v dagger >/dev/null 2>&1 || { echo "ERROR: dagger is not installed in the runner image. Add it to .forgejo/Dockerfile."; exit 1; }
|
|
command -v task >/dev/null 2>&1 || { echo "ERROR: task is not installed in the runner image. Add it to .forgejo/Dockerfile."; exit 1; }
|
|
dpkg -s stunnel4 netcat-openbsd >/dev/null 2>&1 || { echo "ERROR: stunnel4/netcat-openbsd are not installed in the runner image. Add them to .forgejo/Dockerfile."; exit 1; }
|
|
|
|
- name: Setup Dagger Remote Engine (via stunnel)
|
|
env:
|
|
DAGGER_STUNNEL_URL: ${{ secrets.DAGGER_STUNNEL_URL }}
|
|
DAGGER_CA_CERT: ${{ secrets.DAGGER_CA_CERT }}
|
|
DAGGER_CLIENT_CERT: ${{ secrets.DAGGER_CLIENT_CERT }}
|
|
DAGGER_CLIENT_KEY: ${{ secrets.DAGGER_CLIENT_KEY }}
|
|
run: scripts/setup_dagger_remote.sh
|
|
|
|
- name: Locate Docker daemon for local Dagger engine
|
|
run: |
|
|
# Skip if remote Dagger engine is already configured (preferred path)
|
|
if [ -n "${_DAGGER_RUNNER_HOST:-}" ]; then
|
|
echo "Remote Dagger engine configured, no local Docker needed."
|
|
exit 0
|
|
fi
|
|
|
|
# Try host Docker socket (DooD) if runner mounts it
|
|
if [ -S /var/run/docker.sock ]; then
|
|
if DOCKER_HOST=unix:///var/run/docker.sock docker info >/dev/null 2>&1; then
|
|
echo "Docker available via host socket."
|
|
echo "DOCKER_HOST=unix:///var/run/docker.sock" >> "$GITHUB_ENV"
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
echo "WARNING: No remote Dagger engine and no local Docker found." >&2
|
|
echo " - Remote engine: check DAGGER_STUNNEL_URL secret and that the host proxy is running." >&2
|
|
echo " - Local Docker: runner does not expose /var/run/docker.sock." >&2
|
|
echo "CI will likely fail at the Dagger step." >&2
|
|
|
|
- name: Prune Dagger cache before check
|
|
env:
|
|
DAGGER_NO_NAG: "1"
|
|
# prune(maxUsedSpace) also reclaims named cache volumes (gradle-cache, go-build-cache, etc.)
|
|
# when total cache exceeds the limit; without args only unreferenced entries are removed.
|
|
run: |
|
|
dagger query '{ engine { localCache { prune(maxUsedSpace: "75gb", targetSpace: "50gb") } } }' || true
|
|
|
|
- name: Run Full Check Suite
|
|
env:
|
|
DAGGER_NO_NAG: "1"
|
|
run: task check-dagger
|
|
|
|
- name: Prune Dagger cache after check
|
|
if: always()
|
|
env:
|
|
DAGGER_NO_NAG: "1"
|
|
run: |
|
|
dagger query '{ engine { localCache { prune(maxUsedSpace: "75gb", targetSpace: "50gb") } } }' || true
|
|
|
|
- name: Cleanup TLS credentials
|
|
if: always()
|
|
run: rm -rf /tmp/dagger-tls /tmp/stunnel-dagger.conf /tmp/stunnel.pid
|
|
|
|
merge-renovate:
|
|
name: Auto-merge Renovate PR
|
|
needs: [check]
|
|
if: github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/')
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
|
|
steps:
|
|
- name: Merge if automerge label is set
|
|
env:
|
|
FORGEJO_TOKEN: ${{ github.token }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
run: |
|
|
python3 - << 'PYEOF'
|
|
import os, json, urllib.request, urllib.error, sys
|
|
|
|
token = os.environ["FORGEJO_TOKEN"]
|
|
url_base = os.environ.get("GITHUB_SERVER_URL", "").rstrip("/")
|
|
repo = os.environ.get("GITHUB_REPOSITORY", "")
|
|
pr_number = os.environ["PR_NUMBER"]
|
|
api = f"{url_base}/api/v1/repos/{repo}"
|
|
headers = {"Authorization": f"token {token}", "Content-Type": "application/json"}
|
|
|
|
req = urllib.request.Request(f"{api}/issues/{pr_number}/labels", headers=headers)
|
|
with urllib.request.urlopen(req) as r:
|
|
labels = [l["name"] for l in json.loads(r.read())]
|
|
|
|
if "automerge" not in labels:
|
|
print(f"PR #{pr_number}: no 'automerge' label — major update, skipping")
|
|
sys.exit(0)
|
|
|
|
body = json.dumps({"Do": "merge"}).encode()
|
|
req = urllib.request.Request(
|
|
f"{api}/pulls/{pr_number}/merge",
|
|
data=body, headers=headers, method="POST"
|
|
)
|
|
try:
|
|
with urllib.request.urlopen(req) as r:
|
|
print(f"PR #{pr_number} merged successfully")
|
|
except urllib.error.HTTPError as e:
|
|
err = e.read().decode()
|
|
if "already been merged" in err or "has been merged" in err:
|
|
print(f"PR #{pr_number} already merged — OK")
|
|
else:
|
|
print(f"Merge failed: {err}")
|
|
sys.exit(1)
|
|
PYEOF
|