Add ruff in CI and pre-commit #125
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
| # This workflow will install Python dependencies, run tests and lint | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
| name: Python tests | |
| on: | |
| push: | |
| branches: [ "master", "develop" ] | |
| pull_request: | |
| branches: [ "master", "develop" ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| pythontests: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["pypy3.11", "3.11"] # 3.11 is the lowest we support, since we want StrEnum | |
| 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 mypy ruff pytest | |
| if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
| - name: Lint with ruff | |
| run: ruff check --output-format=github | |
| - name: Check ruff formatting | |
| run: ruff format --check --diff | |
| - name: Test with pytest | |
| run: pytest | |
| - name: Run mypy | |
| run: | | |
| mypy --non-interactive --config-file mypy.ini -p problemtools | |
| packages: # Use a separate job to test debian packaging to speed things up (no need to test this for every python version above) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install apt packages (for debbuild) | |
| run: sudo apt-get install debhelper dh-virtualenv dpkg-dev python3-venv automake g++ make libboost-regex-dev libgmp-dev python3 git build-essential | |
| shell: bash | |
| - name: Build debian packages | |
| run: make builddeb |