-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (132 loc) · 4.88 KB
/
build.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
# -----------------------------------------------------------------------------
# - invoked on push, pull_request, manual trigger, or schedule
# - test under at least 3 versions of python
# -----------------------------------------------------------------------------
name: build
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: "0 8 * * *"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
defaults:
run:
shell: bash -le {0}
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: test_env_python${{ matrix.python-version }}
python-version: ${{ matrix.python-version }}
auto-activate-base: false
- name: Install hdf5 libs
run: |
sudo apt-get update
sudo apt-get install libhdf5-dev
- name: get upstream branch name
run: |
if "${{ github.event_name == 'pull_request' }}" ; then
echo "branch_name=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
else
echo "branch_name=${GITHUB_REF_NAME}" >> $GITHUB_ENV
fi
- name: Conda info
run: |
conda info
conda list
echo branch_name = ${branch_name}
- name: check for upstream vivarium
run: |
if git ls-remote --exit-code --heads https://github.com/ihmeuw/vivarium.git ${branch_name} == "0"; then
echo "upstream_vivarium_exist=true" >> $GITHUB_ENV
else
echo "upstream_vivarium_exist=false" >> $GITHUB_ENV
fi
- name: check for upstream vivarium_public_health
run: |
if git ls-remote --exit-code --heads https://github.com/ihmeuw/vivarium_public_health.git ${branch_name} == "0"; then
echo "upstream_vivarium_public_health_exist=true" >> $GITHUB_ENV
else
echo "upstream_vivarium_public_health_exist=false" >> $GITHUB_ENV
fi
- name: check for upstream gbd_mapping
run: |
if git ls-remote --exit-code --heads https://github.com/ihmeuw/gbd_mapping.git ${branch_name} == "0"; then
echo "upstream_gbd_mapping_exist=true" >> $GITHUB_ENV
else
echo "upstream_gbd_mapping_exist=false" >> $GITHUB_ENV
fi
- name: print environment values
run: |
cat $GITHUB_ENV
- name: Retrieve upstream vivarium
if: env.upstream_vivarium_exist == 'true'
run: |
echo "Cloning vivarium upstream branch: ${branch_name}"
git clone --branch=${branch_name} https://github.com/ihmeuw/vivarium.git
pushd vivarium
pip install .
popd
- name: Retrieve upstream vivarium_public_health
if: env.upstream_vivarium_public_health_exist == 'true'
run: |
echo "Cloning vivarium_public_health upstream branch: ${branch_name}"
git clone --branch=${branch_name} https://github.com/ihmeuw/vivarium_public_health.git
pushd vivarium_public_health
pip install .
popd
- name: Retrieve upstream gbd_mapping
if: env.upstream_gbd_mapping_exist == 'true'
run: |
echo "Cloning upstream gbd_mapping branch: ${branch_name}"
git clone --branch=${branch_name} https://github.com/ihmeuw/gbd_mapping.git
pushd gbd_mapping
pip install .
popd
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[docs,test]
- name: Lint
run: |
pip install black==22.3.0 isort
black . --check --diff
isort . --check --verbose --only-modified --diff
- name: Test
run: |
if github.event_name == 'schedule'; then
pytest --runslow ./tests
else
pytest ./tests
fi
- name: Doc build
run: |
make html -C docs/ SPHINXOPTS="-W --keep-going -n"
- name: Doctest
run: |
make doctest -C docs/
- name: Send mail
# Notify when cron job fails
if: (github.event_name == 'schedule' && failure())
uses: dawidd6/action-send-mail@v2
with:
# mail server settings
server_address: smtp.gmail.com
server_port: 465
# user credentials
username: ${{ secrets.NOTIFY_EMAIL }}
password: ${{ secrets.NOTIFY_PASSWORD }}
# email subject
subject: ${{ github.job }} job of ${{ github.repository }} has ${{ job.status }}
# email body as text
body: ${{ github.job }} job in worflow ${{ github.workflow }} of ${{ github.repository }} has ${{ job.status }}
# comma-separated string, send email to
# from email name
from: Dr Manhattan