forked from sherpa/sherpa
-
Notifications
You must be signed in to change notification settings - Fork 0
253 lines (230 loc) · 9.46 KB
/
ci-conda-deployment.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
name: Conda Deployments
#Only run when updating main, ciaox, or release/... branches (no PRs).
#With check-skip job, we skip build on main/ciaox if directly tagged as a release.
# (To only build releases on the release branch)
on:
push:
branches:
- main
- ciaox
- 'release/**'
#Reduces GH Action duplication:
# Cancels the previous pipeline for this ref it is still running
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
sherpa_label: dev
conda_loc: ${{ github.workspace }}/conda_loc
defaults:
run:
shell: bash
jobs:
check-skip:
name: Skip the Pipeline if tagged and NOT on the release branch
runs-on: ubuntu-latest
if: github.repository == 'sherpa/sherpa'
outputs:
skip_pipeline: ${{ steps.skip_check.outputs.skip_pipeline }}
steps:
#Checkout the code with a depth of 0 to grab the tags/branches as well
- name: Checkout Code
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Check build number
id: skip_check
run: |
#BUILD_NUM not passed to future jobs to maintain a separate Git sanity check
BUILD_NUM="$(git describe --tags --always | awk '{split($0,a,"-"); print a[2]}')"
echo "BUILD_NUM=${BUILD_NUM}"
if [ -z "${BUILD_NUM}" ] && [ "${GITHUB_REF:0:20}" != "refs/heads/releases/" ] ; then
#Skip the build/test/deploy if directly on a tag and NOT on a release branch
echo "skip_pipeline=true" >> $GITHUB_OUTPUT
else
echo "skip_pipeline=false" >> $GITHUB_OUTPUT
fi
#Linux and macOS build separate as we can't use container option dynamically
# based on it being defined in the matrix or not.
build-linux:
name: Linux Python ${{ matrix.python-version }}
if: ${{ needs.check-skip.outputs.skip_pipeline }} == "false"
needs: ["check-skip"]
runs-on: ubuntu-latest
container:
image: ${{ matrix.image }}
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
volumes:
- ${{ github.workspace }}:${{ github.workspace }}
strategy:
matrix:
image: ["redhat/ubi8"]
conda-os: ["Linux-x86_64"]
os-dir: ["linux-64"]
python-version: ["3.9", "3.10", "3.11"]
steps:
- name: Install git and diff
run: yum install -y -q git diffutils
- name: Conda Setup
env:
CONDA_OS: ${{ matrix.conda-os }}
run: |
curl -L https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-${CONDA_OS}.sh -o conda-installer.sh
bash conda-installer.sh -b -p ${conda_loc}
source ${conda_loc}/etc/profile.d/conda.sh
conda create -yq -n builder conda-build=3.25 conda-verify
#Checkout the code with a depth of 0 to grab the tags/branches as well
- name: Checkout Code
uses: actions/[email protected]
with:
fetch-depth: 0
path: sherpa
- name: Build Sherpa
env:
SHERPA_PYTHON_VERSION: ${{ matrix.python-version }}
run: |
cd sherpa
export SHERPA_FULL_VERSION=$(git describe --tags --always)
export SHERPA_VERSION=$(echo $SHERPA_FULL_VERSION | awk '{split($0,a,"-"); print a[1]}')
SHERPA_BUILD_NUMBER=$(echo $SHERPA_FULL_VERSION | awk '{split($0,a,"-"); print a[2]}')
export SHERPA_BUILD_NUMBER="${SHERPA_BUILD_NUMBER:-0}"
echo "Version: ${SHERPA_VERSION} Build Number: ${SHERPA_BUILD_NUMBER}"
if [ -z ${SHERPA_VERSION} ] || [ -z ${SHERPA_BUILD_NUMBER} ] ; then
echo "Error: SHERPA_VERSION or SHERPA_BUILD_NUMBER not set."
exit 1
fi
source ${conda_loc}/etc/profile.d/conda.sh
conda activate builder
echo "conda build --python ${SHERPA_PYTHON_VERSION} --output-folder ${GITHUB_WORKSPACE}/packages recipes/conda"
conda build --python ${SHERPA_PYTHON_VERSION} --output-folder ${GITHUB_WORKSPACE}/packages recipes/conda
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os-dir }}
path: ${{ github.workspace }}/packages/*/sherpa*bz2
if-no-files-found: error
retention-days: 3
build-macos:
name: MacOS Python ${{ matrix.python-version }}
if: github.repository == 'sherpa/sherpa' && ${{ needs.check-skip.outputs.skip_pipeline }} == "false"
needs: ["check-skip"]
runs-on: ${{ matrix.os-type }}
strategy:
matrix:
os-type: ["macos-11"]
conda-os: ["MacOSX-x86_64"]
os-dir: ["osx-64"]
python-version: ["3.9", "3.10", "3.11"]
env:
CONDA_BUILD_SYSROOT: /opt/MacOSX10.14.sdk
steps:
- name: Conda Setup
env:
CONDA_OS: ${{ matrix.conda-os }}
run: |
curl -L https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-${CONDA_OS}.sh -o conda-installer.sh
bash conda-installer.sh -b -p ${conda_loc}
source ${conda_loc}/etc/profile.d/conda.sh
conda create -yq -n builder conda-build=3.25 conda-verify
- name: macOS 10.14 SDK
if: ${{ matrix.conda-os == 'MacOSX-x86_64' }}
run: |
#Download the MacOS 10.14 SDK to the CONDA_BUILD_SYSROOT location for the Conda Compilers to work
mkdir -p /opt
curl -L https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.14.sdk.tar.xz -o MacOSX10.14.sdk.tar.xz
if [[ $? -ne 0 ]]; then
echo "MacOS 10.14 SDK download failed"
fi
sudo tar -C /opt -xf MacOSX10.14.sdk.tar.xz
- name: Checkout Code
uses: actions/[email protected]
with:
fetch-depth: 0
path: sherpa
- name: Build Sherpa
env:
SHERPA_PYTHON_VERSION: ${{ matrix.python-version }}
run: |
cd sherpa
export SHERPA_FULL_VERSION=$(git describe --tags --always)
export SHERPA_VERSION=$(echo $SHERPA_FULL_VERSION | awk '{split($0,a,"-"); print a[1]}')
SHERPA_BUILD_NUMBER=$(echo $SHERPA_FULL_VERSION | awk '{split($0,a,"-"); print a[2]}')
export SHERPA_BUILD_NUMBER="${SHERPA_BUILD_NUMBER:-0}"
echo "Version: ${SHERPA_VERSION} Build Number: ${SHERPA_BUILD_NUMBER}"
if [ -z ${SHERPA_VERSION} ] || [ -z ${SHERPA_BUILD_NUMBER} ] ; then
echo "Error: SHERPA_VERSION or SHERPA_BUILD_NUMBER not set"
exit 1
fi
source ${conda_loc}/etc/profile.d/conda.sh
conda activate builder
echo "conda build --python ${SHERPA_PYTHON_VERSION} --output-folder ${GITHUB_WORKSPACE}/packages recipes/conda"
conda build --python ${SHERPA_PYTHON_VERSION} --output-folder ${GITHUB_WORKSPACE}/packages recipes/conda
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os-dir }}
path: ${{ github.workspace }}/packages/*/sherpa*bz2
if-no-files-found: error
retention-days: 3
#The jobs below should not run if "build-linux" or "build-macos" are skipped.
#If they try to, then the "pre-deploy-test" stage will fail anyway and the deployment will NOT be attempted.
#If the "pre-deploy-test" stage is attempted when it shouldn't be, GH Actions might have updated the
# condition for skipping a "needs" option.
pre-deploy-test:
needs: ["build-linux", "build-macos"]
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: Latest Ubuntu Pre-Deploy Test
os: ubuntu-latest
conda-os: "Linux-x86_64"
os-dir: "linux-64"
- name: Latest MacOS Pre-Deploy Test
os: macos-latest
conda-os: "MacOSX-x86_64"
os-dir: "osx-64"
steps:
#Download all artifacts
- uses: actions/download-artifact@v3
id: download
with:
name: ${{ matrix.os-dir }}
path: packages
- name: Conda Setup & Index Artifacts
env:
CONDA_OS: ${{ matrix.conda-os }}
working-directory: ${{ github.workspace }}
run: |
curl -L https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-${CONDA_OS}.sh -o conda-installer.sh
bash conda-installer.sh -b -p ${conda_loc}
source ${conda_loc}/etc/profile.d/conda.sh
conda install conda-build=3.25
echo "Packages downloaded here: ${{steps.download.outputs.download-path}}"
echo "ls packages/*/sherpa*.bz2"
ls packages/*/sherpa*.bz2
echo "conda index packages"
conda index packages
- name: Run the tests
working-directory: ${{ github.workspace }}
run: |
source ${conda_loc}/etc/profile.d/conda.sh
curl -LO -k https://github.com/sherpa/sherpa-test-data/archive/main.zip
echo "conda create -n test39 --yes -q -c file://$(pwd)/packages python=3.9 astropy sherpa matplotlib"
conda create -n test39 --yes -q -c file://$(pwd)/packages python=3.9 astropy sherpa matplotlib
conda activate test39
pip install main.zip
sherpa_smoke -f astropy
sherpa_test
echo "conda create -n test310 --yes -q -c file://$(pwd)/packages python=3.10 astropy sherpa matplotlib"
conda create -n test310 --yes -q -c file://$(pwd)/packages python=3.10 astropy sherpa matplotlib
conda activate test310
pip install main.zip
sherpa_smoke -f astropy
sherpa_test
echo "conda create -n test311 --yes -q -c file://$(pwd)/packages python=3.11 astropy sherpa matplotlib"
conda create -n test311 --yes -q -c file://$(pwd)/packages python=3.11 astropy sherpa matplotlib
conda activate test311
pip install main.zip
sherpa_smoke -f astropy
sherpa_test