Skip to content

CI testing

CI testing #1101

Workflow file for this run

name: CI testing
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
on: # Trigger the workflow on push or pull request, but only for the main branch
push: {}
pull_request:
branches: [main]
schedule:
- cron: "0 0 * * *" # every day at midnight UTC
defaults:
run:
shell: bash
jobs:
pytester:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-24.04", "macOS-13", "windows-2022"]
python-version: ["3.9", "3.12"]
requires: ["latest"]
dependency: ["lightning"]
include:
- { os: "ubuntu-22.04", python-version: "3.9", requires: "oldest", dependency: "lightning" }
- { os: "ubuntu-24.04", python-version: "3.12", requires: "latest", dependency: "pytorch_lightning" }
- { os: "windows-2022", python-version: "3.12", requires: "latest", dependency: "pytorch_lightning" }
- { os: "macOS-13", python-version: "3.12", requires: "latest", dependency: "pytorch_lightning" }
# Timeout: https://stackoverflow.com/a/59076067/4521646
timeout-minutes: 35
env:
TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Set min. dependencies
if: matrix.requires == 'oldest'
run: |
pip install 'lightning-utilities[cli]'
python -m lightning_utilities.cli requirements set-oldest --req_files='["requirements.txt"]'
- name: Adjust requirements
run: |
pip install 'lightning-utilities[cli]' -U -q
python -m lightning_utilities.cli requirements replace-pkg \
--old_package="lightning" \
--new_package="${{matrix.dependency}}" \
--req_files='["_requirements/extra.txt"]'
cat _requirements/extra.txt
- name: Install package & dependencies
run: |
set -e
pip --version
pip install -e '.[test,extra]' -U -q --find-links $TORCH_URL
pip list
# check that right package was installed
python -c "import ${{matrix.dependency}}; print(${{matrix.dependency}}.__version__)"
- name: Tests with mocks
run: |
coverage run --source litmodels -m pytest src tests -v -m "not cloud"
- name: Statistics
run: |
coverage report
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
tests-guardian:
runs-on: ubuntu-latest
needs: pytester
if: always()
steps:
- run: echo "${{ needs.pytester.result }}"
- name: failing...
if: needs.pytester.result == 'failure'
run: exit 1
- name: cancelled or skipped...
if: contains(fromJSON('["cancelled", "skipped"]'), needs.pytester.result)
timeout-minutes: 1
run: sleep 90