Fix CodeRabbit code quality issues across repository, schema, auth, and core modules #12
Workflow file for this run
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
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| release: | |
| types: [published] | |
| jobs: | |
| lint: | |
| name: Lint & Format Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install linting tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install ruff mypy | |
| - name: Check formatting with Ruff | |
| run: ruff format --check . | |
| - name: Lint with Ruff | |
| run: ruff check . | |
| - name: Type check with mypy | |
| run: mypy runapi --ignore-missing-imports | |
| continue-on-error: true # Don't fail on type errors initially | |
| test: | |
| name: Test Python ${{ matrix.python-version }} | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
| 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 dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[test]" | |
| - name: Run tests | |
| run: | | |
| python tests/test_runapi.py | |
| check-version: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| outputs: | |
| is_new_version: ${{ steps.check.outputs.is_new_version }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Check if version is new | |
| id: check | |
| shell: python | |
| run: | | |
| import tomllib | |
| import sys | |
| import json | |
| import os | |
| from urllib.request import urlopen | |
| from urllib.error import HTTPError | |
| try: | |
| with open("pyproject.toml", "rb") as f: | |
| project = tomllib.load(f) | |
| local_version = project["project"]["version"] | |
| package_name = project["project"]["name"] | |
| print(f"Checking version {local_version} for package {package_name}...") | |
| # Output version for later jobs | |
| with open(os.environ['GITHUB_OUTPUT'], 'a') as fh: | |
| print(f"version={local_version}", file=fh) | |
| try: | |
| with urlopen(f"https://pypi.org/pypi/{package_name}/json") as response: | |
| data = json.load(response) | |
| pypi_versions = data["releases"].keys() | |
| if local_version in pypi_versions: | |
| print(f"Version {local_version} already exists on PyPI. Skipping build & publish.") | |
| with open(os.environ['GITHUB_OUTPUT'], 'a') as fh: | |
| print("is_new_version=false", file=fh) | |
| else: | |
| print(f"Version {local_version} is new! Proceeding.") | |
| with open(os.environ['GITHUB_OUTPUT'], 'a') as fh: | |
| print("is_new_version=true", file=fh) | |
| except HTTPError as e: | |
| if e.code == 404: | |
| print("Package not found on PyPI (first deployment). Proceeding.") | |
| with open(os.environ['GITHUB_OUTPUT'], 'a') as fh: | |
| print("is_new_version=true", file=fh) | |
| else: | |
| print(f"Error checking PyPI: {e}") | |
| sys.exit(1) | |
| except Exception as e: | |
| print(f"Error: {e}") | |
| sys.exit(1) | |
| build: | |
| needs: check-version | |
| if: needs.check-version.outputs.is_new_version == 'true' | |
| name: Build distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build | |
| - name: Build a binary wheel and a source tarball | |
| run: python -m build | |
| - name: Store the distribution packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| publish-to-pypi: | |
| name: Publish to PyPI | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish distribution to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| skip-existing: true | |
| verbose: true | |
| create-release: | |
| name: Create GitHub Release | |
| needs: [publish-to-pypi, check-version] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| name: v${{ needs.check-version.outputs.version }} | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: false |