Skip to content

Commit 3881776

Browse files
authored
Merge pull request #25 from sandialabs/3_github_actions
Reworking tests
2 parents e329aea + fcc8e43 commit 3881776

File tree

4 files changed

+160
-112
lines changed

4 files changed

+160
-112
lines changed

.github/workflows/coverage.yml

Lines changed: 0 additions & 57 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: 160 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Pytest Tests
1+
name: Github CI
22

33
on:
44
push:
@@ -9,12 +9,54 @@ on:
99
- main
1010

1111
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+
1253
tests:
54+
needs: format-check
1355
strategy:
1456
fail-fast: false # If one job fails, the rest will still run
1557
matrix:
16-
os: [ubuntu-latest] # Omitting macos-latest because it is 10x more expensive
17-
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"]
1860
runs-on: ${{ matrix.os }}
1961
defaults:
2062
run:
@@ -30,7 +72,7 @@ jobs:
3072
~/conda_pkgs_dir
3173
~/.conda
3274
~/miniconda3/envs
33-
key: conda-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('dev_environment.yml') }}
75+
key: conda-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('dev_environment.yml', '*/dev_environment.yml') }}
3476
restore-keys: |
3577
conda-${{ matrix.os }}-${{ matrix.python-version }}-
3678
conda-${{ matrix.os }}-
@@ -42,13 +84,125 @@ jobs:
4284
auto-update-conda: true
4385
python-version: ${{ matrix.python-version }}
4486
channels: conda-forge,defaults
45-
activate-environment: conin_dev
87+
activate-environment: or_topas_dev
4688
environment-file: dev_environment.yml
4789
use-mamba: true
4890

4991
- name: Install package
5092
run: pip install -e .
5193

5294
- name: Test with pytest
53-
run: pytest -v
95+
run: |
96+
pytest -r s -vv or_topas
97+
98+
mip-solver-tests:
99+
needs: format-check
100+
strategy:
101+
fail-fast: false # If one job fails, the rest will still run
102+
matrix:
103+
os: [ubuntu-latest] # Omitting macos-latest because it is expensive
104+
solver: ["glpk"] #["highs", "glpk", "none"]
105+
runs-on: ${{ matrix.os }}
106+
defaults:
107+
run:
108+
shell: bash -el {0}
109+
steps:
110+
- uses: actions/checkout@v4
111+
112+
# Cache the conda environment (using a key for Ubuntu and Python 3.13)
113+
- name: Cache conda environment
114+
uses: actions/cache@v4
115+
with:
116+
path: |
117+
~/conda_pkgs_dir
118+
~/.conda
119+
~/miniconda3/envs
120+
key: conda-ubuntu-latest-3.13-${{ hashFiles('dev_environment.yml') }}
121+
restore-keys: |
122+
conda-ubuntu-latest-3.13-
123+
conda-ubuntu-latest-
124+
125+
- name: Set up Miniconda
126+
uses: conda-incubator/setup-miniconda@v3
127+
with:
128+
miniconda-version: "latest"
129+
auto-update-conda: true
130+
python-version: 3.13
131+
channels: conda-forge,defaults
132+
activate-environment: or_topas_dev
133+
environment-file: dev_environment.yml
134+
use-mamba: true
135+
136+
- name: Configure solver - none
137+
if: ${{ matrix.solver == 'none' }}
138+
run: |
139+
pip uninstall highspy || true
140+
conda uninstall -y glpk || true
141+
142+
- name: Configure solver - glpk
143+
if: ${{ matrix.solver == 'glpk' }}
144+
run: |
145+
pip uninstall highspy || true
146+
conda install -y glpk
147+
148+
- name: Configure solver - highs
149+
if: ${{ matrix.solver == 'highs' }}
150+
run: |
151+
pip install highspy
152+
conda uninstall -y glpk || true
153+
154+
- name: Install package
155+
run: |
156+
python -m highspy || true
157+
which glpsol || true
158+
pip install -e .
159+
160+
- name: Test with pytest & coverage
161+
run: pytest -r s -vv or_topas
162+
163+
coverage:
164+
needs: tests
165+
runs-on: ubuntu-latest
166+
defaults:
167+
run:
168+
shell: bash -el {0}
169+
steps:
170+
- uses: actions/checkout@v4
171+
172+
# Cache the conda environment (using a key for Ubuntu and Python 3.13)
173+
- name: Cache conda environment
174+
uses: actions/cache@v4
175+
with:
176+
path: |
177+
~/conda_pkgs_dir
178+
~/.conda
179+
~/miniconda3/envs
180+
key: conda-ubuntu-latest-3.13-${{ hashFiles('dev_environment.yml') }}
181+
restore-keys: |
182+
conda-ubuntu-latest-3.13-
183+
conda-ubuntu-latest-
184+
185+
- name: Set up Miniconda
186+
uses: conda-incubator/setup-miniconda@v3
187+
with:
188+
miniconda-version: "latest"
189+
auto-update-conda: true
190+
python-version: 3.13
191+
channels: conda-forge,defaults
192+
activate-environment: or_topas_dev
193+
environment-file: dev_environment.yml
194+
use-mamba: true
195+
196+
- name: Install package
197+
run: |
198+
pip install -e .
199+
200+
- name: Test with pytest & coverage
201+
run: pytest --cov --cov-branch --cov-report=xml --junitxml=junit.xml -vv or_topas
202+
203+
- name: Upload test results to Codecov
204+
uses: codecov/codecov-action@v4
205+
with:
206+
token: ${{ secrets.CODECOV_TOKEN }}
207+
files: ./coverage.xml
54208

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[![Pytest Tests](https://github.com/sandialabs/or_topas/actions/workflows/pytest.yml/badge.svg?branch=main)](https://github.com/sandialabs/or_topas/actions/workflows/pytest.yml?query=branch%3Amain)
2-
[![Coverage Status](https://github.com/sandialabs/or_topas/actions/workflows/coverage.yml/badge.svg?branch=main)](https://github.com/sandialabs/or_topas/actions/workflows/coverage.yml?query=branch%3Amain)
32
[![codecov](https://codecov.io/gh/sandialabs/or_topas/branch/main/graph/badge.svg)](https://codecov.io/gh/sandialabs/or_topas)
43
[![Documentation Status](https://readthedocs.org/projects/or-topas/badge/?version=latest)](https://or-topas.readthedocs.org/en/latest/)
54
[![GitHub contributors](https://img.shields.io/github/contributors/sandialabs/or_topas.svg)](https://github.com/sandialabs/or_topas/graphs/contributors)

0 commit comments

Comments
 (0)