mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
ci: add optional Graphify code-graph workflows (code-only, no secrets) (#13005)
* ci: add optional Graphify code-graph workflows Build a code knowledge graph with the open-source Graphify CLI in code-only mode (tree-sitter, no API key or secret) on a daily schedule, cache graphify-out/ between runs, and upload graph.json.gz, graph.html and GRAPH_REPORT.md as a workflow artifact. Attach the same bundle to published releases. graph.json is about 150 MiB, above GitHub's 100 MiB file limit, so the graph is not committed; graphify-out/ is ignored. * ci: keep the Graphify cache bounded and align the release build - Set GRAPHIFY_NO_BACKUP=1. Hub-named community labels make graphify treat the graph as curated and snapshot it into graphify-out/<date>/ before every overwrite, without pruning; the cache would grow by ~100 MiB a day. The cache path also excludes graphify-out/20*. - Cluster once on a cold build (extract --no-cluster, then cluster-only), and label the release graph the same way as the scheduled one instead of "Community N" placeholders. - Release builds restore the default branch's cache (restore only) and run an incremental update instead of a cold extract. - Add workflow_dispatch with a tag input to graph-release.yml for releases created with GITHUB_TOKEN, which do not trigger the release event. - Use actions/cache@v6 and actions/setup-python@v7 like the rest of the repository; drop setup-uv and the full-history checkout. - Bundle graph.html only when graphify generated it. * ci: graph: build from a full extraction on every run graphify update re-extracts only the files that changed since the cached build. Go function ids include the file stem, so after a function moves to another file, callers in unchanged files keep edges to the old id, and the cache chain never resets that drift. A cold code-only build takes about five minutes on a hosted runner, so drop the cache and always extract. GRAPHIFY_NO_BACKUP only mattered for the cached graphify-out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: graph: attach the release bundle from a separate write job graph-release.yml ran graphify and its dependencies with a contents: write token persisted in the checkout's git config. Build the release bundle in the read-only graph job and upload it from a job that only downloads the artifact. The release asset is now the same bundle as the daily artifact, graph-health.json included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: graph: do not persist the checkout token Nothing after the checkout talks to a git remote, so keep the token out of .git/config where graphify could read it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: graph: keep artifact and asset names valid for any tag A dispatched tag such as release/v4.0 made an artifact name with a slash, which upload-artifact rejects. Name the artifact after the commit again and replace slashes in the release asset name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: graph: never call an LLM cluster-only auto-detects a labeling backend from API-key variables and the claude CLI; locally it picked up the claude CLI. Set GRAPHIFY_BACKEND=none so the build stays code-only even if a runner image provides one; communities keep hub-node names. --------- Co-authored-by: Konstantin Lebedev <whitefox@mayflower.work> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2 files changed
+130
No files matched your search
@@ -0,0 +1,127 @@
|
||||
name: Graph
|
||||
|
||||
# Builds a code knowledge graph with the open-source Graphify CLI and uploads
|
||||
# it as an artifact; a published release, or a dispatch naming a tag, also
|
||||
# gets it as a release asset. Code-only mode parses the repository with
|
||||
# tree-sitter and needs no API key or secret. Only the release job holds a
|
||||
# write token, and it runs no third-party code.
|
||||
#
|
||||
# A release created with the default GITHUB_TOKEN does not trigger this
|
||||
# workflow; dispatch it with the tag in that case.
|
||||
#
|
||||
# The graph is not committed: graph.json is ~150 MiB, above GitHub's 100 MiB
|
||||
# file limit.
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "23 4 * * *"
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Release tag to build and attach the bundle to (empty: artifact only)"
|
||||
required: false
|
||||
type: string
|
||||
|
||||
concurrency:
|
||||
group: graph-${{ github.ref }}-${{ inputs.tag }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
GRAPHIFY_VERSION: "0.9.112"
|
||||
# Stable community ids across runs.
|
||||
PYTHONHASHSEED: "0"
|
||||
# Never call an LLM, even if a runner image ships an API key or the claude
|
||||
# CLI: cluster-only auto-detects a labeling backend otherwise.
|
||||
GRAPHIFY_BACKEND: "none"
|
||||
TAG: ${{ github.event.release.tag_name || inputs.tag }}
|
||||
|
||||
jobs:
|
||||
graph:
|
||||
name: Build code graph
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
ref: ${{ env.TAG && format('refs/tags/{0}', env.TAG) || '' }}
|
||||
persist-credentials: false
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v7
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Install graphify
|
||||
run: python -m pip install "graphifyy==${GRAPHIFY_VERSION}"
|
||||
|
||||
# Always a full extraction: graphify update re-extracts only changed
|
||||
# files, so callers in unchanged files keep edges to a function's old
|
||||
# id after it moves to another file.
|
||||
- name: Build the graph
|
||||
run: |
|
||||
# Cluster once: extract alone does not write the report or HTML.
|
||||
# cluster-only names communities after their hub nodes
|
||||
# (GRAPHIFY_BACKEND=none keeps it from calling an LLM).
|
||||
graphify extract . --code-only --no-cluster
|
||||
graphify cluster-only .
|
||||
|
||||
- name: Graph health
|
||||
run: |
|
||||
graphify diagnose multigraph --json > graph-health.json
|
||||
python3 - <<'PY' >> "$GITHUB_STEP_SUMMARY"
|
||||
import json
|
||||
|
||||
summary = json.load(open("graph-health.json")).get("summary", {})
|
||||
print("### Graph health")
|
||||
print(f"- nodes: {summary.get('node_count', 'n/a')}")
|
||||
print(f"- edges: {summary.get('raw_edge_count', 'n/a')}")
|
||||
print(f"- dangling endpoints: {summary.get('dangling_endpoint_edges', 'n/a')}")
|
||||
print(f"- duplicate edges: {summary.get('exact_duplicate_edges', 'n/a')}")
|
||||
PY
|
||||
|
||||
- name: Bundle outputs
|
||||
run: |
|
||||
gzip -9 -c graphify-out/graph.json > graph.json.gz
|
||||
files=(graph.json.gz graphify-out/GRAPH_REPORT.md graph-health.json)
|
||||
# graphify skips graph.html when it cannot aggregate a large graph.
|
||||
if [ -f graphify-out/graph.html ]; then
|
||||
files+=(graphify-out/graph.html)
|
||||
else
|
||||
echo "::warning::graphify-out/graph.html was not generated"
|
||||
fi
|
||||
tar -czf graph-bundle.tar.gz "${files[@]}"
|
||||
|
||||
- name: Upload graph artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: graph-${{ github.sha }}
|
||||
path: graph-bundle.tar.gz
|
||||
retention-days: 14
|
||||
|
||||
release:
|
||||
name: Attach graph bundle
|
||||
needs: graph
|
||||
if: github.event_name == 'release' || inputs.tag != ''
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Download graph artifact
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: graph-${{ github.sha }}
|
||||
|
||||
- name: Upload release asset
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
asset="graph-${TAG//\//-}.tar.gz"
|
||||
mv graph-bundle.tar.gz "${asset}"
|
||||
gh release upload "${TAG}" "${asset}" --clobber --repo "${GITHUB_REPOSITORY}"
|
||||
Reference in new issue
Block a user