/ .github / workflows / python-ci.yml
python-ci.yml
  1  name: CI with Python Test
  2  on:
  3    push:
  4      paths-ignore:
  5        - "javadoc/**"
  6        - "website/**"
  7        - "**.md"
  8      branches:
  9        - 'main'
 10        - 'release/**'
 11      tags:
 12        - 'py-v[0-9]+.[0-9]+.[0-9]+'
 13    pull_request:
 14      paths-ignore:
 15        - "javadoc/**"
 16        - "website/**"
 17        - "**.md"
 18      branches:
 19        - 'main'
 20        - 'release/**'
 21    workflow_dispatch:
 22  
 23  jobs:
 24    run-pytest:
 25      runs-on: ubuntu-24.04
 26      services:
 27        # Label used to access the service container
 28        postgres:
 29          # Docker Hub image
 30          image: postgres:14.5
 31          # Provide the password for postgres
 32          env:
 33            POSTGRES_PASSWORD: lakesoul_test
 34            POSTGRES_USER: lakesoul_test
 35            POSTGRES_DB: lakesoul_test
 36          # Set health checks to wait until postgres has started
 37          options: >-
 38            --health-cmd pg_isready
 39            --health-interval 10s
 40            --health-timeout 5s
 41            --health-retries 5
 42            --name lakesoul-test-pg
 43          ports:
 44            # Maps tcp port 5432 on service container to the host
 45            - 5432:5432
 46      steps:
 47        - name: Free Disk Space (Ubuntu)
 48          uses: jlumbroso/free-disk-space@main
 49          with:
 50            tool-cache: false
 51            android: true
 52            dotnet: true
 53            haskell: true
 54            large-packages: false
 55            docker-images: true
 56            swap-storage: true
 57        - uses: actions/checkout@v4
 58        - name: Set up JDK 11
 59          uses: actions/setup-java@v4
 60          with:
 61            java-version: '11'
 62            distribution: 'temurin'
 63            cache: maven
 64        - name: Install psql
 65          run: sudo apt-get install -y postgresql-client-16
 66        - name: Init PG
 67          run: |
 68            ./script/meta_init_for_local_test.sh -j 2
 69        - name: Install Protoc
 70          uses: arduino/setup-protoc@v2
 71          with:
 72            version: "23.x"
 73            repo-token: ${{ secrets.GITHUB_TOKEN }}
 74        - name: Install uv
 75          uses: astral-sh/setup-uv@v6
 76          with:
 77            enable-cache: true
 78            cache-suffix: "lakesoul-py-ci"
 79            cache-dependency-glob: |
 80              pyproject.toml
 81              uv.lock
 82        - uses: Swatinem/rust-cache@v2
 83          with:
 84            workspaces: ". -> rust/target" 
 85            env-vars: "JAVA_HOME"
 86        - name: pytest
 87          env:
 88            LAKESOUL_SOURCE_DIR: ${{ github.workspace }}
 89          run: |
 90            mvn package -pl lakesoul-spark -am -DskipTests
 91            cd python
 92            uv sync
 93            source .venv/bin/activate
 94            export LAKESOUL_IO_USE_V2_MERGE=true
 95            cargo run --release -p lakesoul-console -- tpch-gen -p "file:///tmp/lakesoul/tpch_data" --scale-factor 0.1 -n 8 
 96            cargo run --release -p lakesoul-console -- -f test.sql
 97            uv run pytest ./tests/ -s
 98    publish:
 99      runs-on: ubuntu-24.04
100      if: startsWith(github.event.ref, 'refs/tags/py-v')
101      needs: ["run-pytest"]
102      env:
103        PIP_INDEX_URL: https://pypi.tuna.tsinghua.edu.cn/simple
104      permissions:
105        id-token: write 
106      steps:
107        - name: Checkout repository
108          uses: actions/checkout@v3
109        - name: Install uv
110          uses: astral-sh/setup-uv@v6
111        - name: build  
112          run: |
113            cd python && uvx --from 'maturin[zig]' maturin build --release --zig --target x86_64-unknown-linux-gnu --auditwheel repair --compatibility manylinux2014 --out ../dist
114        - name: Publish package distributions to PyPI
115          uses: pypa/gh-action-pypi-publish@release/v1
116  
117        
118          
119