forked from bluecheetah/bag
-
Notifications
You must be signed in to change notification settings - Fork 14
183 lines (180 loc) · 5.63 KB
/
pr.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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
# CI flow
name: bag-pr-ci
on:
push:
schedule:
- cron: '0 9 * * *' # 9AM UTC = 2AM PST
env:
CONDA_ENV_NAME: bag_py3d7_c
jobs:
build_pybag:
runs-on: ubuntu-20.04
defaults:
run:
shell: bash -el {0}
continue-on-error: true
strategy:
matrix:
python-version: ["3.7"]
steps:
- name: Checkout submodule
uses: actions/checkout@v3
with:
submodules: recursive
# Phase 1: Conda setup
- name: Setup conda
uses: conda-incubator/[email protected]
with:
activate-environment: ${{ env.CONDA_ENV_NAME }}
python-version: ${{ matrix.python-version }}
auto-activate-base: false
- name: Save Conda Env
# Workaround, this isn't working otherwise.
run: |
echo "CONDA=$CONDA"
echo "CONDA=$CONDA" >> "$GITHUB_ENV"
- name: Cache Conda env
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs/${{ env.CONDA_ENV_NAME }}
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{
steps.get-date.outputs.today }}-${{
hashFiles('environment.yml') }}-${{
env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
id: cache-conda
- name: Install packages
if: steps.cache-conda.outputs.cache-hit != 'true'
run: |
sudo apt update
sudo apt -y install \
autoconf \
curl \
gcc-8 \
g++-8 \
git \
libtool \
libltdl-dev \
pkg-config \
make \
- name: Update conda environment
if: steps.cache-conda.outputs.cache-hit != 'true'
run: |
echo "env.conda=${{ env.CONDA }}"
conda env update -n ${{ env.CONDA_ENV_NAME }} -f environment.yml
- name: Install additional dependencies
if: steps.cache-conda.outputs.cache-hit != 'true'
run: |
cd pybag/setup
mkdir install
cp setup_script.sh install/
cp render_template.py install/
cp project-config.template install/
cd install
./setup_script.sh
# Phase 2: Build pybag
- name: Get pybag commit string
run: |
cd pybag
export PYBAG_COMMIT="$(git rev-parse HEAD)"
echo $PYBAG_COMMIT
echo "PYBAG_COMMIT=$PYBAG_COMMIT" >> "$GITHUB_ENV"
- name: Cache pybag
id: cache-pybag
uses: actions/cache@v4
with:
path: pybag/_build
key:
pybag-${{ runner.os }}--${{ runner.arch }}--${{
hashFiles('environment.yml') }}-${{
env.PYBAG_COMMIT }}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
- name: Build pybag
if: (steps.cache-pybag.outputs.cache-hit != 'true') || (steps.cache-conda.outputs.cache-hit != 'true')
id: cpp-build
run: |
cd pybag
export PYBAG_PYTHON=python
echo "PYBAG_PYTHON=$PYBAG_PYTHON"
./run_test.sh
tests:
needs: build_pybag
defaults:
run:
shell: bash -el {0}
runs-on: ubuntu-latest
continue-on-error: true
outputs:
pytestOutput: ${{ steps.unit-tests.outputs.test }}
mypyOutput: ${{ steps.type-checks.outputs.test }}
strategy:
matrix:
python-version: ["3.7"]
steps:
- name: Checkout submodule
uses: actions/checkout@v3
with:
submodules: recursive
# Phase 1: Conda cache load
- name: Setup conda
uses: conda-incubator/[email protected]
with:
activate-environment: ${{ env.CONDA_ENV_NAME }}
python-version: ${{ matrix.python-version }}
auto-activate-base: false
- name: Save Conda Env
# Workaround, this isn't working otherwise.
run: |
echo "CONDA=$CONDA"
echo "CONDA=$CONDA" >> "$GITHUB_ENV"
- name: Cache Conda env
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs/${{ env.CONDA_ENV_NAME }}
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{
steps.get-date.outputs.today }}-${{
hashFiles('environment.yml') }}-${{
env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
id: cache-conda
# Phase 2: Pybag cache load
- name: Get pybag commit string
run: |
cd pybag
export PYBAG_COMMIT="$(git rev-parse HEAD)"
echo $PYBAG_COMMIT
echo "PYBAG_COMMIT=$PYBAG_COMMIT" >> "$GITHUB_ENV"
- name: Cache pybag
id: cache-pybag
uses: actions/cache@v4
with:
path: pybag/_build
key:
pybag-${{ runner.os }}--${{ runner.arch }}--${{
hashFiles('environment.yml') }}-${{
env.PYBAG_COMMIT }}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
# Phase 3: Run tests
- name: Set python path
run: |
export PYTHONPATH="$(pwd)/tests:$(pwd)/pybag/_build/lib:$(pwd)/src"
echo $PYTHONPATH
echo "PYTHONPATH=$PYTHONPATH" >> "$GITHUB_ENV"
- name: Run simple test
id: simple-test
run: |
python tests/run_core.py
- name: Run unit tests
id: unit-tests
run: |
pytest tests/ -v