-
Notifications
You must be signed in to change notification settings - Fork 18
120 lines (107 loc) · 5.21 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Continuous Integration
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
# run this every week at 12 noon on Monday
- cron: '0 12 * * 1'
jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", 3.11, 3.12]
# macos13 runs on until and macos14 now runs on arm64
os: [ubuntu-20.04, macos-latest, macos-13]
exclude:
# Python 3.7 is not available on M1 Mac homebrew
- os: macos-latest
python-version: 3.7
include:
- os: ubuntu-20.04
INSTALL_DEPS: sudo apt-get update && sudo apt-get -y install gfortran-7 swig libopenmpi-dev openmpi-bin libopenblas-dev && sudo ln -s `which gfortran-7` /usr/local/bin/gfortran
- os: macos-latest
# Different versions of homebrew put the gfortran in different
INSTALL_DEPS: >
brew update-reset
&& HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install gcc swig libomp open-mpi openblas
&& COSMOSIS_GCC_VER=$(brew list --versions gcc | awk '{print $2}' | cut -d. -f1)
&& GFORTRAN_PATH1=/usr/local/bin/gfortran
&& GFORTRAN_PATH2=/usr/local/bin/gfortran-${COSMOSIS_GCC_VER}
&& GFORTRAN_PATH3=/opt/homebrew/bin/gfortran
&& GFORTRAN_PATH4=/opt/homebrew/bin/gfortran-${COSMOSIS_GCC_VER}
&& if ! which -s gfortran
; then if [ -f $GFORTRAN_PATH2 ]; then ln -s $GFORTRAN_PATH2 $GFORTRAN_PATH1; echo Linking gfortran from /usr/local
; elif [ -f $GFORTRAN_PATH4 ]; then ln -s $GFORTRAN_PATH4 $GFORTRAN_PATH3; echo Linking gfortran from /opt/homebrew
; else echo "gfortran not found" && exit 1
; fi
; fi
&& echo "gfortran now at $(which -a gfortran)"
- os: macos-13
# Different versions of homebrew put the gfortran in different
INSTALL_DEPS: >
brew update-reset
&& HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install gcc swig libomp open-mpi openblas
&& COSMOSIS_GCC_VER=$(brew list --versions gcc | awk '{print $2}' | cut -d. -f1)
&& GFORTRAN_PATH1=/usr/local/bin/gfortran
&& GFORTRAN_PATH2=/usr/local/bin/gfortran-${COSMOSIS_GCC_VER}
&& GFORTRAN_PATH3=/opt/homebrew/bin/gfortran
&& GFORTRAN_PATH4=/opt/homebrew/bin/gfortran-${COSMOSIS_GCC_VER}
&& if ! which -s gfortran
; then if [ -f $GFORTRAN_PATH2 ]; then ln -s $GFORTRAN_PATH2 $GFORTRAN_PATH1; echo Linking gfortran from /usr/local
; elif [ -f $GFORTRAN_PATH4 ]; then ln -s $GFORTRAN_PATH4 $GFORTRAN_PATH3; echo Linking gfortran from /opt/homebrew
; else echo "gfortran not found" && exit 1
; fi
; fi
&& echo "gfortran now at $(which -a gfortran)"
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies
cache-dependency-path: 'setup.py'
- name: Install dependencies
run: ${{ matrix.INSTALL_DEPS }}
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
if [[ "${{ matrix.os }}" == "macos-13" || "${{ matrix.python-version }}" == '3.7' || "${{ matrix.python-version}}" == '3.8' ]]; then
pip install "numpy<2"
else
pip install "numpy>=2"
fi
pip install -vv .
pip install --no-binary=mpi4py mpi4py astropy pytest pytest-cov getdist derivative numdifftools
- name: Install PocoMC
if: matrix.python-version != '3.7'
run: |
pip install pocomc==1.2.6
- name: Test nautilus alone
if: (matrix.python-version == '3.12' || matrix.python-version == '3.11' || matrix.python-version =='3.10') && (matrix.os == 'macos-13')
run: |
# On some systems it seems like nautilus runs out of
# memory when run with the full test suite.
python cosmosis/test/test_samplers.py test_nautilus
- name: Test with pytest
run: |
cosmosis --version
if [[ "${{ matrix.os }}" == 'macos-13' && ("${{ matrix.python-version }}" == '3.10' || "${{ matrix.python-version }}" == '3.11' || "${{ matrix.python-version }}" == '3.12' ) ]]; then
export SKIP_NAUTILUS=1
fi
mkdir tmp && cd tmp && pytest --pyargs cosmosis --cov cosmosis --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
if: matrix.python-version == '3.9' && matrix.os == 'ubuntu-20.04'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}