Skip to content

chore(ci): replace hardcoded server commit with latest release#732

Merged
imbajin merged 9 commits into
apache:masterfrom
lokidundun:unifyci
May 9, 2026
Merged

chore(ci): replace hardcoded server commit with latest release#732
imbajin merged 9 commits into
apache:masterfrom
lokidundun:unifyci

Conversation

@lokidundun
Copy link
Copy Markdown
Contributor

Purpose of the PR

  • close #xxx

Main Changes

  1. CI: track latest HugeGraph stable release instead of hardcoded commit

All 6 workflows (client-ci, client-go-ci, hubble-ci, loader-ci, spark-connector-ci, tools-ci) previously had a # TODO: replace it with the (latest - n) commit id (n >= 15)
reminder with a manually-pinned COMMIT_ID. These SHAs drift out of date and silently miss server-side regressions.

Replaced the static value with an actions/github-script@v7 step that:

  • queries apache/hugegraph's latest GitHub release via getLatestRelease
  • resolves the tag through getRef and dereferences annotated tags via getTag (lightweight tags work too)
  • exports the 7-char SHA as COMMIT_ID for downstream install-hugegraph-from-source.sh $COMMIT_ID

CI now follows the most recent stable release with zero manual upkeep.

  1. loader-ci: cache the built HugeGraph server

Reused the resolved release SHA as a cache key (~/hugegraph-cache-${commit_id}) so subsequent CI runs skip the server build entirely as long as the upstream release hasn't
moved.

  1. hugegraph-client-go: adapt gremlin to HugeGraph 1.7.0+ graph-space bindings

Server 1.7.0 introduced graph spaces and changed how the gremlin engine registers traversal sources — the graph is no longer a top-level Groovy global named , it's now
aliased as __g_DEFAULT- (where DEFAULT is the default graph space). The Java client was updated for this in GremlinManager.java; the Go client was not, so every gremlin
POST against a 1.7.0+ server failed with:

Could not rebind [g] to [__g_hugegraph] as [__g_hugegraph] not in the Graph or TraversalSource global bindings

Ported the Java behavior:

  • gemlin.go: aliases field on PostRequest / PostRequestData is now map[string]string (was an empty anonymous struct that silently dropped values).
  • Added buildDefaultAliases(transport) mirroring GremlinManager.java:46-56 and HugeClientBuilder.DEFAULT_GRAPHSPACE = "DEFAULT": returns {"graph": "DEFAULT-", "g":
    "__g_DEFAULT-"} when the caller hasn't supplied custom aliases.
  • PostRequest.Do auto-injects on every gremlin POST. GET is intentionally untouched — the Java client has no GET equivalent, and the server's /gremlin GET endpoint cannot accept
    JSON aliases query params due to a Jersey URI-template parser conflict on { / }.
  • gemlin_test.go: removed the GET assertion (would 500 on 1.7.0+ regardless of client changes), changed the POST script from hugegraph.traversal().V().limit(3) to g.V().limit(3)
    to match Java's g.V().count() convention, and surfaced server status/message on failure for easier diagnosis.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • xxx

Does this PR potentially affect the following parts?

  • Nope
  • Dependencies (add/update license info)
  • Modify configurations
  • The public API
  • Other affects (typed here)

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 2, 2026
@github-actions github-actions Bot added the client hugegraph-client label May 2, 2026
@dosubot dosubot Bot added the ci Continuous integration label May 2, 2026
@imbajin imbajin requested a review from Copilot May 4, 2026 02:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates CI workflows to follow the latest Apache HugeGraph stable release automatically (instead of pinned SHAs), and adjusts the Go Gremlin client to work with HugeGraph 1.7.0+ graph-space traversal source bindings.

