bitflicker64 commented on code in PR #386:
URL: https://github.com/apache/hugegraph-ai/pull/386#discussion_r4397883424
##########
scripts/apache-release.sh:
##########
@@ -24,30 +24,48 @@ set -eo pipefail
GROUP="hugegraph"
# current repository name
REPO="${GROUP}-ai"
-# release version (input by committer)
-RELEASE_VERSION=$1
-USERNAME=$2
-PASSWORD=$3
+# Python 3.11+; preserve the existing version/username/password argument order.
+SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
+RELEASE_PYTHON="${PYTHON_FOR_RELEASE:-python3}"
+"${RELEASE_PYTHON}" "${SCRIPT_DIR}/version.py" check
+ROOT_VERSION=$("${RELEASE_PYTHON}" "${SCRIPT_DIR}/version.py" get version)
+RELEASE_VERSION=${1:-${ROOT_VERSION}}
+USERNAME=${2:-}
+PASSWORD=${3:-}
+if [ "${RELEASE_VERSION}" != "${ROOT_VERSION}" ]; then
+ echo "Release version must match root pyproject.toml (${ROOT_VERSION})" >&2
+ exit 1
+fi
# git release branch (check it carefully)
GIT_BRANCH="release-${RELEASE_VERSION}"
-RELEASE_VERSION=${RELEASE_VERSION:?"Please input the release version behind
script"}
-
WORK_DIR=$(
cd "$(dirname "$0")"
pwd
)
cd "${WORK_DIR}"
echo "In the work dir: $(pwd)"
+# Validate the exact commit that will be distributed, not just this checkout.
+RELEASE_COMMIT=$(git rev-parse --verify "${GIT_BRANCH}^{commit}")
+SNAPSHOT_DIR=$(mktemp -d)
+trap 'rm -rf "${SNAPSHOT_DIR}"' EXIT
+git -C "${SCRIPT_DIR}/.." archive --format=tar "${RELEASE_COMMIT}" | tar -xf -
-C "${SNAPSHOT_DIR}"
Review Comment:
Important: `git archive` applies the `export-ignore` rules in
`.gitattributes`, so the snapshot lacks `hugegraph-ml/pyproject.toml` and
`docker/charts/...`, and `version.py check --root` exits 1 with
`FileNotFoundError` on every real release run. The unit test passes only
because its fixture has no `.gitattributes`. Extract the full tree instead (for
example `git worktree add --detach "$SNAPSHOT_DIR" "$RELEASE_COMMIT"`) and copy
`.gitattributes` into the `test_version.py` fixture.
##########
.github/workflows/hugegraph-python-client.yml:
##########
@@ -1,148 +1,112 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
name: HG-Python-Client CI
on:
- push:
- branches:
- - 'main'
- - 'release-*'
- pull_request:
-
-concurrency:
- group: ${{ github.workflow }}-${{ github.event_name }}-${{
github.event.pull_request.number || github.run_id }}
- cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+ workflow_call:
+ inputs:
+ python-versions:
+ type: string
+ required: true
+ integration-python:
+ type: string
+ required: true
+ uv-version:
+ type: string
+ required: true
+ server-image:
+ type: string
+ required: true
+ version:
+ type: string
+ required: true
permissions:
contents: read
-env:
- UV_VERSION: "0.9.22"
-
jobs:
- client-unit-contract:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- matrix:
- python-version: ["3.10", "3.11"]
-
- steps:
- - uses: actions/checkout@v6
- with:
- persist-credentials: false
-
- - name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v6
- with:
- python-version: ${{ matrix.python-version }}
-
- - name: Install uv
- run: |
- curl -LsSf "https://astral.sh/uv/${UV_VERSION}/install.sh" | sh
- echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- "$HOME/.local/bin/uv" --version
-
- - name: Cache dependencies
- id: cache-deps
- uses: actions/cache@v5
- with:
- path: |
- ~/.cache/uv
- key: ${{ runner.os }}-uv-${{ matrix.python-version }}-${{
hashFiles('**/pyproject.toml', 'uv.lock') }}
- restore-keys: |
- ${{ runner.os }}-uv-${{ matrix.python-version }}-
-
- - name: Install dependencies with uv sync
- run: |
- uv sync --extra python-client --extra dev
-
- - name: Verify source archive build and installation
- run: |
- archive_dir=$(mktemp -d)
- git archive HEAD | tar -x -C "$archive_dir"
- uv build --all-packages "$archive_dir" --out-dir "$archive_dir/dist"
- uv sync --project "$archive_dir" --all-packages
- uv pip check --python "$archive_dir/.venv/bin/python"
-
- - name: Run unit and contract tests
- run: |
- uv run pytest hugegraph-python-client/src/tests -m "unit or
contract" --cov=pyhugegraph --cov-fail-under=45 --cov-report=term
--cov-report=xml:client-unit-contract.xml -v --tb=short --durations=20
-
- - name: Upload coverage artifact
- uses: actions/upload-artifact@v7
- with:
- name: client-unit-contract-coverage-${{ matrix.python-version }}
- path: client-unit-contract.xml
- if-no-files-found: error
-
- client-hugegraph-integration:
+ tests:
+ name: client / Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
+ timeout-minutes: 30
strategy:
fail-fast: false
matrix:
- python-version: ["3.10", "3.11"]
- server-version: ["1.7.0", "latest"]
-
+ python-version: ${{ fromJSON(inputs.python-versions) }}
services:
hugegraph:
- image: hugegraph/hugegraph:${{ matrix.server-version }}
+ image: ${{ matrix.python-version == inputs.integration-python &&
inputs.server-image || '' }}
env:
PASSWORD: admin
- options: --health-cmd="curl -f http://localhost:8080/versions || exit
1" --health-interval=10s --health-timeout=5s --health-retries=8
+ options: >-
+ --health-cmd="curl -f http://localhost:8080/versions || exit 1"
+ --health-interval=10s --health-timeout=5s --health-retries=12
--health-start-period=90s
ports:
- 8080:8080
-
+ env:
+ HUGEGRAPH_URL: http://127.0.0.1:8080
+ HUGEGRAPH_GRAPH: hugegraph
+ HUGEGRAPH_USER: admin
+ HUGEGRAPH_PASSWORD: admin
+ HUGEGRAPH_REQUIRED: 'true'
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
-
- - name: Record HugeGraph baseline
- env:
- HUGEGRAPH_CONTAINER: ${{ job.services.hugegraph.id }}
- run: |
- docker inspect --format='Image: {{.Config.Image}}; ID: {{.Image}}'
"$HUGEGRAPH_CONTAINER"
- curl --fail --silent --show-error http://127.0.0.1:8080/versions |
jq -e '.versions | {core, gremlin, api}'
-
- - name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v6
+ - uses: ./.github/actions/setup-python-env
+ id: python-env
with:
python-version: ${{ matrix.python-version }}
-
- - name: Install uv
- run: |
- curl -LsSf "https://astral.sh/uv/${UV_VERSION}/install.sh" | sh
- echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- "$HOME/.local/bin/uv" --version
-
- - name: Cache dependencies
- id: cache-deps
- uses: actions/cache@v5
- with:
- path: |
- ~/.cache/uv
- key: ${{ runner.os }}-uv-${{ matrix.python-version }}-${{
hashFiles('**/pyproject.toml', 'uv.lock') }}
- restore-keys: |
- ${{ runner.os }}-uv-${{ matrix.python-version }}-
-
- - name: Install dependencies with uv sync
- run: |
- uv sync --extra python-client --extra dev
-
- - name: Run HugeGraph integration tests
+ uv-version: ${{ inputs.uv-version }}
+ component: client
+ - name: Install client and test dependencies
+ run: uv sync --extra python-client --extra dev
Review Comment:
Important: this rewrite drops the `Verify source archive build and
installation` step from #381, so no CI job checks that the `git archive` source
release still builds and resolves without the export-ignored `hugegraph-ml/`.
Restore that step on the `integration-python` leg of this job.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]