build: pin versions #833
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 with a variety of Python versions | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
| # TODO: In the future we ought to perform code coverage checks | |
| name: Pull Request | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| env: | |
| PYTHON_VERSION: "3.10" | |
| jobs: | |
| tests: | |
| name: "Tests" | |
| timeout-minutes: 30 | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| # For Pull Requests we run tests on Ubuntu with Python 3.10. | |
| # In releases we will test on more configurations. | |
| operating-system: | |
| - ubuntu-latest | |
| # - windows-latest | |
| # - macos-latest | |
| python-version: | |
| - '3.10' | |
| # - '3.11' | |
| # - '3.12' | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python ${{ env.PYTHON_VERSION }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| cache: 'pip' # caching pip dependencies | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu | |
| python -m pip install ".[dev]" | |
| - name: Cache Test Datasets | |
| id: cache-test-datasets | |
| uses: actions/cache@v4 | |
| with: | |
| path: data | |
| key: "test-datasets" | |
| - name: PyTest | |
| run: invoke test.pytest | |
| - name: Doctest | |
| run: invoke test.doctest | |
| - name: Check Notebooks | |
| run: invoke test.nb | |
| lint: | |
| name: "Code Style" | |
| timeout-minutes: 10 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Formatting | |
| uses: astral-sh/ruff-action@v3 | |
| with: | |
| args: "format --check" | |
| - name: Linting | |
| uses: astral-sh/ruff-action@v3 | |
| commit: | |
| name: "Commit Style" | |
| runs-on: ubuntu-latest | |
| # Only report commit style issues on push to main, not on PRs as contributors seldom | |
| # want to worry about fixing commit messages. The reviewer will `squash and merge` | |
| # with a proper commit message. | |
| if: github.event_name == 'push' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: wagoid/commitlint-github-action@v6 | |
| documentation: | |
| name: "Documentation" | |
| timeout-minutes: 10 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| cache: 'pip' # caching pip dependencies | |
| - name: Install Dependencies | |
| run: | | |
| sudo apt-get install -y pandoc | |
| python -m pip install torch~=2.9.1 torchvision~=0.24.1 --index-url https://download.pytorch.org/whl/cpu | |
| python -m pip install -U ".[dev,doc]" | |
| # '-U' upgrades dependencies based on the pyproject.toml | |
| - name: Build Documentation | |
| run: invoke docs.build | |
| - name: Artifact name | |
| run: echo DOC_ARTIFACT_NAME=doc-${GITHUB_REF//\//-} >> $GITHUB_ENV | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.DOC_ARTIFACT_NAME }} | |
| retention-days: 14 | |
| path: docs/_build | |
| overwrite: true |