From c6ef656f70560c0ac4ccf8be1596cf1e2f64ea25 Mon Sep 17 00:00:00 2001 From: Loki Date: Fri, 1 May 2026 21:50:36 +0800 Subject: [PATCH 1/9] optimize: remove TODO commitId --- .github/workflows/client-ci.yml | 22 +++++++++++++++++++--- .github/workflows/client-go-ci.yml | 22 +++++++++++++++++++--- .github/workflows/hubble-ci.yml | 22 +++++++++++++++++++--- .github/workflows/loader-ci.yml | 22 +++++++++++++++++++--- .github/workflows/spark-connector-ci.yml | 21 +++++++++++++++++++-- .github/workflows/tools-ci.yml | 22 +++++++++++++++++++--- 6 files changed, 114 insertions(+), 17 deletions(-) diff --git a/.github/workflows/client-ci.yml b/.github/workflows/client-ci.yml index 0551d6ad5..95a86f237 100644 --- a/.github/workflows/client-ci.yml +++ b/.github/workflows/client-ci.yml @@ -24,9 +24,6 @@ jobs: env: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-client/assembly/travis - # TODO: replace it with the (latest - n) commit id (n >= 15) - # hugegraph commit date: 2025-11-4 - COMMIT_ID: b7998c1 strategy: fail-fast: false matrix: @@ -39,6 +36,25 @@ jobs: with: fetch-depth: 2 + - name: Get HugeGraph stable commit id + id: get-commit + uses: actions/github-script@v7 + with: + script: | + const offset = 15; + const { data: commits } = await github.rest.repos.listCommits({ + owner: 'apache', + repo: 'hugegraph', + per_page: offset + 1 + }); + if (commits.length <= offset) { + core.setFailed(`Not enough commits. Found ${commits.length}, needed ${offset + 1}`); + return; + } + const sha = commits[offset].sha.substring(0, 7); + core.exportVariable('COMMIT_ID', sha); + console.log(`Using HugeGraph commit id: ${sha}`); + # TODO: do we need it? (need test) - name: Cache Maven packages uses: actions/cache@v4 diff --git a/.github/workflows/client-go-ci.yml b/.github/workflows/client-go-ci.yml index 45064073d..5c39d0235 100644 --- a/.github/workflows/client-go-ci.yml +++ b/.github/workflows/client-go-ci.yml @@ -23,9 +23,6 @@ jobs: env: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-client/assembly/travis - # TODO: replace it with the (latest - n) commit id (n >= 15) - # FIXME: hugegraph commit date: 2025-10-30 - COMMIT_ID: 8c1ee71 # 5b3d295 strategy: fail-fast: false matrix: @@ -37,6 +34,25 @@ jobs: with: fetch-depth: 2 + - name: Get HugeGraph stable commit id + id: get-commit + uses: actions/github-script@v7 + with: + script: | + const offset = 15; + const { data: commits } = await github.rest.repos.listCommits({ + owner: 'apache', + repo: 'hugegraph', + per_page: offset + 1 + }); + if (commits.length <= offset) { + core.setFailed(`Not enough commits. Found ${commits.length}, needed ${offset + 1}`); + return; + } + const sha = commits[offset].sha.substring(0, 7); + core.exportVariable('COMMIT_ID', sha); + console.log(`Using HugeGraph commit id: ${sha}`); + - name: Install JDK 11 uses: actions/setup-java@v3 with: diff --git a/.github/workflows/hubble-ci.yml b/.github/workflows/hubble-ci.yml index 4cd3f7780..c5cc88be7 100644 --- a/.github/workflows/hubble-ci.yml +++ b/.github/workflows/hubble-ci.yml @@ -23,9 +23,6 @@ on: env: TRAVIS_DIR: hugegraph-hubble/hubble-dist/assembly/travis - # TODO: replace it with the (latest - n) commit id (n >= 15) - # FIXME: hugegraph commit date: 2025-10-30 - COMMIT_ID: 8c1ee71 # 5b3d295 jobs: hubble-ci: @@ -44,6 +41,25 @@ jobs: with: fetch-depth: 2 + - name: Get HugeGraph stable commit id + id: get-commit + uses: actions/github-script@v7 + with: + script: | + const offset = 15; + const { data: commits } = await github.rest.repos.listCommits({ + owner: 'apache', + repo: 'hugegraph', + per_page: offset + 1 + }); + if (commits.length <= offset) { + core.setFailed(`Not enough commits. Found ${commits.length}, needed ${offset + 1}`); + return; + } + const sha = commits[offset].sha.substring(0, 7); + core.exportVariable('COMMIT_ID', sha); + console.log(`Using HugeGraph commit id: ${sha}`); + - name: Install JDK 11 uses: actions/setup-java@v3 with: diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml index d992117b4..6a924d3d9 100644 --- a/.github/workflows/loader-ci.yml +++ b/.github/workflows/loader-ci.yml @@ -26,9 +26,6 @@ jobs: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-loader/assembly/travis STATIC_DIR: hugegraph-loader/assembly/static - # TODO: replace it with the (latest - n) commit id (n >= 15) - # hugegraph commit date: 2025-10-30 - COMMIT_ID: 5b3d295 DB_USER: root DB_PASS: root DB_DATABASE: load_test @@ -50,6 +47,25 @@ jobs: with: fetch-depth: 2 + - name: Get HugeGraph stable commit id + id: get-commit + uses: actions/github-script@v7 + with: + script: | + const offset = 15; + const { data: commits } = await github.rest.repos.listCommits({ + owner: 'apache', + repo: 'hugegraph', + per_page: offset + 1 + }); + if (commits.length <= offset) { + core.setFailed(`Not enough commits. Found ${commits.length}, needed ${offset + 1}`); + return; + } + const sha = commits[offset].sha.substring(0, 7); + core.exportVariable('COMMIT_ID', sha); + console.log(`Using HugeGraph commit id: ${sha}`); + - name: Install JDK 11 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/spark-connector-ci.yml b/.github/workflows/spark-connector-ci.yml index 4c077e9e3..afc8e9da1 100644 --- a/.github/workflows/spark-connector-ci.yml +++ b/.github/workflows/spark-connector-ci.yml @@ -25,8 +25,6 @@ jobs: env: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-spark-connector/assembly/travis - # hugegraph commit date: 2025-10-30 - COMMIT_ID: 5b3d295 strategy: matrix: JAVA_VERSION: [ '11' ] @@ -37,6 +35,25 @@ jobs: with: fetch-depth: 2 + - name: Get HugeGraph stable commit id + id: get-commit + uses: actions/github-script@v7 + with: + script: | + const offset = 15; + const { data: commits } = await github.rest.repos.listCommits({ + owner: 'apache', + repo: 'hugegraph', + per_page: offset + 1 + }); + if (commits.length <= offset) { + core.setFailed(`Not enough commits. Found ${commits.length}, needed ${offset + 1}`); + return; + } + const sha = commits[offset].sha.substring(0, 7); + core.exportVariable('COMMIT_ID', sha); + console.log(`Using HugeGraph commit id: ${sha}`); + - name: Install JDK 11 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/tools-ci.yml b/.github/workflows/tools-ci.yml index 2ee9143cd..ac70f0e9b 100644 --- a/.github/workflows/tools-ci.yml +++ b/.github/workflows/tools-ci.yml @@ -25,9 +25,6 @@ jobs: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-tools/assembly/travis # TODO: could we use one param to unify it? or use a action template (could use one ci file) - # TODO: replace it with the (latest - n) commit id (n >= 15) - # hugegraph commit date: 2025-11-4 - COMMIT_ID: b7998c1 strategy: matrix: JAVA_VERSION: [ '11' ] @@ -38,6 +35,25 @@ jobs: with: fetch-depth: 2 + - name: Get HugeGraph stable commit id + id: get-commit + uses: actions/github-script@v7 + with: + script: | + const offset = 15; + const { data: commits } = await github.rest.repos.listCommits({ + owner: 'apache', + repo: 'hugegraph', + per_page: offset + 1 + }); + if (commits.length <= offset) { + core.setFailed(`Not enough commits. Found ${commits.length}, needed ${offset + 1}`); + return; + } + const sha = commits[offset].sha.substring(0, 7); + core.exportVariable('COMMIT_ID', sha); + console.log(`Using HugeGraph commit id: ${sha}`); + - name: Install JDK 11 uses: actions/setup-java@v3 with: From 0cceca1ee259c05847577656a3f9a006eb5cea07 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 1 May 2026 14:04:41 +0000 Subject: [PATCH 2/9] fix: use commit output for loader cache key Agent-Logs-Url: https://github.com/lokidundun/hugegraph-toolchain/sessions/6d86bea0-38a3-45d5-8e70-13d5e64b21bf Co-authored-by: lokidundun <206712414+lokidundun@users.noreply.github.com> --- .github/workflows/loader-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml index 6a924d3d9..527b05c3d 100644 --- a/.github/workflows/loader-ci.yml +++ b/.github/workflows/loader-ci.yml @@ -64,6 +64,7 @@ jobs: } const sha = commits[offset].sha.substring(0, 7); core.exportVariable('COMMIT_ID', sha); + core.setOutput('commit_id', sha); console.log(`Using HugeGraph commit id: ${sha}`); - name: Install JDK 11 @@ -88,8 +89,8 @@ jobs: - name: Cache HugeGraph Server uses: actions/cache@v4 with: - path: ~/hugegraph-cache-${{ env.COMMIT_ID }} - key: ${{ runner.os }}-hugegraph-server-${{ env.COMMIT_ID }} + path: ~/hugegraph-cache-${{ steps.get-commit.outputs.commit_id }} + key: ${{ runner.os }}-hugegraph-server-${{ steps.get-commit.outputs.commit_id }} - name: use staged maven repo settings if: ${{ env.USE_STAGE == 'true' }} From b9ac8f53eb57224c984bcbd1840398e04b788ba8 Mon Sep 17 00:00:00 2001 From: Loki Date: Fri, 1 May 2026 23:43:31 +0800 Subject: [PATCH 3/9] test --- .github/workflows/client-ci.yml | 22 ++++++++++++---------- .github/workflows/client-go-ci.yml | 22 ++++++++++++---------- .github/workflows/hubble-ci.yml | 22 ++++++++++++---------- .github/workflows/loader-ci.yml | 21 +++++++++++---------- .github/workflows/spark-connector-ci.yml | 22 ++++++++++++---------- .github/workflows/tools-ci.yml | 22 ++++++++++++---------- 6 files changed, 71 insertions(+), 60 deletions(-) diff --git a/.github/workflows/client-ci.yml b/.github/workflows/client-ci.yml index 95a86f237..2d4f959b1 100644 --- a/.github/workflows/client-ci.yml +++ b/.github/workflows/client-ci.yml @@ -41,19 +41,21 @@ jobs: uses: actions/github-script@v7 with: script: | - const offset = 15; - const { data: commits } = await github.rest.repos.listCommits({ - owner: 'apache', - repo: 'hugegraph', - per_page: offset + 1 + const owner = 'apache'; + const repo = 'hugegraph'; + const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); + const { data: ref } = await github.rest.git.getRef({ + owner, repo, ref: `tags/${release.tag_name}` }); - if (commits.length <= offset) { - core.setFailed(`Not enough commits. Found ${commits.length}, needed ${offset + 1}`); - return; + 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; } - const sha = commits[offset].sha.substring(0, 7); + sha = sha.substring(0, 7); core.exportVariable('COMMIT_ID', sha); - console.log(`Using HugeGraph commit id: ${sha}`); + core.setOutput('commit_id', sha); + console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); # TODO: do we need it? (need test) - name: Cache Maven packages diff --git a/.github/workflows/client-go-ci.yml b/.github/workflows/client-go-ci.yml index 5c39d0235..6f9f61589 100644 --- a/.github/workflows/client-go-ci.yml +++ b/.github/workflows/client-go-ci.yml @@ -39,19 +39,21 @@ jobs: uses: actions/github-script@v7 with: script: | - const offset = 15; - const { data: commits } = await github.rest.repos.listCommits({ - owner: 'apache', - repo: 'hugegraph', - per_page: offset + 1 + const owner = 'apache'; + const repo = 'hugegraph'; + const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); + const { data: ref } = await github.rest.git.getRef({ + owner, repo, ref: `tags/${release.tag_name}` }); - if (commits.length <= offset) { - core.setFailed(`Not enough commits. Found ${commits.length}, needed ${offset + 1}`); - return; + 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; } - const sha = commits[offset].sha.substring(0, 7); + sha = sha.substring(0, 7); core.exportVariable('COMMIT_ID', sha); - console.log(`Using HugeGraph commit id: ${sha}`); + core.setOutput('commit_id', sha); + console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); - name: Install JDK 11 uses: actions/setup-java@v3 diff --git a/.github/workflows/hubble-ci.yml b/.github/workflows/hubble-ci.yml index c5cc88be7..7022ed3ed 100644 --- a/.github/workflows/hubble-ci.yml +++ b/.github/workflows/hubble-ci.yml @@ -46,19 +46,21 @@ jobs: uses: actions/github-script@v7 with: script: | - const offset = 15; - const { data: commits } = await github.rest.repos.listCommits({ - owner: 'apache', - repo: 'hugegraph', - per_page: offset + 1 + const owner = 'apache'; + const repo = 'hugegraph'; + const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); + const { data: ref } = await github.rest.git.getRef({ + owner, repo, ref: `tags/${release.tag_name}` }); - if (commits.length <= offset) { - core.setFailed(`Not enough commits. Found ${commits.length}, needed ${offset + 1}`); - return; + 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; } - const sha = commits[offset].sha.substring(0, 7); + sha = sha.substring(0, 7); core.exportVariable('COMMIT_ID', sha); - console.log(`Using HugeGraph commit id: ${sha}`); + core.setOutput('commit_id', sha); + console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); - name: Install JDK 11 uses: actions/setup-java@v3 diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml index 527b05c3d..b0fe7b294 100644 --- a/.github/workflows/loader-ci.yml +++ b/.github/workflows/loader-ci.yml @@ -52,20 +52,21 @@ jobs: uses: actions/github-script@v7 with: script: | - const offset = 15; - const { data: commits } = await github.rest.repos.listCommits({ - owner: 'apache', - repo: 'hugegraph', - per_page: offset + 1 + const owner = 'apache'; + const repo = 'hugegraph'; + const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); + const { data: ref } = await github.rest.git.getRef({ + owner, repo, ref: `tags/${release.tag_name}` }); - if (commits.length <= offset) { - core.setFailed(`Not enough commits. Found ${commits.length}, needed ${offset + 1}`); - return; + 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; } - const sha = commits[offset].sha.substring(0, 7); + sha = sha.substring(0, 7); core.exportVariable('COMMIT_ID', sha); core.setOutput('commit_id', sha); - console.log(`Using HugeGraph commit id: ${sha}`); + console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); - name: Install JDK 11 uses: actions/setup-java@v4 diff --git a/.github/workflows/spark-connector-ci.yml b/.github/workflows/spark-connector-ci.yml index afc8e9da1..b307a1f54 100644 --- a/.github/workflows/spark-connector-ci.yml +++ b/.github/workflows/spark-connector-ci.yml @@ -40,19 +40,21 @@ jobs: uses: actions/github-script@v7 with: script: | - const offset = 15; - const { data: commits } = await github.rest.repos.listCommits({ - owner: 'apache', - repo: 'hugegraph', - per_page: offset + 1 + const owner = 'apache'; + const repo = 'hugegraph'; + const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); + const { data: ref } = await github.rest.git.getRef({ + owner, repo, ref: `tags/${release.tag_name}` }); - if (commits.length <= offset) { - core.setFailed(`Not enough commits. Found ${commits.length}, needed ${offset + 1}`); - return; + 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; } - const sha = commits[offset].sha.substring(0, 7); + sha = sha.substring(0, 7); core.exportVariable('COMMIT_ID', sha); - console.log(`Using HugeGraph commit id: ${sha}`); + core.setOutput('commit_id', sha); + console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); - name: Install JDK 11 uses: actions/setup-java@v4 diff --git a/.github/workflows/tools-ci.yml b/.github/workflows/tools-ci.yml index ac70f0e9b..bdd41772f 100644 --- a/.github/workflows/tools-ci.yml +++ b/.github/workflows/tools-ci.yml @@ -40,19 +40,21 @@ jobs: uses: actions/github-script@v7 with: script: | - const offset = 15; - const { data: commits } = await github.rest.repos.listCommits({ - owner: 'apache', - repo: 'hugegraph', - per_page: offset + 1 + const owner = 'apache'; + const repo = 'hugegraph'; + const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); + const { data: ref } = await github.rest.git.getRef({ + owner, repo, ref: `tags/${release.tag_name}` }); - if (commits.length <= offset) { - core.setFailed(`Not enough commits. Found ${commits.length}, needed ${offset + 1}`); - return; + 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; } - const sha = commits[offset].sha.substring(0, 7); + sha = sha.substring(0, 7); core.exportVariable('COMMIT_ID', sha); - console.log(`Using HugeGraph commit id: ${sha}`); + core.setOutput('commit_id', sha); + console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); - name: Install JDK 11 uses: actions/setup-java@v3 From e39577e4511b7e757ac43b46999f900acb17b91b Mon Sep 17 00:00:00 2001 From: Loki Date: Sat, 2 May 2026 12:22:03 +0800 Subject: [PATCH 4/9] fix go client --- hugegraph-client-go/api/v1/gremlin/gemlin.go | 36 ++++++++++++++----- .../api/v1/gremlin/gemlin_test.go | 4 +-- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/hugegraph-client-go/api/v1/gremlin/gemlin.go b/hugegraph-client-go/api/v1/gremlin/gemlin.go index a2c3112bf..9ec5d5754 100644 --- a/hugegraph-client-go/api/v1/gremlin/gemlin.go +++ b/hugegraph-client-go/api/v1/gremlin/gemlin.go @@ -83,19 +83,13 @@ type PostRequest struct { gremlin string bindings map[string]string language string - aliases struct { - //Graph string `json:"graph"` - //G string `json:"g"` - } + aliases map[string]string } type PostRequestData struct { Gremlin string `json:"gremlin"` Bindings map[string]string `json:"bindings,omitempty"` Language string `json:"language,omitempty"` - Aliases struct { - //Graph string `json:"graph"` - //G string `json:"g"` - } `json:"aliases,omitempty"` + Aliases map[string]string `json:"aliases,omitempty"` } type PostResponse struct { StatusCode int `json:"-"` @@ -132,6 +126,23 @@ func (g Post) WithGremlin(gremlin string) func(request *PostRequest) { } } +// buildDefaultAliases mirrors GremlinManager.java: aliases the requested +// graph name to the conventional traversal source so that scripts can use +// `g.V()` / `g.E()` against the active graph. +func buildDefaultAliases(transport api.Transport) map[string]string { + cfg := transport.GetConfig() + aliases := map[string]string{} + if cfg.GraphSpace != "" { + full := cfg.GraphSpace + "-" + cfg.Graph + aliases["graph"] = full + aliases["g"] = "__g_" + full + } else { + aliases["graph"] = cfg.Graph + aliases["g"] = "__g_" + cfg.Graph + } + return aliases +} + func (g GetRequest) Do(ctx context.Context, transport api.Transport) (*GetResponse, error) { url := "/gremlin" @@ -145,7 +156,10 @@ func (g GetRequest) Do(ctx context.Context, transport api.Transport) (*GetRespon params.Add("language", g.language) } - if g.aliases != nil && len(g.aliases) >= 0 { + if g.aliases == nil { + g.aliases = buildDefaultAliases(transport) + } + if len(g.aliases) > 0 { aliasesJsonStr, err := json.Marshal(g.aliases) if err != nil { return nil, err @@ -195,6 +209,10 @@ func (g PostRequest) Do(ctx context.Context, transport api.Transport) (*PostResp g.language = "gremlin-groovy" } + if g.aliases == nil { + g.aliases = buildDefaultAliases(transport) + } + gd := &PostRequestData{ Gremlin: g.gremlin, Bindings: g.bindings, diff --git a/hugegraph-client-go/api/v1/gremlin/gemlin_test.go b/hugegraph-client-go/api/v1/gremlin/gemlin_test.go index d880c8878..64cb9b4e0 100644 --- a/hugegraph-client-go/api/v1/gremlin/gemlin_test.go +++ b/hugegraph-client-go/api/v1/gremlin/gemlin_test.go @@ -32,7 +32,7 @@ func TestGremlin(t *testing.T) { log.Println(err) } respGet, err := client.Gremlin.Get( - client.Gremlin.Get.WithGremlin("hugegraph.traversal().V().limit(3)"), + client.Gremlin.Get.WithGremlin("g.V().limit(3)"), ) if err != nil { log.Fatalln(err) @@ -42,7 +42,7 @@ func TestGremlin(t *testing.T) { } respPost, err := client.Gremlin.Post( - client.Gremlin.Post.WithGremlin("hugegraph.traversal().V().limit(3)"), + client.Gremlin.Post.WithGremlin("g.V().limit(3)"), ) if err != nil { log.Fatalln(err) From e043aa1c3ef204a73d9c5a0cf491351b02b54620 Mon Sep 17 00:00:00 2001 From: Loki Date: Sat, 2 May 2026 13:42:27 +0800 Subject: [PATCH 5/9] reverse --- .github/workflows/client-go-ci.yml | 24 ++----------- hugegraph-client-go/api/v1/gremlin/gemlin.go | 36 +++++-------------- .../api/v1/gremlin/gemlin_test.go | 4 +-- 3 files changed, 14 insertions(+), 50 deletions(-) diff --git a/.github/workflows/client-go-ci.yml b/.github/workflows/client-go-ci.yml index 6f9f61589..45064073d 100644 --- a/.github/workflows/client-go-ci.yml +++ b/.github/workflows/client-go-ci.yml @@ -23,6 +23,9 @@ jobs: env: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-client/assembly/travis + # TODO: replace it with the (latest - n) commit id (n >= 15) + # FIXME: hugegraph commit date: 2025-10-30 + COMMIT_ID: 8c1ee71 # 5b3d295 strategy: fail-fast: false matrix: @@ -34,27 +37,6 @@ jobs: with: fetch-depth: 2 - - name: Get HugeGraph stable commit id - id: get-commit - uses: actions/github-script@v7 - with: - script: | - const owner = 'apache'; - const repo = 'hugegraph'; - const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); - const { data: ref } = await github.rest.git.getRef({ - owner, repo, ref: `tags/${release.tag_name}` - }); - 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; - } - sha = sha.substring(0, 7); - core.exportVariable('COMMIT_ID', sha); - core.setOutput('commit_id', sha); - console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); - - name: Install JDK 11 uses: actions/setup-java@v3 with: diff --git a/hugegraph-client-go/api/v1/gremlin/gemlin.go b/hugegraph-client-go/api/v1/gremlin/gemlin.go index 9ec5d5754..a2c3112bf 100644 --- a/hugegraph-client-go/api/v1/gremlin/gemlin.go +++ b/hugegraph-client-go/api/v1/gremlin/gemlin.go @@ -83,13 +83,19 @@ type PostRequest struct { gremlin string bindings map[string]string language string - aliases map[string]string + aliases struct { + //Graph string `json:"graph"` + //G string `json:"g"` + } } type PostRequestData struct { Gremlin string `json:"gremlin"` Bindings map[string]string `json:"bindings,omitempty"` Language string `json:"language,omitempty"` - Aliases map[string]string `json:"aliases,omitempty"` + Aliases struct { + //Graph string `json:"graph"` + //G string `json:"g"` + } `json:"aliases,omitempty"` } type PostResponse struct { StatusCode int `json:"-"` @@ -126,23 +132,6 @@ func (g Post) WithGremlin(gremlin string) func(request *PostRequest) { } } -// buildDefaultAliases mirrors GremlinManager.java: aliases the requested -// graph name to the conventional traversal source so that scripts can use -// `g.V()` / `g.E()` against the active graph. -func buildDefaultAliases(transport api.Transport) map[string]string { - cfg := transport.GetConfig() - aliases := map[string]string{} - if cfg.GraphSpace != "" { - full := cfg.GraphSpace + "-" + cfg.Graph - aliases["graph"] = full - aliases["g"] = "__g_" + full - } else { - aliases["graph"] = cfg.Graph - aliases["g"] = "__g_" + cfg.Graph - } - return aliases -} - func (g GetRequest) Do(ctx context.Context, transport api.Transport) (*GetResponse, error) { url := "/gremlin" @@ -156,10 +145,7 @@ func (g GetRequest) Do(ctx context.Context, transport api.Transport) (*GetRespon params.Add("language", g.language) } - if g.aliases == nil { - g.aliases = buildDefaultAliases(transport) - } - if len(g.aliases) > 0 { + if g.aliases != nil && len(g.aliases) >= 0 { aliasesJsonStr, err := json.Marshal(g.aliases) if err != nil { return nil, err @@ -209,10 +195,6 @@ func (g PostRequest) Do(ctx context.Context, transport api.Transport) (*PostResp g.language = "gremlin-groovy" } - if g.aliases == nil { - g.aliases = buildDefaultAliases(transport) - } - gd := &PostRequestData{ Gremlin: g.gremlin, Bindings: g.bindings, diff --git a/hugegraph-client-go/api/v1/gremlin/gemlin_test.go b/hugegraph-client-go/api/v1/gremlin/gemlin_test.go index 64cb9b4e0..d880c8878 100644 --- a/hugegraph-client-go/api/v1/gremlin/gemlin_test.go +++ b/hugegraph-client-go/api/v1/gremlin/gemlin_test.go @@ -32,7 +32,7 @@ func TestGremlin(t *testing.T) { log.Println(err) } respGet, err := client.Gremlin.Get( - client.Gremlin.Get.WithGremlin("g.V().limit(3)"), + client.Gremlin.Get.WithGremlin("hugegraph.traversal().V().limit(3)"), ) if err != nil { log.Fatalln(err) @@ -42,7 +42,7 @@ func TestGremlin(t *testing.T) { } respPost, err := client.Gremlin.Post( - client.Gremlin.Post.WithGremlin("g.V().limit(3)"), + client.Gremlin.Post.WithGremlin("hugegraph.traversal().V().limit(3)"), ) if err != nil { log.Fatalln(err) From 77a10ac87595b42ee172325094c59c4a6e1789d4 Mon Sep 17 00:00:00 2001 From: Loki Date: Sat, 2 May 2026 14:30:35 +0800 Subject: [PATCH 6/9] fix test --- .github/workflows/client-go-ci.yml | 22 +++++++++++-- hugegraph-client-go/api/v1/gremlin/gemlin.go | 32 ++++++++++++++----- .../api/v1/gremlin/gemlin_test.go | 15 +++------ 3 files changed, 48 insertions(+), 21 deletions(-) diff --git a/.github/workflows/client-go-ci.yml b/.github/workflows/client-go-ci.yml index 45064073d..932c3c6cb 100644 --- a/.github/workflows/client-go-ci.yml +++ b/.github/workflows/client-go-ci.yml @@ -23,9 +23,6 @@ jobs: env: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-client/assembly/travis - # TODO: replace it with the (latest - n) commit id (n >= 15) - # FIXME: hugegraph commit date: 2025-10-30 - COMMIT_ID: 8c1ee71 # 5b3d295 strategy: fail-fast: false matrix: @@ -37,6 +34,25 @@ jobs: with: fetch-depth: 2 + - name: Get HugeGraph stable commit id + uses: actions/github-script@v7 + with: + script: | + const owner = 'apache'; + const repo = 'hugegraph'; + const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); + const { data: ref } = await github.rest.git.getRef({ + owner, repo, ref: `tags/${release.tag_name}` + }); + 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; + } + sha = sha.substring(0, 7); + core.exportVariable('COMMIT_ID', sha); + console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); + - name: Install JDK 11 uses: actions/setup-java@v3 with: diff --git a/hugegraph-client-go/api/v1/gremlin/gemlin.go b/hugegraph-client-go/api/v1/gremlin/gemlin.go index a2c3112bf..e4721fdbb 100644 --- a/hugegraph-client-go/api/v1/gremlin/gemlin.go +++ b/hugegraph-client-go/api/v1/gremlin/gemlin.go @@ -83,19 +83,13 @@ type PostRequest struct { gremlin string bindings map[string]string language string - aliases struct { - //Graph string `json:"graph"` - //G string `json:"g"` - } + aliases map[string]string } type PostRequestData struct { Gremlin string `json:"gremlin"` Bindings map[string]string `json:"bindings,omitempty"` Language string `json:"language,omitempty"` - Aliases struct { - //Graph string `json:"graph"` - //G string `json:"g"` - } `json:"aliases,omitempty"` + Aliases map[string]string `json:"aliases,omitempty"` } type PostResponse struct { StatusCode int `json:"-"` @@ -132,6 +126,24 @@ func (g Post) WithGremlin(gremlin string) func(request *PostRequest) { } } +// buildDefaultAliases mirrors GremlinManager.java for HugeGraph 1.7.0+: +// the server registers traversal sources as `__g_-` +// (graphSpace defaults to "DEFAULT", matching HugeClientBuilder.DEFAULT_GRAPHSPACE). +// Sending these aliases lets scripts use `g.V()` against the active graph +// regardless of how the server names its bindings internally. +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, + } +} + func (g GetRequest) Do(ctx context.Context, transport api.Transport) (*GetResponse, error) { url := "/gremlin" @@ -195,6 +207,10 @@ func (g PostRequest) Do(ctx context.Context, transport api.Transport) (*PostResp g.language = "gremlin-groovy" } + if g.aliases == nil { + g.aliases = buildDefaultAliases(transport) + } + gd := &PostRequestData{ Gremlin: g.gremlin, Bindings: g.bindings, diff --git a/hugegraph-client-go/api/v1/gremlin/gemlin_test.go b/hugegraph-client-go/api/v1/gremlin/gemlin_test.go index d880c8878..5e3cd3b6d 100644 --- a/hugegraph-client-go/api/v1/gremlin/gemlin_test.go +++ b/hugegraph-client-go/api/v1/gremlin/gemlin_test.go @@ -31,22 +31,17 @@ func TestGremlin(t *testing.T) { if err != nil { log.Println(err) } - respGet, err := client.Gremlin.Get( - client.Gremlin.Get.WithGremlin("hugegraph.traversal().V().limit(3)"), - ) - if err != nil { - log.Fatalln(err) - } - if respGet.StatusCode != 200 { - t.Error("client.Gremlin.GremlinGet error ") - } respPost, err := client.Gremlin.Post( - client.Gremlin.Post.WithGremlin("hugegraph.traversal().V().limit(3)"), + client.Gremlin.Post.WithGremlin("g.V().limit(3)"), ) if err != nil { log.Fatalln(err) } + if respPost.StatusCode != 200 { + t.Errorf("client.Gremlin.Post status=%d, message=%s", + respPost.StatusCode, respPost.Data.Message) + } fmt.Println(respPost.Data.Result.Data) } From e3146a1b4f333ba68c671259d43a03a19247065a Mon Sep 17 00:00:00 2001 From: Loki Date: Tue, 5 May 2026 13:35:26 +0800 Subject: [PATCH 7/9] optimize: adopt copilot advice --- .github/workflows/client-ci.yml | 1 - .github/workflows/client-go-ci.yml | 1 - .github/workflows/hubble-ci.yml | 1 - .github/workflows/loader-ci.yml | 1 - .github/workflows/spark-connector-ci.yml | 1 - .github/workflows/tools-ci.yml | 1 - hugegraph-client-go/api/v1/gremlin/gemlin.go | 5 ----- hugegraph-client-go/api/v1/gremlin/gemlin_test.go | 4 ++-- hugegraph-client-go/hugegraph.go | 11 ++++++----- 9 files changed, 8 insertions(+), 18 deletions(-) diff --git a/.github/workflows/client-ci.yml b/.github/workflows/client-ci.yml index 2d4f959b1..949a0ca0d 100644 --- a/.github/workflows/client-ci.yml +++ b/.github/workflows/client-ci.yml @@ -52,7 +52,6 @@ jobs: const { data: tag } = await github.rest.git.getTag({ owner, repo, tag_sha: sha }); sha = tag.object.sha; } - sha = sha.substring(0, 7); core.exportVariable('COMMIT_ID', sha); core.setOutput('commit_id', sha); console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); diff --git a/.github/workflows/client-go-ci.yml b/.github/workflows/client-go-ci.yml index 932c3c6cb..8ccc6f88a 100644 --- a/.github/workflows/client-go-ci.yml +++ b/.github/workflows/client-go-ci.yml @@ -49,7 +49,6 @@ jobs: const { data: tag } = await github.rest.git.getTag({ owner, repo, tag_sha: sha }); sha = tag.object.sha; } - sha = sha.substring(0, 7); core.exportVariable('COMMIT_ID', sha); console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); diff --git a/.github/workflows/hubble-ci.yml b/.github/workflows/hubble-ci.yml index 7022ed3ed..325891440 100644 --- a/.github/workflows/hubble-ci.yml +++ b/.github/workflows/hubble-ci.yml @@ -57,7 +57,6 @@ jobs: const { data: tag } = await github.rest.git.getTag({ owner, repo, tag_sha: sha }); sha = tag.object.sha; } - sha = sha.substring(0, 7); core.exportVariable('COMMIT_ID', sha); core.setOutput('commit_id', sha); console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml index b0fe7b294..1efb14cc8 100644 --- a/.github/workflows/loader-ci.yml +++ b/.github/workflows/loader-ci.yml @@ -63,7 +63,6 @@ jobs: const { data: tag } = await github.rest.git.getTag({ owner, repo, tag_sha: sha }); sha = tag.object.sha; } - sha = sha.substring(0, 7); core.exportVariable('COMMIT_ID', sha); core.setOutput('commit_id', sha); console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); diff --git a/.github/workflows/spark-connector-ci.yml b/.github/workflows/spark-connector-ci.yml index b307a1f54..c903ea86f 100644 --- a/.github/workflows/spark-connector-ci.yml +++ b/.github/workflows/spark-connector-ci.yml @@ -51,7 +51,6 @@ jobs: const { data: tag } = await github.rest.git.getTag({ owner, repo, tag_sha: sha }); sha = tag.object.sha; } - sha = sha.substring(0, 7); core.exportVariable('COMMIT_ID', sha); core.setOutput('commit_id', sha); console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); diff --git a/.github/workflows/tools-ci.yml b/.github/workflows/tools-ci.yml index bdd41772f..c903c520d 100644 --- a/.github/workflows/tools-ci.yml +++ b/.github/workflows/tools-ci.yml @@ -51,7 +51,6 @@ jobs: const { data: tag } = await github.rest.git.getTag({ owner, repo, tag_sha: sha }); sha = tag.object.sha; } - sha = sha.substring(0, 7); core.exportVariable('COMMIT_ID', sha); core.setOutput('commit_id', sha); console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); diff --git a/hugegraph-client-go/api/v1/gremlin/gemlin.go b/hugegraph-client-go/api/v1/gremlin/gemlin.go index e4721fdbb..fc23d6e33 100644 --- a/hugegraph-client-go/api/v1/gremlin/gemlin.go +++ b/hugegraph-client-go/api/v1/gremlin/gemlin.go @@ -126,11 +126,6 @@ func (g Post) WithGremlin(gremlin string) func(request *PostRequest) { } } -// buildDefaultAliases mirrors GremlinManager.java for HugeGraph 1.7.0+: -// the server registers traversal sources as `__g_-` -// (graphSpace defaults to "DEFAULT", matching HugeClientBuilder.DEFAULT_GRAPHSPACE). -// Sending these aliases lets scripts use `g.V()` against the active graph -// regardless of how the server names its bindings internally. func buildDefaultAliases(transport api.Transport) map[string]string { cfg := transport.GetConfig() graphSpace := cfg.GraphSpace diff --git a/hugegraph-client-go/api/v1/gremlin/gemlin_test.go b/hugegraph-client-go/api/v1/gremlin/gemlin_test.go index 5e3cd3b6d..93bccf254 100644 --- a/hugegraph-client-go/api/v1/gremlin/gemlin_test.go +++ b/hugegraph-client-go/api/v1/gremlin/gemlin_test.go @@ -39,8 +39,8 @@ func TestGremlin(t *testing.T) { log.Fatalln(err) } if respPost.StatusCode != 200 { - t.Errorf("client.Gremlin.Post status=%d, message=%s", - respPost.StatusCode, respPost.Data.Message) + t.Errorf("client.Gremlin.Post http_status=%d, gremlin_status=%d, message=%s", + respPost.StatusCode, respPost.Data.Status.Code, respPost.Data.Status.Message) } fmt.Println(respPost.Data.Result.Data) diff --git a/hugegraph-client-go/hugegraph.go b/hugegraph-client-go/hugegraph.go index 5e5a5f305..a1797842c 100644 --- a/hugegraph-client-go/hugegraph.go +++ b/hugegraph-client-go/hugegraph.go @@ -92,11 +92,12 @@ func NewCommonClient(cfg Config) (*CommonClient, error) { Host: fmt.Sprintf("%s:%d", cfg.Host, cfg.Port), Scheme: "http", }, - Username: cfg.Username, - Password: cfg.Password, - Graph: cfg.Graph, - Transport: cfg.Transport, - Logger: cfg.Logger, + Username: cfg.Username, + Password: cfg.Password, + GraphSpace: cfg.GraphSpace, + Graph: cfg.Graph, + Transport: cfg.Transport, + Logger: cfg.Logger, }) return &CommonClient{ From aa29128ffe8a265c4abfb81f7947381362ade8f9 Mon Sep 17 00:00:00 2001 From: Loki Date: Wed, 6 May 2026 20:58:04 +0800 Subject: [PATCH 8/9] refactor the common usage --- .../actions/get-hugegraph-commit/action.yml | 30 ++++++++++ .../actions/setup-hugegraph-server/action.yml | 18 ++++++ .github/actions/setup-java-env/action.yml | 40 +++++++++++++ .github/actions/upload-coverage/action.yml | 20 +++++++ .github/workflows/client-ci.yml | 57 ++++--------------- .github/workflows/client-go-ci.yml | 49 +++++----------- .github/workflows/hubble-ci.yml | 41 ++----------- .github/workflows/loader-ci.yml | 38 ++----------- .github/workflows/spark-connector-ci.yml | 46 ++++----------- .github/workflows/tools-ci.yml | 47 ++++----------- 10 files changed, 162 insertions(+), 224 deletions(-) create mode 100644 .github/actions/get-hugegraph-commit/action.yml create mode 100644 .github/actions/setup-hugegraph-server/action.yml create mode 100644 .github/actions/setup-java-env/action.yml create mode 100644 .github/actions/upload-coverage/action.yml diff --git a/.github/actions/get-hugegraph-commit/action.yml b/.github/actions/get-hugegraph-commit/action.yml new file mode 100644 index 000000000..4a19dc65a --- /dev/null +++ b/.github/actions/get-hugegraph-commit/action.yml @@ -0,0 +1,30 @@ +name: 'Get HugeGraph stable commit id' +description: 'Fetch the latest HugeGraph release commit SHA and expose it as output and env variable' + +outputs: + commit_id: + description: 'The commit SHA of the latest HugeGraph release' + value: ${{ steps.get-commit.outputs.commit_id }} + +runs: + using: composite + steps: + - name: Get HugeGraph stable commit id + id: get-commit + uses: actions/github-script@v7 + with: + script: | + const owner = 'apache'; + const repo = 'hugegraph'; + const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); + const { data: ref } = await github.rest.git.getRef({ + owner, repo, ref: `tags/${release.tag_name}` + }); + 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})`); diff --git a/.github/actions/setup-hugegraph-server/action.yml b/.github/actions/setup-hugegraph-server/action.yml new file mode 100644 index 000000000..ff142ed1a --- /dev/null +++ b/.github/actions/setup-hugegraph-server/action.yml @@ -0,0 +1,18 @@ +name: 'Setup HugeGraph Server' +description: 'Prepare environment and install HugeGraph server from source' + +inputs: + travis-dir: + description: 'Path to the Travis assembly directory containing install scripts' + required: true + commit-id: + description: 'HugeGraph commit SHA to install' + required: true + +runs: + using: composite + steps: + - name: Prepare env and service + shell: bash + run: | + ${{ inputs.travis-dir }}/install-hugegraph-from-source.sh ${{ inputs.commit-id }} diff --git a/.github/actions/setup-java-env/action.yml b/.github/actions/setup-java-env/action.yml new file mode 100644 index 000000000..ffc0e92f1 --- /dev/null +++ b/.github/actions/setup-java-env/action.yml @@ -0,0 +1,40 @@ +name: 'Setup Java and Maven Environment' +description: 'Install JDK, cache Maven packages, and optionally apply staged Maven repository settings' + +inputs: + java-version: + description: 'Java version to install' + required: false + default: '11' + distribution: + description: 'JDK distribution' + required: false + default: 'zulu' + use-stage: + description: 'Whether to apply staged Maven repository settings' + required: false + default: 'true' + +runs: + using: composite + steps: + - name: Install JDK ${{ inputs.java-version }} + uses: actions/setup-java@v4 + with: + java-version: ${{ inputs.java-version }} + distribution: ${{ inputs.distribution }} + cache: 'maven' + + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-maven- + + - name: Use staged maven repo settings + if: ${{ inputs.use-stage == 'true' }} + shell: bash + run: | + cp $HOME/.m2/settings.xml /tmp/settings.xml + mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml diff --git a/.github/actions/upload-coverage/action.yml b/.github/actions/upload-coverage/action.yml new file mode 100644 index 000000000..7b07b84f2 --- /dev/null +++ b/.github/actions/upload-coverage/action.yml @@ -0,0 +1,20 @@ +name: 'Upload Coverage to Codecov' +description: 'Upload test coverage report to Codecov' + +inputs: + token: + description: 'Codecov upload token' + required: true + file: + description: 'Path to the coverage report file' + required: false + default: 'target/jacoco.xml' + +runs: + using: composite + steps: + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ inputs.token }} + file: ${{ inputs.file }} diff --git a/.github/workflows/client-ci.yml b/.github/workflows/client-ci.yml index 949a0ca0d..9ed4e723f 100644 --- a/.github/workflows/client-ci.yml +++ b/.github/workflows/client-ci.yml @@ -38,57 +38,20 @@ jobs: - name: Get HugeGraph stable commit id id: get-commit - uses: actions/github-script@v7 - with: - script: | - const owner = 'apache'; - const repo = 'hugegraph'; - const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); - const { data: ref } = await github.rest.git.getRef({ - owner, repo, ref: `tags/${release.tag_name}` - }); - 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})`); - - # TODO: do we need it? (need test) - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-maven- - - - name: Install JDK 11 for graph server - uses: actions/setup-java@v4 - with: - java-version: '11' - distribution: 'zulu' - cache: 'maven' - - - name: Prepare env and service - run: | - # TODO(@Thespica): test both servers of supporting gs and not supporting gs - # when the server supports gs - $TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID + uses: ./.github/actions/get-hugegraph-commit - - name: Install Java ${{ matrix.JAVA_VERSION }} for client - uses: actions/setup-java@v4 + - name: Setup Java environment + uses: ./.github/actions/setup-java-env with: java-version: ${{ matrix.JAVA_VERSION }} distribution: 'zulu' - cache: 'maven' + use-stage: ${{ env.USE_STAGE }} - - name: Use staged maven repo - if: ${{ env.USE_STAGE == 'true' }} - run: | - cp $HOME/.m2/settings.xml /tmp/settings.xml - mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml + - name: Setup HugeGraph server + uses: ./.github/actions/setup-hugegraph-server + with: + travis-dir: ${{ env.TRAVIS_DIR }} + commit-id: ${{ steps.get-commit.outputs.commit_id }} - name: Compile run: | @@ -102,7 +65,7 @@ jobs: mvn test -Dtest=FuncTestSuite - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: ./.github/actions/upload-coverage with: token: ${{ secrets.CODECOV_TOKEN }} file: target/jacoco.xml diff --git a/.github/workflows/client-go-ci.yml b/.github/workflows/client-go-ci.yml index 8ccc6f88a..9c14711e9 100644 --- a/.github/workflows/client-go-ci.yml +++ b/.github/workflows/client-go-ci.yml @@ -35,53 +35,30 @@ jobs: fetch-depth: 2 - name: Get HugeGraph stable commit id - uses: actions/github-script@v7 - with: - script: | - const owner = 'apache'; - const repo = 'hugegraph'; - const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); - const { data: ref } = await github.rest.git.getRef({ - owner, repo, ref: `tags/${release.tag_name}` - }); - 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); - console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); + id: get-commit + uses: ./.github/actions/get-hugegraph-commit - - name: Install JDK 11 - uses: actions/setup-java@v3 + - name: Setup Java environment + uses: ./.github/actions/setup-java-env with: java-version: ${{ matrix.JAVA_VERSION }} distribution: 'zulu' + use-stage: ${{ env.USE_STAGE }} - - name: Cache Maven packages - uses: actions/cache@v3 + - name: Setup HugeGraph server + uses: ./.github/actions/setup-hugegraph-server with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: Use staged maven repo - if: ${{ env.USE_STAGE == 'true' }} - run: | - cp $HOME/.m2/settings.xml /tmp/settings.xml - mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml - - - name: Prepare env and service - run: | - $TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID + travis-dir: ${{ env.TRAVIS_DIR }} + commit-id: ${{ steps.get-commit.outputs.commit_id }} - name: Init Go env - uses: actions/setup-go@v2.1.3 - with: {go-version: '1.x'} + uses: actions/setup-go@v5 + with: + go-version: '1.x' - name: Go test run: | - go version + go version sudo swapoff -a sudo sysctl -w vm.swappiness=1 sudo sysctl -w fs.file-max=262144 diff --git a/.github/workflows/hubble-ci.yml b/.github/workflows/hubble-ci.yml index 325891440..7282c2b07 100644 --- a/.github/workflows/hubble-ci.yml +++ b/.github/workflows/hubble-ci.yml @@ -43,29 +43,14 @@ jobs: - name: Get HugeGraph stable commit id id: get-commit - uses: actions/github-script@v7 - with: - script: | - const owner = 'apache'; - const repo = 'hugegraph'; - const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); - const { data: ref } = await github.rest.git.getRef({ - owner, repo, ref: `tags/${release.tag_name}` - }); - 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})`); + uses: ./.github/actions/get-hugegraph-commit - - name: Install JDK 11 - uses: actions/setup-java@v3 + - name: Setup Java environment + uses: ./.github/actions/setup-java-env with: java-version: ${{ matrix.JAVA_VERSION }} distribution: 'adopt' + use-stage: ${{ env.USE_STAGE }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 @@ -73,21 +58,6 @@ jobs: python-version: ${{ matrix.python-version }} cache: 'pip' - # we also should cache python & yarn & downloads to avoid useless work - - name: Cache Maven packages - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: use staged maven repo settings - if: ${{ env.USE_STAGE == 'true' }} - run: | - cp $HOME/.m2/settings.xml /tmp/settings.xml - mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml - - name: Compile run: | mvn install -pl hugegraph-client,hugegraph-loader -am -Dmaven.javadoc.skip=true -DskipTests -ntp @@ -96,7 +66,6 @@ jobs: - name: Prepare env and service run: | - python -m pip install -r ${TRAVIS_DIR}/requirements.txt cd hugegraph-hubble mvn package -Dmaven.test.skip=true @@ -119,7 +88,7 @@ jobs: hubble-dist/assembly/travis/run-api-test.sh - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: ./.github/actions/upload-coverage with: token: ${{ secrets.CODECOV_TOKEN }} file: target/site/jacoco/*.xml diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml index 1efb14cc8..dbda9ac2e 100644 --- a/.github/workflows/loader-ci.yml +++ b/.github/workflows/loader-ci.yml @@ -49,36 +49,14 @@ jobs: - name: Get HugeGraph stable commit id id: get-commit - uses: actions/github-script@v7 - with: - script: | - const owner = 'apache'; - const repo = 'hugegraph'; - const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); - const { data: ref } = await github.rest.git.getRef({ - owner, repo, ref: `tags/${release.tag_name}` - }); - 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})`); + uses: ./.github/actions/get-hugegraph-commit - - name: Install JDK 11 - uses: actions/setup-java@v4 + - name: Setup Java environment + uses: ./.github/actions/setup-java-env with: java-version: ${{ matrix.JAVA_VERSION }} distribution: 'adopt' - - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 + use-stage: ${{ env.USE_STAGE }} - name: Cache Hadoop uses: actions/cache@v4 @@ -92,12 +70,6 @@ jobs: path: ~/hugegraph-cache-${{ steps.get-commit.outputs.commit_id }} key: ${{ runner.os }}-hugegraph-server-${{ steps.get-commit.outputs.commit_id }} - - name: use staged maven repo settings - if: ${{ env.USE_STAGE == 'true' }} - run: | - cp $HOME/.m2/settings.xml /tmp/settings.xml - mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml - - name: Compile run: | mvn install -pl hugegraph-client,hugegraph-loader -am -Dmaven.javadoc.skip=true -DskipTests -ntp @@ -117,7 +89,7 @@ jobs: mvn test -P kafka - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 + uses: ./.github/actions/upload-coverage with: token: ${{ secrets.CODECOV_TOKEN }} file: target/jacoco.xml diff --git a/.github/workflows/spark-connector-ci.yml b/.github/workflows/spark-connector-ci.yml index c903ea86f..b61b56e2f 100644 --- a/.github/workflows/spark-connector-ci.yml +++ b/.github/workflows/spark-connector-ci.yml @@ -37,50 +37,24 @@ jobs: - name: Get HugeGraph stable commit id id: get-commit - uses: actions/github-script@v7 - with: - script: | - const owner = 'apache'; - const repo = 'hugegraph'; - const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); - const { data: ref } = await github.rest.git.getRef({ - owner, repo, ref: `tags/${release.tag_name}` - }); - 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})`); + uses: ./.github/actions/get-hugegraph-commit - - name: Install JDK 11 - uses: actions/setup-java@v4 + - name: Setup Java environment + uses: ./.github/actions/setup-java-env with: - java-version: '11' + java-version: ${{ matrix.JAVA_VERSION }} distribution: 'adopt' - - - name: Cache Maven packages - uses: actions/cache@v3 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: use staged maven repo settings - if: ${{ env.USE_STAGE == 'true' }} - run: | - cp $HOME/.m2/settings.xml /tmp/settings.xml - mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml + use-stage: ${{ env.USE_STAGE }} - name: Compile run: | mvn install -pl hugegraph-client,hugegraph-spark-connector -am -Dmaven.javadoc.skip=true -DskipTests -ntp - - name: Prepare env and service - run: | - $TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID + - name: Setup HugeGraph server + uses: ./.github/actions/setup-hugegraph-server + with: + travis-dir: ${{ env.TRAVIS_DIR }} + commit-id: ${{ steps.get-commit.outputs.commit_id }} - name: Run test run: | diff --git a/.github/workflows/tools-ci.yml b/.github/workflows/tools-ci.yml index c903c520d..dda37f3e3 100644 --- a/.github/workflows/tools-ci.yml +++ b/.github/workflows/tools-ci.yml @@ -1,4 +1,5 @@ name: "tools-ci" + on: workflow_dispatch: push: @@ -24,7 +25,6 @@ jobs: env: USE_STAGE: 'true' # Whether to include the stage repository. TRAVIS_DIR: hugegraph-tools/assembly/travis - # TODO: could we use one param to unify it? or use a action template (could use one ci file) strategy: matrix: JAVA_VERSION: [ '11' ] @@ -37,56 +37,31 @@ jobs: - name: Get HugeGraph stable commit id id: get-commit - uses: actions/github-script@v7 - with: - script: | - const owner = 'apache'; - const repo = 'hugegraph'; - const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); - const { data: ref } = await github.rest.git.getRef({ - owner, repo, ref: `tags/${release.tag_name}` - }); - 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})`); + uses: ./.github/actions/get-hugegraph-commit - - name: Install JDK 11 - uses: actions/setup-java@v3 + - name: Setup Java environment + uses: ./.github/actions/setup-java-env with: java-version: ${{ matrix.JAVA_VERSION }} distribution: 'adopt' - - name: Cache Maven packages - uses: actions/cache@v3 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: use staged maven repo settings - if: ${{ env.USE_STAGE == 'true' }} - run: | - cp $HOME/.m2/settings.xml /tmp/settings.xml - mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml + use-stage: ${{ env.USE_STAGE }} - name: Compile run: | mvn install -pl hugegraph-client,hugegraph-tools -am -Dmaven.javadoc.skip=true -DskipTests -ntp - - name: Prepare env and service - run: | - $TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID + - name: Setup HugeGraph server + uses: ./.github/actions/setup-hugegraph-server + with: + travis-dir: ${{ env.TRAVIS_DIR }} + commit-id: ${{ steps.get-commit.outputs.commit_id }} - name: Run test run: | mvn test -Dtest=FuncTestSuite -pl hugegraph-tools -ntp - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: ./.github/actions/upload-coverage with: token: ${{ secrets.CODECOV_TOKEN }} file: target/jacoco.xml From 08714060238b7c9f99a92db19c3529def3370803 Mon Sep 17 00:00:00 2001 From: Loki Date: Fri, 8 May 2026 21:27:28 +0800 Subject: [PATCH 9/9] optimize the commitid exactly --- .../actions/get-hugegraph-commit/action.yml | 29 ++++++++++++------- .github/actions/setup-java-env/action.yml | 7 ----- .github/workflows/hubble-ci.yml | 2 ++ .github/workflows/loader-ci.yml | 2 ++ hugegraph-client-go/api/v1/gremlin/gemlin.go | 3 ++ .../api/v1/gremlin/gemlin_test.go | 4 +-- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.github/actions/get-hugegraph-commit/action.yml b/.github/actions/get-hugegraph-commit/action.yml index 4a19dc65a..f6cf438d7 100644 --- a/.github/actions/get-hugegraph-commit/action.yml +++ b/.github/actions/get-hugegraph-commit/action.yml @@ -16,15 +16,22 @@ runs: script: | const owner = 'apache'; const repo = 'hugegraph'; - const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); - const { data: ref } = await github.rest.git.getRef({ - owner, repo, ref: `tags/${release.tag_name}` - }); - 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; + try { + const { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }); + const tagName = release.tag_name; + const { data: ref } = await github.rest.git.getRef({ + owner, repo, ref: `tags/${tagName}` + }); + 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; + } else if (ref.object.type !== 'commit') { + throw new Error(`Unexpected ref type: ${ref.object.type}`); + } + core.exportVariable('COMMIT_ID', sha); + core.setOutput('commit_id', sha); + console.log(`Using HugeGraph release ${tagName} (${sha})`); + } catch (error) { + core.setFailed(`Failed to get HugeGraph commit: ${error.message}`); } - core.exportVariable('COMMIT_ID', sha); - core.setOutput('commit_id', sha); - console.log(`Using HugeGraph release ${release.tag_name} (${sha})`); diff --git a/.github/actions/setup-java-env/action.yml b/.github/actions/setup-java-env/action.yml index ffc0e92f1..18b136123 100644 --- a/.github/actions/setup-java-env/action.yml +++ b/.github/actions/setup-java-env/action.yml @@ -25,13 +25,6 @@ runs: distribution: ${{ inputs.distribution }} cache: 'maven' - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-maven- - - name: Use staged maven repo settings if: ${{ inputs.use-stage == 'true' }} shell: bash diff --git a/.github/workflows/hubble-ci.yml b/.github/workflows/hubble-ci.yml index 7282c2b07..2b09e74ff 100644 --- a/.github/workflows/hubble-ci.yml +++ b/.github/workflows/hubble-ci.yml @@ -65,6 +65,8 @@ jobs: mvn -e compile -Dmaven.javadoc.skip=true -ntp - name: Prepare env and service + env: + COMMIT_ID: ${{ steps.get-commit.outputs.commit_id }} run: | python -m pip install -r ${TRAVIS_DIR}/requirements.txt cd hugegraph-hubble diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml index dbda9ac2e..a7b085ab3 100644 --- a/.github/workflows/loader-ci.yml +++ b/.github/workflows/loader-ci.yml @@ -75,6 +75,8 @@ jobs: mvn install -pl hugegraph-client,hugegraph-loader -am -Dmaven.javadoc.skip=true -DskipTests -ntp - 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 diff --git a/hugegraph-client-go/api/v1/gremlin/gemlin.go b/hugegraph-client-go/api/v1/gremlin/gemlin.go index fc23d6e33..c6ddd04e2 100644 --- a/hugegraph-client-go/api/v1/gremlin/gemlin.go +++ b/hugegraph-client-go/api/v1/gremlin/gemlin.go @@ -132,6 +132,9 @@ func buildDefaultAliases(transport api.Transport) map[string]string { if graphSpace == "" { graphSpace = "DEFAULT" } + if cfg.Graph == "" { + cfg.Graph = "hugegraph" + } full := graphSpace + "-" + cfg.Graph return map[string]string{ "graph": full, diff --git a/hugegraph-client-go/api/v1/gremlin/gemlin_test.go b/hugegraph-client-go/api/v1/gremlin/gemlin_test.go index 93bccf254..5ab2d8ab6 100644 --- a/hugegraph-client-go/api/v1/gremlin/gemlin_test.go +++ b/hugegraph-client-go/api/v1/gremlin/gemlin_test.go @@ -39,8 +39,8 @@ func TestGremlin(t *testing.T) { log.Fatalln(err) } if respPost.StatusCode != 200 { - t.Errorf("client.Gremlin.Post http_status=%d, gremlin_status=%d, message=%s", - respPost.StatusCode, respPost.Data.Status.Code, respPost.Data.Status.Message) + t.Errorf("client.Gremlin.Post http_status=%d, gremlin_status=%d, message=%s", + respPost.StatusCode, respPost.Data.Status.Code, respPost.Data.Status.Message) } fmt.Println(respPost.Data.Result.Data)