-
Notifications
You must be signed in to change notification settings - Fork 0
254 lines (231 loc) · 8.71 KB
/
cookiecutter-test.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
name: Cookiecutter Test
on:
push:
pull_request:
env:
MPLBACKEND: "agg"
QT_QPA_PLATFORM: "offscreen"
PROJECT_DIR: "project_name"
IMPORT_NAME: "project_name"
ENTRYPOINT_NAME: "project-name"
# PYTHON_VERSION: "3.9"
MAMBA_ROOT_PREFIX: "~/micromamba"
CONDARC_SOURCE: |
notify_outdated_conda: false
pkgs_dirs:
- ~/conda_pkgs_dir
channels:
- conda-forge
add_pip_as_python_dependency: true
auto_activate_base: true
auto_update_conda: false
channel_priority: strict
always_yes: true
changeps1: false
jobs:
pip-tst:
name: "pip"
runs-on: ubuntu-20.04
defaults:
run:
# The following allows for each run step to utilize ~/.bash_profile
# for setting up the per-step initial state.
# --login: a login shell. Source ~/.bash_profile
# -e: exit on first error
# -o pipefail: piped processes are important; fail if they fail
shell: bash --login -eo pipefail {0}
strategy:
matrix:
config_file: [ default_config.yaml, complex_config.yaml]
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Upgrade pip
run: |
pip install --upgrade pip build
- name: Install cookiecutter and requirements
run: |
pip install -r requirements.txt
- name: Check the pip packages in the test env
run: |
pip list
- name: Configure git
run: |
git config --global user.email "[email protected]"
git config --global user.name "PCDS / GitHub CI"
- name: Append version to config
run: |
echo ' python_version: "${{ matrix.python_version }}"' >> tests/${{ matrix.config_file }}
cat tests/${{ matrix.config_file }}
- name: Use the cookiecutter
run: |
cookiecutter . --no-input --config-file tests/${{ matrix.config_file }} --output-dir "$HOME"
- name: Build wheel and source distribution
run: |
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
export SETUPTOOLS_SCM_DEBUG=1
echo "Source date epoch set to ${SOURCE_DATE_EPOCH} for reproducible build"
# See: https://github.com/python/cpython/pull/5200
# And: https://reproducible-builds.org/docs/source-date-epoch/
cd "${HOME}/${PROJECT_DIR}"
python -m build --sdist --wheel --outdir ./dist
cat pyproject.toml
- name: Check the source distribution
run: |
cd
python -m venv test-source-env
source test-source-env/bin/activate
cd "${HOME}/${PROJECT_DIR}"
python -m pip install ./dist/*.gz
cd /tmp
python -c "import ${IMPORT_NAME}; print('Imported ${IMPORT_NAME} from ' + ${IMPORT_NAME}.__file__)"
command -v "${ENTRYPOINT_NAME}"
- name: Use the wheel for testing
run: |
cd "${HOME}/${PROJECT_DIR}"
python -m pip install ./dist/*.whl
cd /tmp
python -c "import ${IMPORT_NAME}; print('Imported ${IMPORT_NAME} from ' + ${IMPORT_NAME}.__file__)"
command -v "${ENTRYPOINT_NAME}"
- name: After failure
if: ${{ failure() }}
run: |
(
echo "### Pip list"
echo "<details>"
echo ""
echo '```'
pip list | egrep -v -e "^#"
echo '```'
echo "</details>"
) >> "$GITHUB_STEP_SUMMARY"
- name: Display project structure
if: ${{ always() }}
run: |
cd ~/project_name
tree -apguh -L 4
- name: Upload the built package as an artifact
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: "pip - Cookiecutter Output - ${{ matrix.python_version }} - ${{ matrix.config_file }}"
path: ~/project_name
# conda-test:
# name: "Python 3.9: conda"
# runs-on: ubuntu-20.04
#
# defaults:
# run:
# # The following allows for each run step to utilize ~/.bash_profile
# # for setting up the per-step initial state.
# # --login: a login shell. Source ~/.bash_profile
# # -e: exit on first error
# # -o pipefail: piped processes are important; fail if they fail
# shell: bash --login -eo pipefail {0}
#
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
#
# - name: Configure git
# run: |
# git config --global user.email "[email protected]"
# git config --global user.name "PCDS / GitHub CI"
#
# - name: Set up micromamba and environment
# run: |
# cd "$HOME"
# mkdir logs
# curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj "bin/micromamba"
# mkdir micromamba
#
# echo "Micromamba version: $(bin/micromamba --version)" | tee "$GITHUB_STEP_SUMMARY"
# bin/micromamba shell hook --shell=bash >> ~/.bash_profile
#
# echo "micromamba activate" >> ~/.bash_profile
#
# - name: Configure conda for building
# run: |
# echo "${CONDARC_SOURCE}" > ~/.condarc
# echo "Contents of ~/.condarc:"
# echo "---------------------------"
# cat ~/.condarc
# echo "---------------------------"
#
# - name: Install boa for mambabuild
# run: |
# micromamba install boa conda-verify "python=${PYTHON_VERSION}" pip
# micromamba info
#
# - name: Check condarc
# run: |
# cat ~/.condarc
#
# - name: Install cookiecutter and requirements
# run: |
# pip install -r requirements.txt
#
# - name: Use the cookiecutter
# run: |
# cookiecutter . --no-input --output-dir "$HOME"
#
# - name: Start the next steps in the cookiecutter output
# run: |
# echo "cd \"${HOME}/${PROJECT_DIR}\"" >> ~/.bash_profile
#
# - name: Check the conda recipe
# run: |
# echo "Conda Recipe Folder':' conda-recipe"
# echo "The recipe to be built is as follows:"
# cat "conda-recipe/meta.yaml"
#
# - name: Configure setuptools-scm
# run: |
# micromamba install setuptools-scm
# python -m setuptools_scm
#
# - name: Build the conda package and create the test environment
# run: |
# conda mambabuild "conda-recipe" \
# --quiet \
# --output-folder "$HOME/conda-bld" \
# --no-anaconda-upload \
# --python "${PYTHON_VERSION}" \
# --extra-deps "python==${PYTHON_VERSION}" \
# --keep-old-work \
# 2>&1 | tee $HOME/logs/mambabuild.txt
#
# - name: Upload the built package as an artifact
# uses: actions/upload-artifact@v3
# with:
# name: Python 3.9 - conda - package
# path: ~/conda-bld
#
# - name: Use the pre-built test environment
# run: |
# TEST_ENV_PATH=$(ls -d ${MAMBA_ROOT_PREFIX/#\~/$HOME}/conda-bld/*/*_test_env*)
# echo "The test path should be: ${TEST_ENV_PATH}"
#
# if [ ! -d "${TEST_ENV_PATH}" ]; then
# echo "Something went wrong finding the test environment path. :("
# find ${MAMBA_ROOT_PREFIX/#\~/$HOME}/conda-bld -type d
# exit 1
# fi
#
# echo "micromamba activate ${TEST_ENV_PATH}" >> ~/.bash_profile
#
# - name: Check the conda packages in the test env
# run: |
# conda list
#
# - name: Verify conda-installed package
# run: |
# cd /tmp
# python -c "import ${IMPORT_NAME}; print('Imported ${IMPORT_NAME} from ' + ${IMPORT_NAME}.__file__)"
# command -v "${ENTRYPOINT_NAME}"