Changes:

  • CI: replace hardcoded COMMIT_ID in multiple workflows with a github-script step that resolves the latest release tag to a commit SHA.
  • CI (loader): key the HugeGraph server cache using the resolved release commit.
  • Go client: send default Gremlin aliases on POST requests and update Gremlin tests to use g.V().

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
hugegraph-client-go/api/v1/gremlin/gemlin.go Switch Gremlin POST aliases to a map and auto-inject default aliases for HugeGraph 1.7.0+.
hugegraph-client-go/api/v1/gremlin/gemlin_test.go Update Gremlin test to use g.V() and improve failure reporting.
.github/workflows/tools-ci.yml Resolve COMMIT_ID from latest HugeGraph release tag via actions/github-script.
.github/workflows/spark-connector-ci.yml Resolve COMMIT_ID from latest HugeGraph release tag via actions/github-script.
.github/workflows/loader-ci.yml Resolve COMMIT_ID dynamically and adjust server cache key/path to the resolved commit.
.github/workflows/hubble-ci.yml Resolve COMMIT_ID from latest HugeGraph release tag via actions/github-script.
.github/workflows/client-go-ci.yml Resolve COMMIT_ID from latest HugeGraph release tag via actions/github-script.
.github/workflows/client-ci.yml Resolve COMMIT_ID from latest HugeGraph release tag via actions/github-script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/tools-ci.yml Outdated
const { data: tag } = await github.rest.git.getTag({ owner, repo, tag_sha: sha });
sha = tag.object.sha;
}
sha = sha.substring(0, 7);
Comment thread .github/workflows/hubble-ci.yml Outdated
const { data: tag } = await github.rest.git.getTag({ owner, repo, tag_sha: sha });
sha = tag.object.sha;
}
sha = sha.substring(0, 7);
Comment on lines +134 to +145
func buildDefaultAliases(transport api.Transport) map[string]string {
cfg := transport.GetConfig()
graphSpace := cfg.GraphSpace
if graphSpace == "" {
graphSpace = "DEFAULT"
}
full := graphSpace + "-" + cfg.Graph
return map[string]string{
"graph": full,
"g": "__g_" + full,
}
}
Comment on lines +132 to +133
// Sending these aliases lets scripts use `g.V()` against the active graph
// regardless of how the server names its bindings internally.
Comment on lines +42 to +43
t.Errorf("client.Gremlin.Post status=%d, message=%s",
respPost.StatusCode, respPost.Data.Message)
const { data: tag } = await github.rest.git.getTag({ owner, repo, tag_sha: sha });
sha = tag.object.sha;
}
sha = sha.substring(0, 7);
Comment thread .github/workflows/loader-ci.yml Outdated
const { data: tag } = await github.rest.git.getTag({ owner, repo, tag_sha: sha });
sha = tag.object.sha;
}
sha = sha.substring(0, 7);
Comment thread .github/workflows/client-go-ci.yml Outdated
const { data: tag } = await github.rest.git.getTag({ owner, repo, tag_sha: sha });
sha = tag.object.sha;
}
sha = sha.substring(0, 7);
Comment thread .github/workflows/client-ci.yml Outdated
const { data: tag } = await github.rest.git.getTag({ owner, repo, tag_sha: sha });
sha = tag.object.sha;
}
sha = sha.substring(0, 7);
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.34%. Comparing base (b066b80) to head (0871406).
⚠️ Report is 78 commits behind head on master.

Additional details and impacted files
@@              Coverage Diff              @@
##             master     #732       +/-   ##
=============================================
- Coverage     62.49%   39.34%   -23.16%     
- Complexity     1903     2199      +296     
=============================================
  Files           262      468      +206     
  Lines          9541    17353     +7812     
  Branches        886     1819      +933     
