feat Updating the overall project CI/CD and openapi-generator depende… #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: This file is auto generated by OpenAPI Generator. | |
# URL: https://openapi-generator.tech | |
# | |
# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
name: sysdig_client Python package | |
on: | |
push: | |
pull_request: | |
workflow_call: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
max-parallel: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install uv | |
uses: astral-sh/setup-uv@v6 | |
with: | |
python-version: "${{ matrix.python-version }}" | |
enable-cache: true | |
version: "0.8.7" | |
- name: Download dependencies | |
run: make init | |
- name: Run ruff check | |
run: uvx ruff check . --fix --select=E9,F63,F7,F82 --statistics --config ruff.toml --exclude specs | |
- name: Run Tests | |
run: make test-all | |
check_version: | |
name: Check Version | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
contents: write # required for creating a tag | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.sha }} # required for better experience using pre-releases | |
fetch-depth: '0' # Required due to the way Git works, without it this action won't be able to find any or the correct tags | |
- name: Extract current version | |
id: pyproject_version | |
run: | | |
TAG=v$(grep 'version =' pyproject.toml | sed -e 's/version = "\(.*\)"/\1/') | |
echo "TAG=$TAG" >> "$GITHUB_OUTPUT" | |
- name: Get branch ref name | |
id: branch_ref | |
run: | | |
BRANCH_NAME=${{ github.base_ref || github.ref_name }} | |
echo "$BRANCH_NAME" | |
echo "BRANCH_NAME=$BRANCH_NAME" >> "$GITHUB_OUTPUT" | |
- name: Get tag version | |
id: semantic_release | |
uses: anothrNick/github-tag-action@1.71.0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DEFAULT_BUMP: "patch" | |
TAG_CONTEXT: 'repo' | |
WITH_V: true | |
DRY_RUN: true | |
- name: Compare versions | |
run: | | |
echo "Current version: ${{ steps.pyproject_version.outputs.TAG }}" | |
echo "New version: ${{ steps.semantic_release.outputs.tag }}" | |
if [ "${{ steps.pyproject_version.outputs.TAG }}" != "${{ steps.semantic_release.outputs.tag }}" ]; then | |
echo "### Version mismatch detected! :warning: | |
Current pyproject version: ${{ steps.pyproject_version.outputs.TAG }} | |
New Tag version: **${{ steps.semantic_release.outputs.tag }}** | |
Current Tag: ${{ steps.semantic_release.outputs.old_tag }} | |
Please update the version in pyproject.toml." >> $GITHUB_STEP_SUMMARY | |
exit 1 | |
else | |
echo "### Version match confirmed! :rocket: | |
Current pyproject version: ${{ steps.pyproject_version.outputs.TAG }} | |
New Tag version: **${{ steps.semantic_release.outputs.tag }}** | |
The version is up-to-date." >> $GITHUB_STEP_SUMMARY | |
fi |