Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JCGoran committed Mar 13, 2024
1 parent a31f17d commit c7f38da
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 122 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,24 @@ jobs:
deploy-book:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

# Install dependencies
- name: Set up Python 3.9
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: |
python3 -m pip install pdoc matplotlib numpy scipy wheel setuptools poetry pytest
python3 -m pip install .
python3 -m pip install .[docs,test]
# Build the site
- name: Build the site
run: |
bash generate_docs.sh -t
bash scripts/generate_docs.sh -t
# If we've pushed to master, push the book's HTML to github-pages
- if: ${{ github.ref == 'refs/heads/master' }}
Expand Down
165 changes: 55 additions & 110 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,69 +21,47 @@ jobs:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
#----------------------------------------------
# poetry setup
#----------------------------------------------
- uses: snok/install-poetry@v1
with:
version: 1.4.2
virtualenvs-create: true
virtualenvs-in-project: true
- name: cache deps
id: cache-deps
uses: actions/cache@v2
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}
- run: poetry install --extras interfaces --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'
- run: poetry install --no-interaction
#----------------------------------------------
# install and run linters
#----------------------------------------------
- run: sh check_syntax.sh
python-version: '3.9'

- run: |
python -m pip install .[docs,test]
- run: bash scripts/check_syntax.sh

test:
name: Tests of general module
needs: linting
strategy:
fail-fast: true
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.7", "3.8", "3.9" ]
python-version: [ "3.7", "3.9", "3.12" ]

runs-on: ${{ matrix.os }}
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
#----------------------------------------------
# poetry setup
#----------------------------------------------
- uses: snok/install-poetry@v1
with:
version: 1.4.2
virtualenvs-create: true
virtualenvs-in-project: true
- name: cache deps
id: cache-deps
uses: actions/cache@v2
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}
- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'
- run: poetry install --no-interaction

- run: |
python -m pip install .[test]
- name: Run tests
run: sh check_coverage.sh
run: bash scripts/check_coverage.sh

- name: Upload coverage
if: ${{ matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v1
Expand All @@ -103,31 +81,20 @@ jobs:
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v2
#----------------------------------------------
# poetry setup
#----------------------------------------------
- uses: snok/install-poetry@v1
with:
version: 1.4.2
virtualenvs-create: true
virtualenvs-in-project: true
- name: cache deps
id: cache-deps
uses: actions/cache@v2
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}
- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'
- run: poetry install --no-interaction
- name: Install CLASS
python-version: '3.9'

- name: Install project and CLASS
run: |
poetry install --no-interaction
poetry run pip install Cython
git clone --depth 1 --branch feature/conda https://github.com/JCGoran/class_public && cd class_public && poetry run make classy && cd -
python -m pip install .[test]
python -m pip install Cython
git clone --depth 1 --branch feature/conda https://github.com/JCGoran/class_public && cd class_public && make classy && cd -
- name: Run CLASS tests
run: poetry run pytest -v tests/test_classy_interfaces.py
run: python -m pytest -v tests/test_classy_interfaces.py

coffe:
name: Tests for COFFE interfaces
Expand All @@ -136,32 +103,21 @@ jobs:
strategy:
fail-fast: true
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v2
#----------------------------------------------
# poetry setup
#----------------------------------------------
- uses: snok/install-poetry@v1
with:
version: 1.4.2
virtualenvs-create: true
virtualenvs-in-project: true
- name: cache deps
id: cache-deps
uses: actions/cache@v2
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}
- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'
- run: poetry install --no-interaction
- name: Install COFFE
run: poetry install --extras coffe --no-interaction
python-version: '3.9'

- name: Install project and COFFE
- run: |
python -m pip install .[test]
python -m pip install coffe
- name: Run COFFE tests
run: poetry run pytest -v tests/test_coffe_interfaces.py
run: python -m pytest -v tests/test_coffe_interfaces.py

camb:
name: Tests for CAMB interfaces
Expand All @@ -170,29 +126,18 @@ jobs:
strategy:
fail-fast: true
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v2
#----------------------------------------------
# poetry setup
#----------------------------------------------
- uses: snok/install-poetry@v1
with:
version: 1.4.2
virtualenvs-create: true
virtualenvs-in-project: true
- name: cache deps
id: cache-deps
uses: actions/cache@v2
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}
- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'
- run: poetry install --no-interaction
python-version: '3.9'

- name: Install CAMB
run: poetry install --extras camb --no-interaction
run: |
python -m pip install .[test]
python -m pip install camb
- name: Run CAMB tests
run: poetry run pytest -v tests/test_camb_interfaces.py
run: python -m pytest -v tests/test_camb_interfaces.py
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ docs = [
"pdoc",
"pydocstyle",
]
dev = [
"black",
"pylint",
"mypy",
]

[project.urls]
documentation = "https://jcgoran.github.io/fitk/"
repository = "https://github.com/JCGoran/fitk/"

[tool.poetry.dev-dependencies]
black = "*"
pylint = "*"
mypy = "*"
jupyterlab = "*"
vermin = "*"
coverage = "*"
python-lsp-server = "*"
pydocstyle = "*"

Expand Down
3 changes: 3 additions & 0 deletions scripts/check_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
set -eux

check_coverage(){
this_dir="$(cd "$(dirname "$0")"; pwd -P)"
excluded='not __init__.py and not interfaces'
cd "${this_dir}/.."
if [ "${1:-}" = '-i' ] || [ "${1:-}" = '--images' ]
then
python -m pytest --mpl --doctest-modules --mpl-generate-summary=html -k "${excluded}" --cov=python/fitk/ --cov=tests/ --cov-report=xml tests/ python/fitk/
Expand All @@ -14,6 +16,7 @@ check_coverage(){
fi
python -m coverage html
python -m coverage report
cd - > /dev/null
}

check_coverage "${1:-}"
Expand Down
3 changes: 3 additions & 0 deletions scripts/check_syntax.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ set -eux

validate(){
modules='python/fitk/ tests/'
this_dir="$(cd "$(dirname "$0")"; pwd -P)"
cd "${this_dir}/.."
python -m black --check ${modules}
# the E0611 is because Pylint detects some native modules (like
# `collections.abc.Collection`) as missing on some machines for one reason
# or another
python -m pylint --disable=W,R,C,E0611 ${modules}
cd - > /dev/null
}

validate
Expand Down
3 changes: 3 additions & 0 deletions scripts/fix_formatting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ set -eux

fix(){
modules='python/fitk/ tests/'
this_dir="$(cd "$(dirname "$0")"; pwd -P)"
cd "${this_dir}/.."
python -m black ${modules}
cd - > /dev/null
}

fix
Expand Down
4 changes: 4 additions & 0 deletions scripts/generate_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

set -eu

this_dir="$(cd "$(dirname "$0")"; pwd -P)"
cd "${this_dir}/.."
# the name of the package
PACKAGE='fitk'
export PACKAGE
Expand Down Expand Up @@ -61,4 +63,6 @@ else
parse_docs ./docs
fi

cd - > /dev/null

set +eu
4 changes: 4 additions & 0 deletions scripts/generate_test_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

set -eux

this_dir="$(cd "$(dirname "$0")"; pwd -P)"
cd "${this_dir}/.."
image_directory='tests/data_input/'
modules="${1:-tests/test_graphics.py}"

python -m pytest --mpl-generate-path="${image_directory}" "${modules}"

cd - > /dev/null

set +eux

0 comments on commit c7f38da

Please sign in to comment.