This is an automated email from the ASF dual-hosted git repository.

zhaocong pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-ai.git


The following commit(s) were added to refs/heads/main by this push:
     new 0a33550  refactor: use uv for the CI action (#175)
0a33550 is described below

commit 0a335508b0c22c45849a6d8895baf1d8e941e015
Author: imbajin <[email protected]>
AuthorDate: Mon Feb 24 18:27:17 2025 +0800

    refactor: use uv for the CI action (#175)
    
    * refactor: use uv for the CI action
    
    * Update pylint.yml
    
    * refactor client
    
    * Update hugegraph-python-client.yml
    
    * Update hugegraph-python-client.yml
    
    * Update hugegraph-python-client.yml
    
    * Update hugegraph-python-client.yml
    
    * Update hugegraph-python-client.yml
    
    * Update hugegraph-python-client.yml
    
    * Update hugegraph-python-client.yml
    
    * Update hugegraph-python-client.yml
    
    * Update hugegraph-python-client.yml
    
    * Update hugegraph-python-client.yml
    
    * Update hugegraph-python-client.yml
    
    * Update hugegraph-python-client.yml
---
 .github/workflows/hugegraph-python-client.yml | 46 +++++++++++++++++++++------
 .github/workflows/pylint.yml                  | 36 ++++++++++++++++++---
 2 files changed, 68 insertions(+), 14 deletions(-)

diff --git a/.github/workflows/hugegraph-python-client.yml 
b/.github/workflows/hugegraph-python-client.yml
index f29a9cf..c545bc8 100644
--- a/.github/workflows/hugegraph-python-client.yml
+++ b/.github/workflows/hugegraph-python-client.yml
@@ -13,29 +13,57 @@ jobs:
       fail-fast: false
       matrix:
         python-version: ["3.9", "3.10", "3.11", "3.12"]
+
     steps:
+    # TODO: upgrade to HugeGraph 1.5.0 (need to update the test cases)
+    - name: Prepare HugeGraph Server Environment
+      run: |
+        docker run -d --name=graph -p 8080:8080 -e PASSWORD=admin 
hugegraph/hugegraph:1.3.0
+        #sleep 5
+
     - uses: actions/checkout@v4
+
     - name: Set up Python ${{ matrix.python-version }}
       uses: actions/setup-python@v5
       with:
         python-version: ${{ matrix.python-version }}
-        cache: 'pip'
-    - name: Install dependencies
+
+    - name: Install uv
       run: |
-        python -m pip install --upgrade pip
-        pip install pytest
-        pip install -r ./hugegraph-python-client/requirements.txt
-    - name: Prepare HugeGraph Server Environment
-      # TODO: update the HugeGraph Server version to 1.5.0
+        curl -LsSf https://astral.sh/uv/install.sh | sh
+        echo "$HOME/.cargo/bin" >> $GITHUB_PATH
+
+    - name: Cache dependencies
+      id: cache-deps
+      uses: actions/cache@v4
+      with:
+        path: |
+          .venv
+          ~/.cache/uv
+          ~/.cache/pip
+        key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ 
hashFiles('hugegraph-python-client/requirements.txt') }}
+        restore-keys: |
+          ${{ runner.os }}-venv-${{ matrix.python-version }}-
+          ${{ runner.os }}-venv-
+
+    # TODO: use pyproject.toml later
+    - name: Install dependencies
+      if: steps.cache-deps.outputs.cache-hit != 'true'
       run: |
-        docker run -d --name=graph -p 8080:8080 -e PASSWORD=admin 
hugegraph/hugegraph:1.3.0
-        sleep 20
+        uv venv
+        source .venv/bin/activate
+        uv pip install pytest
+        uv pip install -r ./hugegraph-python-client/requirements.txt
+
     - name: Test example
       run: |
+        ls -al && source .venv/bin/activate
         export PYTHONPATH=$(pwd)/hugegraph-python-client/src
         echo ${PYTHONPATH}
         python 
hugegraph-python-client/src/pyhugegraph/example/hugegraph_example.py
+
     - name: Test with pytest
       run: |
+        ls -al ../ && source ../.venv/bin/activate
         pytest
       working-directory: hugegraph-python-client
diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml
index 3969005..f3b0a50 100644
--- a/.github/workflows/pylint.yml
+++ b/.github/workflows/pylint.yml
@@ -17,21 +17,47 @@ jobs:
 
     steps:
     - uses: actions/checkout@v4
+
     - name: Setup Python ${{ matrix.python-version }}
       uses: actions/setup-python@v5
       with:
         python-version: ${{ matrix.python-version }}
-        cache: 'pip'
+
+    - name: Install uv
+      run: |
+        curl -LsSf https://astral.sh/uv/install.sh | sh
+        echo "$HOME/.cargo/bin" >> $GITHUB_PATH
+
+    - name: Cache dependencies
+      id: cache-deps
+      uses: actions/cache@v4
+      with:
+        path: |
+          .venv
+          ~/.cache/uv
+          ~/.cache/pip
+        key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ 
hashFiles('**/requirements.txt', '**/pyproject.toml') }}
+        restore-keys: |
+          ${{ runner.os }}-venv-${{ matrix.python-version }}-
+          ${{ runner.os }}-venv-
 
     - name: Install dependencies
+      if: steps.cache-deps.outputs.cache-hit != 'true'
       run: |
-        pip install pylint pytest
-        pip install -r ./hugegraph-llm/requirements.txt
-        pip install -r ./hugegraph-ml/requirements.txt
-        pip install -r ./hugegraph-python-client/requirements.txt
+        uv venv
+        source .venv/bin/activate
+        uv pip install pylint pytest
+        # TODO: use pyproject.toml later (unify all projects)
+        uv pip install -r ./hugegraph-llm/requirements.txt
+        uv pip install -r ./hugegraph-ml/requirements.txt
+        uv pip install -r ./hugegraph-python-client/requirements.txt
+
     - name: Check DGL version
       run: |
+        source .venv/bin/activate
         python -c "import dgl; print(dgl.__version__)"
+
     - name: Analysing the code with pylint
       run: |
+        source .venv/bin/activate
         bash ./style/code_format_and_analysis.sh -p

Reply via email to