=============================================
+ Hits           5963     6828      +865     
- Misses         3190    10038     +6848     
- Partials        388      487       +99     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Comment on lines +129 to +139
func buildDefaultAliases(transport api.Transport) map[string]string {
cfg := transport.GetConfig()
graphSpace := cfg.GraphSpace
if graphSpace == "" {
graphSpace = "DEFAULT"
}
full := graphSpace + "-" + cfg.Graph
return map[string]string{
"graph": full,
"g": "__g_" + full,
}
Comment on lines +23 to +30
let sha = ref.object.sha;
if (ref.object.type === 'tag') {
const { data: tag } = await github.rest.git.getTag({ owner, repo, tag_sha: sha });
sha = tag.object.sha;
}
core.exportVariable('COMMIT_ID', sha);
core.setOutput('commit_id', sha);
console.log(`Using HugeGraph release ${release.tag_name} (${sha})`);
Comment on lines +28 to +34
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

Copy link
Copy Markdown
Member

@imbajin imbajin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the approach is solid: composite actions cleanly eliminate duplicated CI boilerplate, and the Go gremlin alias fix correctly addresses the 1.7.0 graph-space binding regression. Two issues need attention before merging, plus a couple of minor nits.

with:
java-version: ${{ inputs.java-version }}
distribution: ${{ inputs.distribution }}
cache: 'maven'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Redundant double Maven cache

actions/setup-java@v4 with cache: 'maven' already saves/restores ~/.m2/repository internally using a setup-java-namespaced key. The explicit Cache Maven packages step below (lines 28-33) targets the same directory with a different key, so every job saves two separate cache entries for identical content.

For workflows that previously had only one cache mechanism (tools-ci, spark-connector-ci, client-go-ci, loader-ci), this PR silently doubles the cache storage and upload time.

Remove either:

  • the cache: 'maven' line here, keeping the explicit step below, OR
  • the entire - name: Cache Maven packages block (lines 28-33), relying solely on setup-java's built-in caching.

Both approaches work; the latter is less YAML and the recommended pattern for setup-java@v4.

uses: actions/setup-java@v4
- name: Get HugeGraph stable commit id
id: get-commit
uses: ./.github/actions/get-hugegraph-commit
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Implicit $COMMIT_ID — invisible to readers of this file

The Prepare env and service step (later in the workflow, not in the diff) still runs:

$TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID

COMMIT_ID is no longer in the job env block. It works only because this composite action calls core.exportVariable('COMMIT_ID', sha) which writes to $GITHUB_ENV. A reader scanning the workflow file will see no COMMIT_ID definition and have no idea where it comes from.

All other workflows in this PR pass the SHA explicitly via steps.get-commit.outputs.commit_id. Align loader-ci to the same pattern — either convert the install step to use the setup-hugegraph-server composite action, or add an explicit env binding to that step:

- name: Prepare env and service
  env:
    COMMIT_ID: ${{ steps.get-commit.outputs.commit_id }}
  run: |
    $TRAVIS_DIR/install-hadoop.sh
    $TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID

uses: actions/setup-java@v3
- name: Get HugeGraph stable commit id
id: get-commit
uses: ./.github/actions/get-hugegraph-commit
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Same implicit $COMMIT_ID issue as loader-ci

The Prepare env and service step later in this file calls:

$TRAVIS_DIR/install-hugegraph.sh $COMMIT_ID

steps.get-commit.outputs.commit_id is never referenced by name anywhere in this file — it only works via the core.exportVariable side-effect. Make the dependency explicit:

- name: Prepare env and service
  env:
    COMMIT_ID: ${{ steps.get-commit.outputs.commit_id }}
  run: |
    ...
    $TRAVIS_DIR/install-hugegraph.sh $COMMIT_ID

log.Fatalln(err)
}
if respPost.StatusCode != 200 {
t.Errorf("client.Gremlin.Post http_status=%d, gremlin_status=%d, message=%s",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Extra leading space — fails gofmt

The t.Errorf line has 5 spaces of indentation instead of a tab. gofmt will produce a diff on this file.

Suggested change
t.Errorf("client.Gremlin.Post http_status=%d, gremlin_status=%d, message=%s",
t.Errorf("client.Gremlin.Post http_status=%d, gremlin_status=%d, message=%s",
respPost.StatusCode, respPost.Data.Status.Code, respPost.Data.Status.Message)

if graphSpace == "" {
graphSpace = "DEFAULT"
}
full := graphSpace + "-" + cfg.Graph
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Unguarded empty Graph field produces a silent bad alias

If a caller constructs a client without setting Graph, full becomes "DEFAULT-" and the alias g becomes "__g_DEFAULT-". The server will accept the POST but return an error like "TraversalSource not found", which is very hard to diagnose.

Since NewCommonClient does not validate that Graph is non-empty, a small guard here makes failures explicit:

Suggested change
full := graphSpace + "-" + cfg.Graph
if cfg.Graph == "" {
cfg.Graph = "hugegraph"
}
full := graphSpace + "-" + cfg.Graph

(Or add the check to NewCommonClient and document the default.)

@lokidundun lokidundun requested a review from imbajin May 8, 2026 14:44
Copy link
Copy Markdown
Member

@imbajin imbajin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THX~

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 9, 2026
@imbajin imbajin merged commit 077802f into apache:master May 9, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continuous integration client hugegraph-client lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants