-
Notifications
You must be signed in to change notification settings - Fork 216
140 lines (137 loc) · 5.6 KB
/
tests-workflow.yaml
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
name: Tests
on:
push:
pull_request:
schedule:
- cron: '0 6 1 * *'
jobs:
pytest:
name: Build and check
strategy:
fail-fast: false
matrix:
config:
- py310
- py311
- py312
- py313
runner:
- ubuntu-latest
- macos-14
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set dependencies
id: dependencies
run: |
source ci/deps/${{ matrix.config }}.sh
echo "CI_PYTHON_VERSION=${CI_PYTHON_VERSION}" >> $GITHUB_ENV
echo "CI_PANDAS_VERSION=${CI_PANDAS_VERSION}" >> $GITHUB_ENV
echo "CI_NUMPY_VERSION=${CI_NUMPY_VERSION}" >> $GITHUB_ENV
echo "CI_SKLEARN_VERSION=${CI_SKLEARN_VERSION}" >> $GITHUB_ENV
echo "CI_NO_SLOW=${CI_NO_SLOW}" >> $GITHUB_ENV
echo "CONDA_PKGS_DIRS=${{ runner.temp }}/conda_pkgs_dir" >> $GITHUB_ENV
echo "py_version=$(cut -d'.' -f 1-2 <<< ${CI_PYTHON_VERSION})" >> $GITHUB_OUTPUT
echo "requirements=ci/deps/${{ matrix.config }}.sh" >> $GITHUB_OUTPUT
- name: Cache downloaded packages
uses: actions/cache@v4
with:
path: ${{ env.CONDA_PKGS_DIRS }}
key: ${{ runner.os }}-${{ runner.arch }}-conda-${{ steps.dependencies.outputs.py_version }}-${{ hashFiles(steps.dependencies.outputs.requirements, 'pyproject.toml', 'ci/deps/requirements.yaml.tmpl') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-conda-${{ steps.dependencies.outputs.py_version }}-
- name: Create Conda Environment
run: |
source ci/setup_conda.sh "${{ runner.os }}" "${{ runner.arch }}" "${{ env.CONDA_PKGS_DIRS }}"
ci/setup_env.sh "${{ runner.os }}"
- name: Configure Xcode
run: |
sudo xcode-select -s "/Applications/Xcode_15.0.1.app"
if: runner.os == 'macOS'
- name: Build package
run: |
source activate sksurv-test
python -m build .
pip install --exists-action=w --pre --no-index --find-links dist/ scikit-survival
rm -fr build dist sksurv
- name: Run Tests
run: |
source activate sksurv-test
ci/run_tests.sh
- name: Check whether to create coverage report
id: coverage
run: |
if [ ${{ env.CI_NO_SLOW }} = 'false' ] && [ ${{ runner.os }} = 'Linux' ] && [ ${{ github.actor }} != 'dependabot[bot]' ]; then
echo "do=true" >> $GITHUB_OUTPUT
else
echo "do=false" >> $GITHUB_OUTPUT
fi
- name: Submit Coverage to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: coverage.xml
fail_ci_if_error: true
disable_file_fixes: true
if: steps.coverage.outputs.do == 'true'
- name: Submit Coverage to Codacy
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml
if: ${{ steps.coverage.outputs.do == 'true' && github.event_name != 'pull_request' }}
nbval:
runs-on: ubuntu-latest
name: Build and check notebooks
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set dependencies
id: dependencies
env:
DEPS_CONFIG: py312
run: |
source ci/deps/${DEPS_CONFIG}.sh
echo "CI_PYTHON_VERSION=${CI_PYTHON_VERSION}" >> $GITHUB_ENV
echo "CI_PANDAS_VERSION=${CI_PANDAS_VERSION}" >> $GITHUB_ENV
echo "CI_NUMPY_VERSION=${CI_NUMPY_VERSION}" >> $GITHUB_ENV
echo "CI_SKLEARN_VERSION=${CI_SKLEARN_VERSION}" >> $GITHUB_ENV
echo "CI_NO_SLOW=${CI_NO_SLOW}" >> $GITHUB_ENV
echo "CONDA_PKGS_DIRS=${{ runner.temp }}/conda_pkgs_dir" >> $GITHUB_ENV
echo "py_version=$(cut -d'.' -f 1-2 <<< ${CI_PYTHON_VERSION})" >> $GITHUB_OUTPUT
echo "requirements=ci/deps/${DEPS_CONFIG}.sh" >> $GITHUB_OUTPUT
- name: Cache downloaded packages
uses: actions/cache@v4
with:
path: ${{ env.CONDA_PKGS_DIRS }}
key: ${{ runner.os }}-${{ runner.arch }}-conda-${{ steps.dependencies.outputs.py_version }}-${{ hashFiles(steps.dependencies.outputs.requirements, 'pyproject.toml', 'ci/deps/requirements.yaml.tmpl') }}
- name: Create Conda Environment
run: |
source ci/setup_conda.sh "${{ runner.os }}" "${{ runner.arch }}" "${{ env.CONDA_PKGS_DIRS }}"
ci/setup_env.sh "${{ runner.os }}"
- name: Configure matplotlib
run: |
mkdir -p ${XDG_CONFIG_HOME}/matplotlib
echo 'figure.figsize: 6.0, 4.0' > ${XDG_CONFIG_HOME}/matplotlib/matplotlibrc
echo 'figure.facecolor: white' >> ${XDG_CONFIG_HOME}/matplotlib/matplotlibrc
echo 'figure.edgecolor: white' >> ${XDG_CONFIG_HOME}/matplotlib/matplotlibrc
echo 'figure.dpi: 72' >> ${XDG_CONFIG_HOME}/matplotlib/matplotlibrc
echo 'font.size: 10' >> ${XDG_CONFIG_HOME}/matplotlib/matplotlibrc
- name: Build package
run: |
source activate sksurv-test
python -m build .
pip install --exists-action=w --pre --no-index --find-links dist/ scikit-survival
rm -fr build dist sksurv
- name: Test notebooks
run: |
source activate sksurv-test
pytest --nbval doc/user_guide/*.ipynb --nbval-sanitize-with ci/nb_sanitize.cfg