Skip to content

Commit a99e999

Browse files
authored
Merge pull request #153 from sandialabs/github_actions
Integrating github actions into a single workflow
2 parents cfa1ca5 + 5595952 commit a99e999

File tree

7 files changed

+170
-260
lines changed

7 files changed

+170
-260
lines changed

.github/workflows/coverage.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

.github/workflows/format.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/pytest.yml

Lines changed: 167 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
name: Pytest Tests
1+
name: Github CI
22

33
on:
4-
workflow_run:
5-
workflows: ["Quick Tests"]
6-
types:
7-
- completed
8-
branches:
9-
- main
104
push:
115
branches:
126
- main
@@ -15,24 +9,61 @@ on:
159
- main
1610

1711
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+
1853
tests:
54+
needs: format-check
1955
strategy:
2056
fail-fast: false # If one job fails, the rest will still run
2157
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"]
2460
runs-on: ${{ matrix.os }}
2561
defaults:
2662
run:
2763
shell: bash -el {0}
2864
steps:
2965
- uses: actions/checkout@v4
3066

31-
- name: List files
32-
run: |
33-
pwd
34-
ls -F
35-
3667
# Cache the conda environment
3768
- name: Cache conda environment
3869
uses: actions/cache@v4
@@ -60,10 +91,128 @@ jobs:
6091
- name: Install package
6192
run: pip install -e .
6293

94+
- name: Install pgmpy
95+
run: |
96+
conda install pytorch
97+
conda install cpuonly
98+
pip install pgmpy
99+
python -m pgmpy || true
100+
63101
- name: Test with pytest
64-
run: pytest -v
102+
run: |
103+
pytest -r s -vv conin
65104
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
67204
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

Comments
 (0)