|
1 | | -name: Pytest Tests |
| 1 | +name: Github CI |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_run: |
5 | | - workflows: ["Quick Tests"] |
6 | | - types: |
7 | | - - completed |
8 | | - branches: |
9 | | - - main |
10 | 4 | push: |
11 | 5 | branches: |
12 | 6 | - main |
|
15 | 9 | - main |
16 | 10 |
|
17 | 11 | jobs: |
| 12 | + format-check: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v3 |
| 17 | + with: |
| 18 | + ref: ${{ github.head_ref }} # Checkout the branch of the PR |
| 19 | + |
| 20 | + - name: Set up Python |
| 21 | + uses: actions/setup-python@v4 |
| 22 | + with: |
| 23 | + python-version: "3.13" |
| 24 | + |
| 25 | + - name: Install formatting tools |
| 26 | + run: | |
| 27 | + python -m pip install --upgrade pip |
| 28 | + pip install black |
| 29 | +
|
| 30 | + - name: Run Black |
| 31 | + run: | |
| 32 | + black . |
| 33 | +
|
| 34 | + - name: Commit and push formatting changes |
| 35 | + run: | |
| 36 | + # Check if any files have been modified |
| 37 | + if [ -n "$(git status --porcelain)" ]; then |
| 38 | + git config --global user.name "github-actions" |
| 39 | + git config --global user.email "github-actions@github.com" |
| 40 | + git add . |
| 41 | + git commit -m "Auto apply black [skip ci]" |
| 42 | + git push origin ${{ github.head_ref }} # Push changes to the same PR branch |
| 43 | + else |
| 44 | + echo "No formatting changes detected." |
| 45 | + fi |
| 46 | +
|
| 47 | + - name: Lint with flake8 |
| 48 | + run: | |
| 49 | + pip install flake8 |
| 50 | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| 51 | + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 52 | +
|
18 | 53 | tests: |
| 54 | + needs: format-check |
19 | 55 | strategy: |
20 | 56 | fail-fast: false # If one job fails, the rest will still run |
21 | 57 | matrix: |
22 | | - os: [ubuntu-latest, macos-latest] |
23 | | - python-version: ["3.10", "3.11", "3.12", "3.13"] |
| 58 | + os: [ubuntu-latest] # Omitting macos-latest because it is expensive |
| 59 | + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] |
24 | 60 | runs-on: ${{ matrix.os }} |
25 | 61 | defaults: |
26 | 62 | run: |
27 | 63 | shell: bash -el {0} |
28 | 64 | steps: |
29 | 65 | - uses: actions/checkout@v4 |
30 | 66 |
|
31 | | - - name: List files |
32 | | - run: | |
33 | | - pwd |
34 | | - ls -F |
35 | | -
|
36 | 67 | # Cache the conda environment |
37 | 68 | - name: Cache conda environment |
38 | 69 | uses: actions/cache@v4 |
@@ -60,10 +91,128 @@ jobs: |
60 | 91 | - name: Install package |
61 | 92 | run: pip install -e . |
62 | 93 |
|
| 94 | + - name: Install pgmpy |
| 95 | + run: | |
| 96 | + conda install pytorch |
| 97 | + conda install cpuonly |
| 98 | + pip install pgmpy |
| 99 | + python -m pgmpy || true |
| 100 | +
|
63 | 101 | - name: Test with pytest |
64 | | - run: pytest -v |
| 102 | + run: | |
| 103 | + pytest -r s -vv conin |
65 | 104 |
|
66 | | - - name: Run pytest with pgmpy |
| 105 | + mip-solver-tests: |
| 106 | + needs: format-check |
| 107 | + strategy: |
| 108 | + fail-fast: false # If one job fails, the rest will still run |
| 109 | + matrix: |
| 110 | + os: [ubuntu-latest] # Omitting macos-latest because it is expensive |
| 111 | + solver: ["highs", "glpk", "none"] |
| 112 | + runs-on: ${{ matrix.os }} |
| 113 | + defaults: |
| 114 | + run: |
| 115 | + shell: bash -el {0} |
| 116 | + steps: |
| 117 | + - uses: actions/checkout@v4 |
| 118 | + |
| 119 | + # Cache the conda environment (using a key for Ubuntu and Python 3.13) |
| 120 | + - name: Cache conda environment |
| 121 | + uses: actions/cache@v4 |
| 122 | + with: |
| 123 | + path: | |
| 124 | + ~/conda_pkgs_dir |
| 125 | + ~/.conda |
| 126 | + ~/miniconda3/envs |
| 127 | + key: conda-ubuntu-latest-3.13-${{ hashFiles('dev_environment.yml') }} |
| 128 | + restore-keys: | |
| 129 | + conda-ubuntu-latest-3.13- |
| 130 | + conda-ubuntu-latest- |
| 131 | + |
| 132 | + - name: Set up Miniconda |
| 133 | + uses: conda-incubator/setup-miniconda@v3 |
| 134 | + with: |
| 135 | + miniconda-version: "latest" |
| 136 | + auto-update-conda: true |
| 137 | + python-version: 3.13 |
| 138 | + channels: conda-forge,defaults |
| 139 | + activate-environment: conin_dev |
| 140 | + environment-file: dev_environment.yml |
| 141 | + use-mamba: true |
| 142 | + |
| 143 | + - name: Configure solver - none |
| 144 | + if: ${{ matrix.solver == 'none' }} |
| 145 | + run: | |
| 146 | + pip uninstall highspy || true |
| 147 | + conda uninstall -y glpk || true |
| 148 | +
|
| 149 | + - name: Configure solver - glpk |
| 150 | + if: ${{ matrix.solver == 'glpk' }} |
| 151 | + run: | |
| 152 | + pip uninstall highspy || true |
| 153 | + conda install -y glpk |
| 154 | +
|
| 155 | + - name: Configure solver - highs |
| 156 | + if: ${{ matrix.solver == 'highs' }} |
| 157 | + run: | |
| 158 | + pip install highspy |
| 159 | + conda uninstall -y glpk || true |
| 160 | +
|
| 161 | + - name: Install package |
| 162 | + run: | |
| 163 | + python -m highspy || true |
| 164 | + which glpsol || true |
| 165 | + pip install -e . |
| 166 | +
|
| 167 | + - name: Test with pytest & coverage |
| 168 | + run: pytest -r s -vv conin |
| 169 | + |
| 170 | + coverage: |
| 171 | + needs: tests |
| 172 | + runs-on: ubuntu-latest |
| 173 | + defaults: |
| 174 | + run: |
| 175 | + shell: bash -el {0} |
| 176 | + steps: |
| 177 | + - uses: actions/checkout@v4 |
| 178 | + |
| 179 | + # Cache the conda environment (using a key for Ubuntu and Python 3.13) |
| 180 | + - name: Cache conda environment |
| 181 | + uses: actions/cache@v4 |
| 182 | + with: |
| 183 | + path: | |
| 184 | + ~/conda_pkgs_dir |
| 185 | + ~/.conda |
| 186 | + ~/miniconda3/envs |
| 187 | + key: conda-ubuntu-latest-3.13-${{ hashFiles('dev_environment.yml') }} |
| 188 | + restore-keys: | |
| 189 | + conda-ubuntu-latest-3.13- |
| 190 | + conda-ubuntu-latest- |
| 191 | + |
| 192 | + - name: Set up Miniconda |
| 193 | + uses: conda-incubator/setup-miniconda@v3 |
| 194 | + with: |
| 195 | + miniconda-version: "latest" |
| 196 | + auto-update-conda: true |
| 197 | + python-version: 3.13 |
| 198 | + channels: conda-forge,defaults |
| 199 | + activate-environment: conin_dev |
| 200 | + environment-file: dev_environment.yml |
| 201 | + use-mamba: true |
| 202 | + |
| 203 | + - name: Install package |
67 | 204 | run: | |
68 | | - pip install pgmpy |
69 | | - pytest -v . |
| 205 | + pip install -e . |
| 206 | + conda install pytorch |
| 207 | + conda install cpuonly |
| 208 | + pip install pgmpy |
| 209 | +
|
| 210 | + - name: Test with pytest & coverage |
| 211 | + run: pytest --cov --cov-branch --cov-report=xml --junitxml=junit.xml -vv conin |
| 212 | + |
| 213 | + - name: Upload test results to Codecov |
| 214 | + uses: codecov/codecov-action@v4 |
| 215 | + with: |
| 216 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 217 | + files: ./coverage.xml |
| 218 | + |
0 commit comments