chore: Use devcontainers #699
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: Checks | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '41 16 * * *' # Every day at 16:41 UTC (to avoid high load at exact hour values). | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| UV_NO_SYNC: 1 | |
| jobs: | |
| tests: | |
| # Default config: py3.14, ubuntu-latest, float32, full options. | |
| # The idea is to make each of those params vary one by one, to limit the number of tests to run. | |
| name: Tests (py${{ matrix.python-version || '3.14' }}, ${{ matrix.os || 'ubuntu-latest' }}, ${{ matrix.dtype || 'float32' }}, ${{ matrix.options || 'full' }}${{ matrix.extra_groups && format(', {0}', matrix.extra_groups) || '' }}) | |
| runs-on: ${{ matrix.os || 'ubuntu-latest' }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Python version variations | |
| - python-version: '3.10' | |
| - python-version: '3.11' | |
| - python-version: '3.12' | |
| - python-version: '3.13' | |
| - python-version: '3.14' # To actually run the default config | |
| # OS variations | |
| - os: macOS-latest | |
| - os: windows-latest | |
| # dtype variations | |
| - dtype: float64 | |
| # Installation options variations | |
| - options: 'none' | |
| # Lower-bounds of all dependencies and Python version. | |
| - python-version: '3.10.0' | |
| extra_groups: 'lower_bounds' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| python-version: ${{ matrix.python-version || '3.14' }} | |
| - uses: ./.github/actions/install-deps | |
| with: | |
| options: ${{ matrix.options || 'full' }} | |
| groups: test ${{ matrix.extra_groups }} | |
| - name: Run unit tests | |
| run: uv run pytest -W error tests/unit --cov=src --cov-report=xml | |
| env: | |
| PYTEST_TORCH_DTYPE: ${{ matrix.dtype || 'float32' }} | |
| - name: Upload results to Codecov | |
| uses: codecov/codecov-action@v6 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| build-devcontainer: | |
| name: Build devcontainer image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push devcontainer image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: .devcontainer/Dockerfile | |
| push: true | |
| tags: ghcr.io/${{ github.repository }}/devcontainer:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-doc: | |
| name: Build and test documentation | |
| needs: build-devcontainer | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/${{ github.repository }}/devcontainer:${{ github.sha }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Sync project installation | |
| run: uv pip install -e '.[full]' --group doc | |
| - name: Build Documentation | |
| working-directory: docs | |
| run: uv run make dirhtml | |
| - name: Test Documentation | |
| working-directory: docs | |
| run: uv run make doctest | |
| code-quality: | |
| name: Code quality (ty and pre-commit hooks) | |
| needs: build-devcontainer | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/${{ github.repository }}/devcontainer:${{ github.sha }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Sync project installation | |
| run: uv pip install -e '.[full]' --group check --group test --group plot | |
| - name: Run pre-commit hooks | |
| run: uv run pre-commit run --all-files | |
| - name: Run ty | |
| run: uv run ty check --output-format=github |