|
| 1 | +name: CI |
| 2 | + |
| 3 | +# Runs on every push to main and every pull request targeting main. |
| 4 | +# Scope is deliberate: dependency-light unit tests and import checks only. |
| 5 | +# The full experiments (CNN training, DoWhy counterfactuals, cross-domain runs) |
| 6 | +# require TensorFlow, DoWhy, a GPU, and licensed datasets that are not available |
| 7 | +# in CI. Those are run on a workstation and recorded in EXPERIMENTS.md. |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: [main] |
| 12 | + pull_request: |
| 13 | + branches: [main] |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + test: |
| 21 | + name: tests (py${{ matrix.python-version }}) |
| 22 | + runs-on: ubuntu-latest |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + python-version: ["3.11", "3.12", "3.13"] |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Set up Python ${{ matrix.python-version }} |
| 32 | + uses: actions/setup-python@v5 |
| 33 | + with: |
| 34 | + python-version: ${{ matrix.python-version }} |
| 35 | + cache: pip |
| 36 | + |
| 37 | + - name: Install core dependencies |
| 38 | + run: | |
| 39 | + python -m pip install --upgrade pip |
| 40 | + pip install -r requirements.txt |
| 41 | + pip install pytest |
| 42 | +
|
| 43 | + - name: Run unit tests |
| 44 | + run: pytest test/ -v |
| 45 | + |
| 46 | + import-independence: |
| 47 | + name: import-independence (no TensorFlow) |
| 48 | + runs-on: ubuntu-latest |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Set up Python |
| 53 | + uses: actions/setup-python@v5 |
| 54 | + with: |
| 55 | + python-version: "3.12" |
| 56 | + cache: pip |
| 57 | + |
| 58 | + - name: Install core dependencies only |
| 59 | + run: | |
| 60 | + python -m pip install --upgrade pip |
| 61 | + pip install -r requirements.txt |
| 62 | +
|
| 63 | + - name: Assert TensorFlow is absent |
| 64 | + run: | |
| 65 | + python - <<'PY' |
| 66 | + import importlib.util, sys |
| 67 | + if importlib.util.find_spec("tensorflow") is not None: |
| 68 | + sys.exit("TensorFlow is installed; this job must run without it.") |
| 69 | + print("confirmed: TensorFlow not installed") |
| 70 | + PY |
| 71 | +
|
| 72 | + - name: Import dependency-light subpackages |
| 73 | + run: | |
| 74 | + python - <<'PY' |
| 75 | + import importlib |
| 76 | + for mod in ("cnsd.causal", "cnsd.physics", "cnsd.config", "cnsd.scm"): |
| 77 | + importlib.import_module(mod) |
| 78 | + print(f"imported {mod} without TensorFlow") |
| 79 | + PY |
| 80 | +
|
| 81 | + install: |
| 82 | + name: editable install |
| 83 | + runs-on: ubuntu-latest |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v4 |
| 86 | + |
| 87 | + - name: Set up Python |
| 88 | + uses: actions/setup-python@v5 |
| 89 | + with: |
| 90 | + python-version: "3.12" |
| 91 | + cache: pip |
| 92 | + |
| 93 | + - name: Install package (editable, core extras) |
| 94 | + run: | |
| 95 | + python -m pip install --upgrade pip |
| 96 | + pip install -e . |
| 97 | +
|
| 98 | + - name: Import installed package |
| 99 | + run: python -c "import cnsd; print('cnsd installed and importable')" |
0 commit comments