Enhance numeric comparison in Diffr class and update project name #5
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: Pull Request Checks | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - '**/*.py' | |
| - 'pyproject.toml' | |
| - 'requirements*.txt' | |
| - '.github/workflows/**' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| version-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install toml requests | |
| - name: Check if version exists as GitHub release | |
| run: | | |
| python -c " | |
| import toml | |
| import requests | |
| import sys | |
| # Read current version from pyproject.toml | |
| with open('pyproject.toml', 'r') as f: | |
| data = toml.load(f) | |
| current_version = data['project']['version'] | |
| print(f'Current version: {current_version}') | |
| # Check if this version exists as a GitHub release | |
| repo = '${{ github.repository }}' | |
| url = f'https://api.github.com/repos/{repo}/releases/tags/v{current_version}' | |
| response = requests.get(url) | |
| if response.status_code == 200: | |
| print(f'ERROR: Release v{current_version} already exists!') | |
| print('Please update the version in pyproject.toml before merging.') | |
| sys.exit(1) | |
| else: | |
| print(f'Version v{current_version} is available for release.') | |
| " | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| needs: version-check | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build black | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Install package | |
| run: | | |
| pip install dist/*.whl | |
| - name: Test installation | |
| run: | | |
| python -c "import diffgetr; print('Package imported successfully')" | |
| python -c "from diffgetr.diff_get import main; print('CLI function available')" | |
| - name: Run unit tests | |
| run: | | |
| python -m unittest discover diffgetr.tests -v | |
| format-code: | |
| runs-on: ubuntu-latest | |
| needs: build-and-test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| ref: ${{ github.head_ref }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install black | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install black | |
| - name: Format code with black | |
| run: | | |
| black --check --diff diffgetr/ || echo "Formatting needed" | |
| black diffgetr/ | |
| - name: Check for changes | |
| id: verify-changed-files | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit formatted code | |
| if: steps.verify-changed-files.outputs.changed == 'true' | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add -A | |
| git commit -m "🤖 Auto-format code with black" | |
| git push |