[fix:project] Update CI CD #10
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" ] | |
| 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 != 'Windows' | |
| - 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 != 'Windows' | |
| - 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 and install dependencies | |
| run: | | |
| uv venv -p ${{ matrix.python-version }} | |
| uv pip install -e ".[dev]" | |
| - name: Run Linting and Tests (Linux/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| echo "--- Running Lint and Format Check ---" | |
| .venv/bin/ruff check src/ tests/ | |
| .venv/bin/ruff format --check src/ tests/ | |
| echo "--- Running Tests with Coverage ---" | |
| .venv/bin/coverage run -m unittest discover tests | |
| - name: Run Linting and Tests (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| echo "--- Running Lint and Format Check ---" | |
| .\.venv\Scripts\ruff.exe check src/ tests/ | |
| .\.venv\Scripts\ruff.exe format --check src/ tests/ | |
| echo "--- Running Tests with Coverage ---" | |
| .\.venv\Scripts\coverage.exe run -m unittest discover tests | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: true |