add pre commit hook to run format tests (#118) #194
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: Continuous Integration | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| jobs: | |
| python: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python: ['3.11', '3.12', '3.13', '3.14', '3.14t'] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: update APT | |
| run: sudo apt-get update | |
| - name: Install dependencies | |
| run: sudo apt-get install -y libsystemd-dev | |
| - name: Install environment | |
| run: uv sync --all-extras --dev | |
| - name: Assert Python Version | |
| run: uv run python -V | |
| - name: Run unit tests | |
| run: uv run pytest --cov=pystemd tests | |
| formatting: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| - name: Run ruff | |
| uses: astral-sh/ruff-action@v3 | |
| with: | |
| src: >- | |
| pystemd | |
| examples | |
| tests | |
| e2e | |
| - name: Run isort | |
| uses: isort/isort-action@v1 | |
| - name: Formatting hint | |
| if: failure() | |
| run: | | |
| echo "::notice::PROTIP: You can install pre-commit hooks to automatically format your code before each commit. Run 'uv run pre-commit install' and never have to resubmit a PR because of formatting errors! See CONTRIBUTING.md for more details." | |
| typing: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: update APT | |
| run: sudo apt-get update | |
| - name: Install dependencies | |
| run: sudo apt-get install -y libsystemd-dev | |
| - name: install environment | |
| run: uv sync --all-extras --dev | |
| - name: run pyrefly | |
| run: uv run pyrefly check pystemd examples tests | |