feat: Improve test coverage #117
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: CI | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| release: | |
| types: [ published ] | |
| jobs: | |
| test-linux: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: linux-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }} | |
| restore-keys: | | |
| linux-pip-${{ matrix.python-version }}- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e . | |
| pip install -r requirements-dev.txt | |
| - name: Lint (ruff) | |
| if: matrix.python-version == '3.11' | |
| run: ruff check . --output-format=github | |
| - name: Type-check (mypy) | |
| if: matrix.python-version == '3.11' | |
| run: mypy . | |
| - name: Run tests with coverage | |
| if: matrix.python-version == '3.11' | |
| run: pytest --cov=checkcrontab --cov-report=xml --cov-report=term-missing | |
| - name: Generate coverage HTML report | |
| if: matrix.python-version == '3.11' | |
| run: coverage html | |
| - name: Upload coverage to Codecov | |
| if: matrix.python-version == '3.11' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: coverage.xml | |
| flags: linux | |
| fail_ci_if_error: true | |
| - name: Upload coverage artifacts | |
| if: matrix.python-version == '3.11' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-linux-${{ matrix.python-version }} | |
| path: | | |
| coverage.xml | |
| htmlcov | |
| - name: Run test suite | |
| if: matrix.python-version != '3.11' | |
| run: pytest | |
| - name: CLI smoke tests | |
| if: matrix.python-version == '3.11' | |
| run: | | |
| python -m checkcrontab examples/system_valid.txt | |
| python -m checkcrontab examples/user_valid.txt | |
| test-macos: | |
| runs-on: macos-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.11', '3.12'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e . | |
| pip install -r requirements-dev.txt | |
| - name: Run tests | |
| run: pytest | |
| - name: CLI smoke tests | |
| if: matrix.python-version == '3.11' | |
| run: | | |
| python -m checkcrontab examples/system_valid.txt | |
| python -m checkcrontab examples/user_valid.txt | |
| test-windows: | |
| runs-on: windows-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.11'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e . | |
| pip install -r requirements-dev.txt | |
| - name: Run tests | |
| run: pytest | |
| - name: CLI smoke tests | |
| run: | | |
| python -m checkcrontab examples/system_valid.txt | |
| python -m checkcrontab examples/user_valid.txt | |
| build: | |
| needs: | |
| - test-linux | |
| - test-macos | |
| - test-windows | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build wheel setuptools | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| #- name: Publish to PyPI | |
| # if: github.event_name == 'release' | |
| # uses: pypa/gh-action-pypi-publish@release/v1 | |
| # with: | |
| # password: ${{ secrets.PYPI_API_TOKEN }} |