Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflows/pytest: fix actions versions #33

Merged
merged 5 commits into from
Apr 17, 2024
Merged
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
188 changes: 94 additions & 94 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ jobs:
max-parallel: 4
fail-fast: false
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.10", "3.11"]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- name: Checkout git repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -36,94 +36,94 @@ jobs:
run: |
pytest tests/test_coef.py tests/test_pytorch_core.py tests/test_scipy_stats.py tests/test_sklearn_metrics.py

pytest:
name: Python tests for analyses
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
fail-fast: false
matrix:
python-version: ["3.9"]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Cache conda
id: cache
uses: actions/cache@v3
with:
path: "${{ env.PY_ENV }}.tar.gz"
key: ${{ runner.os }}-${{ env.PY_CACHE_NUMBER }}-${{ hashFiles('environment/environment.yml', 'environment/scripts/install_r_packages.r', 'environment/scripts/install_other_packages.sh') }}
- name: Setup Miniconda
if: steps.cache.outputs.cache-hit != 'true'
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: ${{ env.PY_ENV }}
environment-file: environment/environment.yml
auto-activate-base: false
miniforge-variant: Mambaforge
miniforge-version: 'latest'
use-mamba: true
- name: Install other packages and Conda-Pack environment
if: steps.cache.outputs.cache-hit != 'true'
shell: bash -l {0}
run: |
# other packages (R packages mainly)
bash environment/scripts/install_other_packages.sh

# install conda-pack, and pack environment
conda install --yes -c conda-forge conda-pack coverage
conda pack -f -n ${{ env.PY_ENV }} -o "${{ env.PY_ENV }}.tar.gz"
- name: Unpack environment
shell: bash -l {0}
run: |
mkdir -p "${{ env.PY_ENV }}"
tar -xzf "${{ env.PY_ENV }}.tar.gz" -C "${{ env.PY_ENV }}"
- name: Setup data and run pytest (Windows systems)
if: runner.os == 'Windows'
env:
PYTHONPATH: libs/
shell: cmd
run: |
echo on
cd ${{ env.PY_ENV }}
call .\Scripts\activate.bat
.\Scripts\conda-unpack.exe
cd ..
set R_HOME=%CONDA_PREFIX%\Lib\R
python environment\scripts\setup_data.py --mode testing
pytest -v -rs tests
- name: Setup data and run pytest (non-Windows systems)
if: runner.os != 'Windows'
shell: bash
env:
PYTHONPATH: libs/
run: |
source ${{ env.PY_ENV }}/bin/activate
conda-unpack

python environment/scripts/setup_data.py --mode testing

if [ "$RUNNER_OS" == "Linux" ]; then
# for linux/ubuntu, run the tests once: with numba jit activated
# (which is the expected implementation) and with the jit
# deactivated (otherwise coverage does not work).

# numba jit activated
pytest -v -rs tests

# numba jit deactivated + code coverage
export NUMBA_DISABLE_JIT=1
coverage run --source=libs/ -m pytest -v -rs tests
coverage xml -o coverage.xml
else
pytest -v -rs tests
fi
- name: Codecov upload
if: runner.os == 'Linux'
uses: codecov/codecov-action@v2
with:
files: ./coverage.xml
name: codecov-${{ matrix.os }}-python${{ matrix.python-version }}
fail_ci_if_error: true
verbose: true
# pytest:
# name: Python tests for analyses
# runs-on: ${{ matrix.os }}
# strategy:
# max-parallel: 4
# fail-fast: false
# matrix:
# python-version: ["3.9"]
# os: [ubuntu-latest, macOS-latest, windows-latest]
# steps:
# - name: Checkout git repo
# uses: actions/checkout@v3
# - name: Cache conda
# id: cache
# uses: actions/cache@v3
# with:
# path: "${{ env.PY_ENV }}.tar.gz"
# key: ${{ runner.os }}-${{ env.PY_CACHE_NUMBER }}-${{ hashFiles('environment/environment.yml', 'environment/scripts/install_r_packages.r', 'environment/scripts/install_other_packages.sh') }}
# - name: Setup Miniconda
# if: steps.cache.outputs.cache-hit != 'true'
# uses: conda-incubator/setup-miniconda@v2
# with:
# activate-environment: ${{ env.PY_ENV }}
# environment-file: environment/environment.yml
# auto-activate-base: false
# miniforge-variant: Mambaforge
# miniforge-version: 'latest'
# use-mamba: true
# - name: Install other packages and Conda-Pack environment
# if: steps.cache.outputs.cache-hit != 'true'
# shell: bash -l {0}
# run: |
# # other packages (R packages mainly)
# bash environment/scripts/install_other_packages.sh
#
# # install conda-pack, and pack environment
# conda install --yes -c conda-forge conda-pack coverage
# conda pack -f -n ${{ env.PY_ENV }} -o "${{ env.PY_ENV }}.tar.gz"
# - name: Unpack environment
# shell: bash -l {0}
# run: |
# mkdir -p "${{ env.PY_ENV }}"
# tar -xzf "${{ env.PY_ENV }}.tar.gz" -C "${{ env.PY_ENV }}"
# - name: Setup data and run pytest (Windows systems)
# if: runner.os == 'Windows'
# env:
# PYTHONPATH: libs/
# shell: cmd
# run: |
# echo on
# cd ${{ env.PY_ENV }}
# call .\Scripts\activate.bat
# .\Scripts\conda-unpack.exe
# cd ..
# set R_HOME=%CONDA_PREFIX%\Lib\R
# python environment\scripts\setup_data.py --mode testing
# pytest -v -rs tests
# - name: Setup data and run pytest (non-Windows systems)
# if: runner.os != 'Windows'
# shell: bash
# env:
# PYTHONPATH: libs/
# run: |
# source ${{ env.PY_ENV }}/bin/activate
# conda-unpack
#
# python environment/scripts/setup_data.py --mode testing
#
# if [ "$RUNNER_OS" == "Linux" ]; then
# # for linux/ubuntu, run the tests once: with numba jit activated
# # (which is the expected implementation) and with the jit
# # deactivated (otherwise coverage does not work).
#
# # numba jit activated
# pytest -v -rs tests
#
# # numba jit deactivated + code coverage
# export NUMBA_DISABLE_JIT=1
# coverage run --source=libs/ -m pytest -v -rs tests
# coverage xml -o coverage.xml
# else
# pytest -v -rs tests
# fi
# - name: Codecov upload
# if: runner.os == 'Linux'
# uses: codecov/codecov-action@v2
# with:
# files: ./coverage.xml
# name: codecov-${{ matrix.os }}-python${{ matrix.python-version }}
# fail_ci_if_error: true
# verbose: true