-
-
Notifications
You must be signed in to change notification settings - Fork 185
/
github-actions.yml.tmpl
246 lines (232 loc) · 9.22 KB
/
github-actions.yml.tmpl
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
# This file was generated automatically from conda-smithy. To update this configuration,
# update the conda-forge.yml and/or the recipe/meta.yaml.
# -*- mode: yaml -*-
{%- set platformset = [] %}
{%- for data in configs %}
{%- set pfarchless = data.build_platform.split('-')[0] %}
{%- if pfarchless not in platformset %}
{%- do platformset.append(pfarchless) %}
{%- endif %}
{%- endfor %}
name: Build conda package
on:
{%- for trigger in github_actions.triggers %}
{%- if trigger == "push" and upload_on_branch %}
push:
branches:
- {{ upload_on_branch }}
{%- else %}
{{ trigger }}:
{%- endif %}
{% endfor %}
{%- if github_actions.cancel_in_progress %}
concurrency:
group: {% raw %}${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}{% endraw %}
cancel-in-progress: true
{%- endif %}
jobs:
build:
name: {% raw %}${{ matrix.CONFIG }}{% endraw %}
runs-on: {% raw %}${{ matrix.runs_on }}{% endraw %}
timeout-minutes: {{ github_actions.timeout_minutes }}
strategy:
fail-fast: false
{%- if github_actions.max_parallel %}
max-parallel: {{ github_actions.max_parallel }}
{%- endif %}
matrix:
include:
{%- for data in configs %}
- CONFIG: {{ data.config_name }}
{%- if github_actions.store_build_artifacts %}
SHORT_CONFIG: {{ data.short_config_name }}
{%- endif %}
UPLOAD_PACKAGES: {{ data.upload }}
os: {{ data.gha_os }}
runs_on: {{ data.gha_runs_on }}
{%- if data.build_platform.startswith("linux") %}
DOCKER_IMAGE: {{ data.config["docker_image"][-1] }}
{%- if data.gha_with_gpu %}
CONDA_FORGE_DOCKER_RUN_ARGS: "--gpus all"
{%- endif %}
{%- endif %}
{%- endfor %}
steps:
{%- if github_actions.free_disk_space %}
- name: Manage disk space
if: matrix.os == 'ubuntu'
run: |
{%- if (github_actions.free_disk_space == true) or ('cache' in github_actions.free_disk_space) %}
sudo mkdir -p /opt/empty_dir || true
for d in \
/opt/ghc \
/opt/hostedtoolcache \
/usr/lib/jvm \
/usr/local/.ghcup \
/usr/local/lib/android \
/usr/local/share/powershell \
/usr/share/dotnet \
/usr/share/swift \
; do
sudo rsync --stats -a --delete /opt/empty_dir/ $d || true
done
{%- endif %}
{%- if (github_actions.free_disk_space == true) or ('apt' in github_actions.free_disk_space) %}
sudo apt-get purge -y -f firefox \
google-chrome-stable \
microsoft-edge-stable
sudo apt-get autoremove -y >& /dev/null
sudo apt-get autoclean -y >& /dev/null
{%- endif %}
{%- if (github_actions.free_disk_space is iterable) and ('docker' in github_actions.free_disk_space) %}
sudo docker image prune --all --force
{%- endif %}
df -h
{%- endif %}
- name: Checkout code
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
{%- if clone_depth is not none %}
with:
fetch-depth: {{ clone_depth }}
{%- endif %}
- name: Build on Linux
if: matrix.os == 'ubuntu'
env:
CONFIG: {% raw %}${{ matrix.CONFIG }}{% endraw %}
UPLOAD_PACKAGES: {% raw %}${{ matrix.UPLOAD_PACKAGES }}{% endraw %}
DOCKER_IMAGE: {% raw %}${{ matrix.DOCKER_IMAGE }}{% endraw %}
CI: github_actions
{%- if upload_on_branch %}
UPLOAD_ON_BRANCH: {{ upload_on_branch }}
{%- endif %}
{%- if docker.run_args is defined %}
CONDA_FORGE_DOCKER_RUN_ARGS: "{{ docker.run_args }} {% raw %}${{ matrix.CONDA_FORGE_DOCKER_RUN_ARGS }}{% endraw %}"
{%- else %}
CONDA_FORGE_DOCKER_RUN_ARGS: "{% raw %}${{ matrix.CONDA_FORGE_DOCKER_RUN_ARGS }}{% endraw %}"
{%- endif %}
{%- for secret in secrets %}
{{ secret }}: {% raw %}${{{% endraw %} secrets.{{ secret }} {% raw %}}}{% endraw %}
{%- endfor %}
shell: bash
run: |
echo "::group::Configure binfmt_misc"
docker run --rm --privileged multiarch/qemu-user-static:register --reset --credential yes
export flow_run_id="github_$GITHUB_RUN_ID"
export remote_url="https://github.com/$GITHUB_REPOSITORY"
export sha="$GITHUB_SHA"
export FEEDSTOCK_NAME="$(basename $GITHUB_REPOSITORY)"
export GIT_BRANCH="$(basename $GITHUB_REF)"
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
export IS_PR_BUILD="True"
else
export IS_PR_BUILD="False"
fi
echo "::endgroup::"
./.scripts/run_docker_build.sh
- name: Build on macOS
if: matrix.os == 'macos'
env:
CONFIG: {% raw %}${{ matrix.CONFIG }}{% endraw %}
UPLOAD_PACKAGES: {% raw %}${{ matrix.UPLOAD_PACKAGES }}{% endraw %}
CI: github_actions
{%- if upload_on_branch %}
UPLOAD_ON_BRANCH: {{ upload_on_branch }}
{%- endif %}
{%- for secret in secrets %}
{{ secret }}: {% raw %}${{{% endraw %} secrets.{{ secret }} {% raw %}}}{% endraw %}
{%- endfor %}
shell: bash
run: |
export flow_run_id="github_$GITHUB_RUN_ID"
export remote_url="https://github.com/$GITHUB_REPOSITORY"
export sha="$GITHUB_SHA"
export FEEDSTOCK_NAME="$(basename $GITHUB_REPOSITORY)"
export GIT_BRANCH="$(basename $GITHUB_REF)"
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
export IS_PR_BUILD="True"
else
export IS_PR_BUILD="False"
fi
./.scripts/run_osx_build.sh
{%- for choco_pkg in choco %}
- name: "Install Chocolatey Package: {{ choco_pkg }}"
if matrix.os == 'windows'
run: |
choco install {{ choco_pkg }} -fdv -y --debug
{% endfor %}
- name: Install Miniconda for windows
uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
with:
miniforge-version: latest
miniforge-variant: Mambaforge
if: matrix.os == 'windows'
- name: Build on windows
shell: cmd
run: |
set "flow_run_id=github_%GITHUB_RUN_ID%"
set "remote_url=https://github.com/%GITHUB_REPOSITORY%"
set "sha=%GITHUB_SHA%"
call ".scripts\run_win_build.bat"
env:
PYTHONUNBUFFERED: 1
CONFIG: {% raw %}${{ matrix.CONFIG }}{% endraw %}
CI: github_actions
UPLOAD_PACKAGES: {% raw %}${{ matrix.UPLOAD_PACKAGES }}{% endraw %}
{%- if upload_on_branch %}
UPLOAD_ON_BRANCH: {{ upload_on_branch }}
{%- endif %}
{%- for secret in secrets %}
{{ secret }}: {% raw %}${{{% endraw %} secrets.{{ secret }} {% raw %}}}{% endraw %}
{%- endfor %}
if: matrix.os == 'windows'
{%- if github_actions.store_build_artifacts %}
- name: Prepare conda build artifacts
id: prepare-artifacts
shell: bash
if: {% raw %}${{ always() }}{% endraw %}
env:
CONFIG: {% raw %}${{ matrix.CONFIG }}{% endraw %}
SHORT_CONFIG: {% raw %}${{ matrix.SHORT_CONFIG }}{% endraw %}
OS: {% raw %}${{ matrix.os }}{% endraw %}
run: |
export CI=github_actions
export CI_RUN_ID=$GITHUB_RUN_ID
export FEEDSTOCK_NAME="$(basename $GITHUB_REPOSITORY)"
export ARTIFACT_STAGING_DIR="$GITHUB_WORKSPACE"
if [ $OS == "macos" ]; then
export CONDA_BLD_DIR="${MINIFORGE_HOME:-${HOME}/miniforge3}/conda-bld"
elif [ $OS == "windows" ]; then
export CONDA_BLD_DIR="${CONDA//\\//}/conda-bld"
else
export CONDA_BLD_DIR="build_artifacts"
fi
# Archive everything in CONDA_BLD_DIR except environments
# Archive the CONDA_BLD_DIR environments only when the job fails
# Use different prefix for successful and failed build artifacts
# so random failures don't prevent rebuilds from creating artifacts.
JOB_STATUS="{% raw %}${{ job.status }}{% endraw %}"
if [ $JOB_STATUS == "failure" ]; then
export BLD_ARTIFACT_PREFIX="conda_artifacts"
export ENV_ARTIFACT_PREFIX="conda_envs"
else
export BLD_ARTIFACT_PREFIX="conda_pkgs"
fi
./.scripts/create_conda_build_artifacts.sh
continue-on-error: true
- name: Store conda build artifacts
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: {% raw %}${{ always() && steps.prepare-artifacts.outcome == 'success' }}{% endraw %}
with:
name: {% raw %}${{ steps.prepare-artifacts.outputs.BLD_ARTIFACT_NAME }}{% endraw %}
path: {% raw %}${{ steps.prepare-artifacts.outputs.BLD_ARTIFACT_PATH }}{% endraw %}
retention-days: {{ github_actions.artifact_retention_days }}
continue-on-error: true
- name: Store conda build environment artifacts
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: {% raw %}${{ failure() && steps.prepare-artifacts.outcome == 'success' }}{% endraw %}
with:
name: {% raw %}${{ steps.prepare-artifacts.outputs.ENV_ARTIFACT_NAME }}{% endraw %}
path: {% raw %}${{ steps.prepare-artifacts.outputs.ENV_ARTIFACT_PATH }}{% endraw %}
retention-days: {{ github_actions.artifact_retention_days }}
continue-on-error: true
{%- endif %}