diff --git a/.github/workflows/python-client-build-artifacts.yml b/.github/workflows/python-client-build-artifacts.yml new file mode 100644 index 0000000000..bbdb8d5ca4 --- /dev/null +++ b/.github/workflows/python-client-build-artifacts.yml @@ -0,0 +1,131 @@ +# +# 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: "Python Client Build Snapshot Artifacts" + +on: + workflow_dispatch: + workflow_call: + outputs: + artifact-name: + description: "Name of the merged artifact containing all wheels and sdist" + value: ${{ jobs.merge-artifacts.outputs.artifact-name }} + pull_request: + paths: + - '.github/workflows/python-client-build-artifacts.yml' + - 'client/python/**' + +jobs: + generate-version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 + with: + fetch-depth: 1 + + - name: Set up Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6 + with: + python-version: "3.13" + + - name: Install Poetry + run: make client-install-poetry + + - name: Generate snapshot version + id: version + run: | + CURRENT_VERSION=$(make client-get-version) + DATE_SUFFIX=$(date -u +%Y%m%d%H%M%S) + NIGHTLY_VERSION="${CURRENT_VERSION}.dev${DATE_SUFFIX}" + echo "version=$NIGHTLY_VERSION" >> $GITHUB_OUTPUT + echo "Generated snapshot version: $NIGHTLY_VERSION" + + build-artifacts: + name: Build artifacts on ${{ matrix.os }} with Python ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + needs: generate-version + strategy: + matrix: + os: [ubuntu-24.04, macos-14, macos-15] + python-version: ["3.10", "3.11", "3.12", "3.13"] + + steps: + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 + with: + fetch-depth: 1 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6 + with: + python-version: ${{ matrix.python-version }} + + - name: Set up JDK for openapi-generator-cli + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 + with: + distribution: 'temurin' + java-version: '21' + + - name: Set snapshot version + run: | + echo "Setting version to: ${{ needs.generate-version.outputs.version }}" + make client-set-version VERSION="${{ needs.generate-version.outputs.version }}" + + - name: Build source distribution + if: matrix.python-version == '3.13' && startsWith(matrix.os, 'ubuntu-24.04') + run: | + make client-build FORMAT=sdist + + - name: Build wheel + run: | + make client-build FORMAT=wheel + + - name: Prepare artifacts directory + run: | + mkdir -p wheelhouse + cp ./client/python/dist/*.whl wheelhouse/ + + - name: Add source distribution + if: matrix.python-version == '3.13' && startsWith(matrix.os, 'ubuntu-24.04') + run: cp ./client/python/dist/*.tar.gz wheelhouse/ + + - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 + with: + name: python-client-artifacts-${{ matrix.os }}-${{ matrix.python-version }} + path: ./wheelhouse/* + + merge-artifacts: + runs-on: ubuntu-latest + needs: + - generate-version + - build-artifacts + outputs: + artifact-name: ${{ steps.output-name.outputs.artifact-name }} + steps: + - name: Merge Artifacts + uses: actions/upload-artifact/merge@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 + with: + name: python-client-artifacts-${{ needs.generate-version.outputs.version }} + pattern: python-client-artifacts-* + delete-merged: true + + - name: Output artifact name + id: output-name + run: echo "artifact-name=python-client-artifacts-${{ needs.generate-version.outputs.version }}" >> $GITHUB_OUTPUT diff --git a/Makefile b/Makefile index 64ee9756fc..57e9e7314e 100644 --- a/Makefile +++ b/Makefile @@ -112,13 +112,16 @@ $(VENV_DIR): @python3 -m venv $(VENV_DIR) @echo "Virtual environment created." -.PHONY: client-install-dependencies -client-install-dependencies: $(VENV_DIR) - @echo "Installing Poetry and project dependencies into $(VENV_DIR)..." - @$(VENV_DIR)/bin/pip install --upgrade pip +.PHONY: client-install-poetry +client-install-poetry: $(VENV_DIR) ## Install Poetry into the virtual environment + @$(VENV_DIR)/bin/pip install --upgrade pip -q @if [ ! -f "$(VENV_DIR)/bin/poetry" ]; then \ - $(VENV_DIR)/bin/pip install --upgrade "poetry$(POETRY_VERSION)"; \ + $(VENV_DIR)/bin/pip install --upgrade "poetry$(POETRY_VERSION)" -q; \ fi + +.PHONY: client-install-dependencies +client-install-dependencies: client-install-poetry + @echo "Installing project dependencies into $(VENV_DIR)..." @$(ACTIVATE_AND_CD) && poetry lock && poetry install --all-extras @echo "Poetry and dependencies installed." @@ -131,6 +134,20 @@ client-lint: client-setup-env ## Run linting checks for Polaris client @$(ACTIVATE_AND_CD) && poetry run pre-commit run --files integration_tests/* generate_clients.py apache_polaris/cli/* apache_polaris/cli/command/* apache_polaris/cli/options/* test/* @echo "--- Client linting checks complete ---" +.PHONY: client-get-version +client-get-version: ## Get Python client version (requires poetry to be installed) + @$(ACTIVATE_AND_CD) && poetry version --short + +.PHONY: client-set-version +client-set-version: client-setup-env ## Set Python client version using poetry. Usage: make client-set-version VERSION= + @echo "--- Setting client version ---" + @if [ -z "$(VERSION)" ]; then \ + echo "Error: VERSION is required. Usage: make client-set-version VERSION=" >&2; \ + exit 1; \ + fi + @$(ACTIVATE_AND_CD) && poetry version "$(VERSION)" + @echo "--- Client version set to $(VERSION) ---" + .PHONY: client-regenerate client-regenerate: client-setup-env ## Regenerate the client code @echo "--- Regenerating client code ---"