[chore:project] Update CI\CD #3
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: Python Code Validator CI | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| build-and-test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ ubuntu-latest, windows-latest ] | |
| python-version: [ "3.11", "3.12" ] | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| if: runner.os == 'Linux' || runner.os == 'macOS' | |
| - name: Install uv (Windows) | |
| run: powershell -c "irm https://astral.sh/uv/install.ps1 | iex" | |
| if: runner.os == 'Windows' | |
| - name: Add uv to PATH | |
| run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| if: runner.os == 'Linux' || runner.os == 'macOS' | |
| - name: Add uv to PATH (Windows) | |
| run: echo "$((Get-Item (Get-Command uv).Source).Directory.FullName)" | Out-File -FilePath $env:GITHUB_PATH -Append | |
| if: runner.os == 'Windows' | |
| - name: Set up Python with uv | |
| run: uv venv -p ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: .venv/bin/uv pip install -e ".[dev]" | |
| if: runner.os != 'Windows' | |
| - name: Install dependencies (Windows) | |
| run: .venv\Scripts\uv.exe pip install -e ".[dev]" | |
| if: runner.os == 'Windows' | |
| - name: Lint and Format with ruff | |
| run: .venv/bin/ruff check src/ tests/ && .venv/bin/ruff format --check src/ tests/ | |
| if: runner.os != 'Windows' | |
| - name: Lint and Format with ruff (Windows) | |
| run: .venv\Scripts\ruff.exe check src/ tests/ ; .venv\Scripts\ruff.exe format --check src/ tests/ | |
| if: runner.os == 'Windows' | |
| - name: Run tests with coverage | |
| run: .venv/bin/coverage run -m unittest discover tests | |
| if: runner.os != 'Windows' | |
| - name: Run tests with coverage (Windows) | |
| run: .venv\Scripts\coverage.exe run -m unittest discover tests | |
| if: runner.os == 'Windows' | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: true |