Skip to content

Commit

Permalink
[#2518] feat(PyClient): Integrate pytest with Gradle to run python te…
Browse files Browse the repository at this point in the history
…st with CICD (#2753)

### What changes were proposed in this pull request?

1. Use Gradle python plugin to manage python module
2. Automatic download conda and create python env in
`gravitino/.gradle/python` directory
3. Use multiple python version `3.8`, `3.9`, `3.10`,and `3.11` test ITs
in Github Action
4. Support `gradlew clean` & `gradlew build` & `gradlew
:client:client-python:test -PpythonVersion=3.8`

### Why are the changes needed?

Use Gradle manager and development Python client module.

Fix: #2518 

### Does this PR introduce _any_ user-facing change?

1. Use `pythonVersion` Gradle parameter setting Python version to
compile and test Python client, `gradlew :client:client-python:test
-PpythonVersion=3.8`
2. Use `skipPythonITs` Gradle parameter to control if skip Python test
cases.

### How was this patch tested?

CI Passed.

---------

Co-authored-by: Peidian li <[email protected]>
  • Loading branch information
xunliu and coolderli authored Apr 3, 2024
1 parent e7d5d23 commit f7f12d8
Show file tree
Hide file tree
Showing 15 changed files with 206 additions and 186 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/backend-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ jobs:
- api/**
- bin/**
- catalogs/**
- clients/**
- clients/client-java/**
- clients/client-java-runtime/**
- clients/filesystem-hadoop3/**
- clients/filesystem-hadoop3-runtime/**
- common/**
- conf/**
- core/**
Expand Down Expand Up @@ -88,7 +91,7 @@ jobs:
- name: Backend Integration Test
id: integrationTest
run: |
./gradlew test --rerun-tasks -PskipTests -PtestMode=${{ matrix.test-mode }} -PjdkVersion=${{ matrix.java-version }} -PskipWebITs -P${{ matrix.backend }}
./gradlew test --rerun-tasks -PskipTests -PtestMode=${{ matrix.test-mode }} -PjdkVersion=${{ matrix.java-version }} -PskipWebITs -P${{ matrix.backend }} -PskipPythonITs
- name: Upload integrate tests reports
uses: actions/upload-artifact@v3
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ jobs:
- api/**
- bin/**
- catalogs/**
- clients/**
- clients/client-java/**
- clients/client-java-runtime/**
- clients/filesystem-hadoop3/**
- clients/filesystem-hadoop3-runtime/**
- common/**
- conf/**
- core/**
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/frontend-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ jobs:
- api/**
- bin/**
- catalogs/**
- clients/**
- clients/client-java/**
- clients/client-java-runtime/**
- clients/filesystem-hadoop3/**
- clients/filesystem-hadoop3-runtime/**
- common/**
- conf/**
- core/**
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/python-integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Python Client Integration Test

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main", "branch-*" ]
pull_request:
branches: [ "main", "branch-*" ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
changes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
source_changes:
- .github/**
- api/**
- clients/client-python/**
- common/**
- conf/**
- core/**
- meta/**
- server/**
- server-common/**
outputs:
source_changes: ${{ steps.filter.outputs.source_changes }}

# Integration test for AMD64 architecture
test-amd64-arch:
needs: changes
if: needs.changes.outputs.source_changes == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
architecture: [linux/amd64]
java-version: [ 8 ]
env:
PLATFORM: ${{ matrix.architecture }}
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Free up disk space
run: |
dev/ci/util_free_space.sh
- name: Python Client Integration Test
id: integrationTest
run: |
for pythonVersion in "3.8" "3.9" "3.10" "3.11"
do
./gradlew -PjdkVersion=${{ matrix.java-version }} -PpythonVersion=${pythonVersion} :client:client-python:test
done
- name: Upload integrate tests reports
uses: actions/upload-artifact@v3
if: ${{ failure() && steps.integrationTest.outcome == 'failure' }}
with:
name: integrate test reports
path: |
build/reports
integration-test/build/integration-test.log
distribution/package/logs/gravitino-server.out
distribution/package/logs/gravitino-server.log
catalogs/**/*.log
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ docs/build
dev/docker/tools/docker-connector

include web/.gitignore
include clients/client-python/.gitignore

# node env
.node
Expand Down
13 changes: 13 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,21 @@ project.extra["extraJvmArgs"] = if (extra["jdkVersion"] in listOf("8", "11")) {
)
}

val pythonVersion: String = project.properties["pythonVersion"] as? String ?: project.extra["pythonVersion"].toString()
project.extra["pythonVersion"] = pythonVersion

licenseReport {
renderers = arrayOf<ReportRenderer>(InventoryHtmlReportRenderer("report.html", "Backend"))
filters = arrayOf<DependencyFilter>(LicenseBundleNormalizer())
}
repositories { mavenCentral() }

allprojects {
// Gravitino Python client project didn't need to apply the Spotless plugin
if (project.name == "client-python") {
return@allprojects
}

apply(plugin = "com.diffplug.spotless")
repositories {
mavenCentral()
Expand Down Expand Up @@ -215,6 +223,11 @@ dependencies {
}

subprojects {
// Gravitino Python client project didn't need to apply the java plugin
if (project.name == "client-python") {
return@subprojects
}

apply(plugin = "jacoco")
apply(plugin = "maven-publish")
apply(plugin = "java")
Expand Down
169 changes: 9 additions & 160 deletions clients/client-python/.gitignore
Original file line number Diff line number Diff line change
@@ -1,160 +1,9 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Copyright 2024 Datastrato Pvt Ltd.
# This software is licensed under the Apache License version 2.

**/.pytest_cache/**
**/__pycache__/**
gravitino.egg-info
vevn
.vevn
.idea
15 changes: 0 additions & 15 deletions clients/client-python/Makefile

This file was deleted.

Loading

0 comments on commit f7f12d8

Please sign in to comment.