Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 31 additions & 27 deletions .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
name: Run Python Tests
name: Run python tests

on:
workflow_dispatch:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
name: Test (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
env:
MPLBACKEND: Agg
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v3
- uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
miniforge-version: latest
use-mamba: true
activate-environment: paretobench
- name: Set cache date
python-version: ${{ matrix.python-version }}
- name: Install package and dependencies
run: |
echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
echo "CACHE_NUMBER=1" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs
key: conda-${{ hashFiles('environment.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
id: cache
- name: Update environment
run: mamba env update -n paretobench -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Install our package
shell: bash -l {0}
run: |
pip install -e .
- name: Run pytest
shell: bash -l {0}
pip install --upgrade pip
pip install ".[test]"
- name: Run the tests (Linux/macOS)
if: runner.os != 'Windows'
run: |
echo -e '## Pytest Results\n\n' >> "$GITHUB_STEP_SUMMARY"
echo -e '```' >> "$GITHUB_STEP_SUMMARY"
pytest -v -cov=src/ 2>&1 tests | tee -a "$GITHUB_STEP_SUMMARY"
pytest -v --cov=beamfit/ tests 2>&1 | tee -a "$GITHUB_STEP_SUMMARY"
echo -e '```' >> "$GITHUB_STEP_SUMMARY"
- name: Run the tests (Windows)
if: runner.os == 'Windows'
shell: powershell
run: |
"## Pytest Results`n`n" | Add-Content -Path $env:GITHUB_STEP_SUMMARY
'```' | Add-Content -Path $env:GITHUB_STEP_SUMMARY
pytest -v tests 2>&1 | Tee-Object -FilePath temp_output.txt
Get-Content temp_output.txt | Add-Content -Path $env:GITHUB_STEP_SUMMARY
'```' | Add-Content -Path $env:GITHUB_STEP_SUMMARY
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ pip install paretobench
```
conda create env -f environment.yml
```
2) Install the package in editing mode
2) Install the package in editing mode (with dependencies required for running tests)
```
pip install -e .
pip install -e .[test]
```

## Usage
Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: paretobench
dependencies:
- python=3.11
- pytest
- pip
- pip:
- pre-commit
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ dependencies = [
Homepage = "https://github.com/electronsandstuff/ParetoBench"
Repository = "https://github.com/electronsandstuff/ParetoBench"

[project.optional-dependencies]
test = [
"pytest",
"pytest-cov",
"xopt",
]

[tool.ruff]
line-length = 120
indent-width = 4
Expand Down
Loading