-
Notifications
You must be signed in to change notification settings - Fork 127
170 lines (143 loc) · 5.65 KB
/
tests.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Cobaya Tests
# for the moment only runs on "action* branches". Coverage/pypi not yet set up.
on: [ push, pull_request ]
env:
COBAYA_INSTALL_SKIP_BASE: planck_2015,CamSpec2021,2018_highl_CamSpec,unbinned,keck
COBAYA_PACKAGES_PATH: ../packages
jobs:
should_run:
# only run on pushes that are not also part of PR
runs-on: ubuntu-latest
outputs:
run_tests: github.event_name == 'push' || ${{ steps.check.outputs.run_tests }}
steps:
- name: Check if tests should run
id: check
if: github.event_name == 'push'
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
head: `${context.repo.owner}:${context.ref.replace('refs/heads/', '')}`,
state: 'open'
});
const shouldRun = prs.length === 0;
core.setOutput('run_tests', shouldRun ? 'true' : 'false');
tests:
needs: should_run
runs-on: ${{ matrix.os }}
if: github.event_name == 'pull_request' || needs.should_run.outputs.run_tests == 'true'
strategy:
fail-fast: false
matrix:
include:
- name: "Anaconda Python (flake8, no numba)"
os: ubuntu-latest
pydist: "ANACONDA"
cobaya_skip: classy,polychord
- name: "Latest Python 3.x (with polychord)"
os: ubuntu-latest
python-version: 3.x
mpi: openmpi
cobaya_skip: classy,polychord
- name: "OS X Python 3.8 (with classy)"
os: macos-latest
python-version: 3.8
mpi: openmpi
cobaya_skip: polychord
- name: "Windows Python 3.12"
os: windows-latest
python-version: 3.12
mpi: intelmpi
cobaya_skip: classy,polychord
steps:
- name: Set COBAYA_INSTALL_SKIP
shell: bash
run: echo "COBAYA_INSTALL_SKIP=$COBAYA_INSTALL_SKIP_BASE,${{ matrix.cobaya_skip }}" >> $GITHUB_ENV
- run: ln -s $(which gfortran-14) /usr/local/bin/gfortran
if: matrix.os == 'macos-latest'
- run: |
gfortran --version
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
if: matrix.pydist != 'ANACONDA'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up Miniconda
if: matrix.pydist == 'ANACONDA'
uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: false
activate-environment: tests-environment
environment-file: tests-environment.yml
- name: flake8 Lint
if: matrix.pydist == 'ANACONDA'
shell: bash -el {0}
run: |
flake8 cobaya --max-line-length 90 --select=E713,E704,E703,E714,E10,E11,E20,E22,E23,E25,E27,E301,E302,E304,E9,F405,F406,F5,F6,F7,F8,W1,W2,W3,W6 --show-source --statistics
- name: Install dependencies (pip)
if: matrix.pydist != 'ANACONDA'
run: |
pip install -r requirements.txt pytest-xdist pytest-cov flaky matplotlib coverage iminuit numba camb
- name: Install mpi
if: matrix.pydist != 'ANACONDA' && matrix.os != 'windows-latest'
uses: mpi4py/setup-mpi@v1
with:
mpi: ${{ matrix.mpi }}
- name: Install mpi4py
if: matrix.pydist != 'ANACONDA' && matrix.os != 'windows-latest'
run: |
pip install mpi4py -i https://pypi.anaconda.org/mpi4py/simple
# - name: Cache dependencies
# uses: actions/cache@v4
# with:
# path: |
# ${{ env.COBAYA_PACKAGES_PATH }}/data/
# key: ${{ env.COBAYA_INSTALL_SKIP }}
# enableCrossOsArchive: true
- name: Run cobaya install and tests
shell: bash -el {0}
run: |
coverage run --parallel-mode -m cobaya.install polychord --debug
coverage run --parallel-mode -m pytest tests/ -n auto -k "not cosmo" --skip-not-installed --no-flaky-report
coverage run --parallel-mode -m cobaya.install cosmo-tests --no-progress-bars --debug --skip-global
pytest tests/ --cov -vv -s -k "cosmo" -n 2 --skip-not-installed --no-flaky-report
- name: Run MPI tests
if: matrix.os != 'windows-latest'
shell: bash -el {0}
run: |
mpiexec -np 2 --oversubscribe coverage run --parallel-mode -m pytest -m mpi tests/ --no-flaky-report
- name: Run external likelihood tests
shell: bash -el {0}
run: |
git clone --depth=1 https://github.com/CobayaSampler/example_external_likelihood
pip install ./example_external_likelihood --quiet
coverage run --parallel-mode -m unittest test_package.tests.test
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
deploy:
needs: tests
runs-on: ubuntu-latest
if: github.repository_owner == 'CobayaSampler' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U build twine
- name: Build package
run: python -m build --sdist
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1