-
Notifications
You must be signed in to change notification settings - Fork 4
267 lines (237 loc) · 11.1 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
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
255
256
257
258
259
260
261
262
263
264
265
266
267
name: Build
on:
push:
branches: [ main, develop, ruby3 ]
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches: [ main, develop ]
env:
VERIFY_SSL: true
jobs:
build:
name: "${{ matrix.build_name }}"
# Note: as of 2021-01-29, this only works for push, not for pull request
# if: "!(contains(github.event.head_commit.message, 'skip') && contains(github.event.head_commit.message, 'ci'))"
# runs-on: ubuntu-18.04
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.allow_failure }}
strategy:
# fail-fast: Default is true, switch to false to allow one platform to fail and still run others
fail-fast: false
matrix:
build_name: [gcc-10, apple-clang-11, apple-clang-14-armv8, msvc-2022]
include:
- build_name: gcc-10
compiler: gcc
version: 10
os: ubuntu-20.04
# dockerImage: conanio/gcc10-ubuntu16.04:latest
allow_failure: false
- build_name: apple-clang-11
compiler: apple-clang
version: 11
os: macos-11
SDKROOT: /Applications/Xcode_11.7.app
allow_failure: false
- build_name: apple-clang-14-armv8
compiler: apple-clang
version: 14
os: macos-14
SDKROOT: /Applications/Xcode_14.3.1.app
allow_failure: false
- build_name: msvc-2022
compiler: msvc
version: 193
os: windows-2022
allow_failure: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: ruby/setup-ruby@v1
if: runner.os != 'Windows'
with:
ruby-version: '3.2.2'
- name: Setup Conan
id: setup-conan
shell: bash
run: |
set -x
pip install conan==2.2.2
conan --version
if [ "$RUNNER_OS" == "Windows" ]; then
DIR_SEP="\\"
else
DIR_SEP="/"
fi
export CONAN_USER_HOME="${{ github.workspace }}${DIR_SEP}conan-cache"
echo "CONAN_MAJOR_VERSION=$CONAN_MAJOR_VERSION" >> "$GITHUB_OUTPUT"
echo "CONAN_USER_HOME=$CONAN_USER_HOME" >> "$GITHUB_OUTPUT"
echo CONAN_USER_HOME="$CONAN_USER_HOME" >> $GITHUB_ENV
if [ "$RUNNER_OS" == "macOS" ]; then
brew install md5sha1sum
sudo xcode-select -switch "${{ matrix.SDKROOT }}"
clang --version
sdk_path=$(xcrun --sdk macosx --show-sdk-path)
echo "sdk_path=$sdk_path" >> $GITHUB_ENV
# These macs don't have the -f option... dunno if brew coreutils is isntalled... Just use python to read the symlink
# readlink -f $sdk_path
python -c "import os; print(os.path.realpath('$sdk_path'))"
# maybe hardcode conf.tools.apple:sdk_path in profile?"
# The openssl@3 package installed on CI adds these files to the pkgconfig directory
# Remove them here so they aren't found instead of the version of OpenSSL built by Conan
# I should have fixed this, but better safe
brew --prefix
rm -Rf $(brew --prefix)/lib/pkgconfig/libcrypto.pc
rm -Rf $(brew --prefix)/lib/pkgconfig/libssl.pc
rm -Rf $(brew --prefix)/lib/pkgconfig/openssl.pc
elif [ "${{ matrix.compiler }}" = "gcc" ]; then
CC=/usr/bin/gcc-${{ matrix.version }}
# echo "CC=/usr/bin/gcc-${{ matrix.version }}" >> $GITHUB_ENV
# echo "CXX=/usr/bin/g++-${{ matrix.version }}" >> $GITHUB_ENV
# echo "FC=/usr/bin/gfortran-${{ matrix.version }}" >> $GITHUB_ENV
# CONAN_PROFILE="gcc${{ matrix.version }}"
if [ -x "$CC" ]; then
echo "Ok, $CC exists"
else
# Note: there is no gcc 12 on that ppa for Focal (20.04)
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update -qq
sudo apt install -y gcc-${{ matrix.version }} g++-${{ matrix.version }}
# No need for gfortran-${{ matrix.version }}
fi
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ matrix.version }} --slave /usr/bin/gcov gcov /usr/bin/gcov-${{ matrix.version }} --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ matrix.version }}
gcc --version
fi
echo "is_conan2=true" >> "$GITHUB_OUTPUT"
export CONAN_HOME="$CONAN_USER_HOME${DIR_SEP}.conan2"
CONAN_PROFILE_DEFAULT="$CONAN_HOME${DIR_SEP}profiles${DIR_SEP}default"
conan profile detect --force --name default
conan profile path default
cat $CONAN_PROFILE_DEFAULT
# Mac has the FreeBSD flavor of sed and MUST take a backup suffix...
sed -i.bak 's/cppstd=.*$/cppstd=20/g' $CONAN_PROFILE_DEFAULT
# if [ "${{ matrix.compiler}}" == "Visual Studio" ]; then
# # Remove these
# sed -i.bak '/cppstd=.*/d' $CONAN_PROFILE_DEFAULT
# sed -i.bak '/compiler.runtime/d' $CONAN_PROFILE_DEFAULT
# sed -i.bak '/compiler.version/d' $CONAN_PROFILE_DEFAULT
# # Set to visual studio
# sed -i.bak 's/compiler=.*$/compiler=${{ matrix.compiler }}/g' $CONAN_PROFILE_DEFAULT
# sed -i.bak 's/compiler.version=.*$/compiler.version=${{ matrix.version }}/g' $CONAN_PROFILE_DEFAULT
# fi
rm -Rf $CONAN_PROFILE_DEFAULT.bak || true
conan profile show
echo "core:non_interactive = True" >> $CONAN_HOME/global.conf
echo "core.download:parallel = {{os.cpu_count() - 2}}" >> $CONAN_HOME/global.conf
echo "core.sources:download_cache = $CONAN_USER_HOME/.conan-download-cache" >> $CONAN_HOME/global.conf
cat $CONAN_HOME/global.conf
echo CONAN_HOME="$CONAN_HOME" >> $GITHUB_ENV
echo CONAN_PROFILE_DEFAULT="$CONAN_PROFILE_DEFAULT" >> $GITHUB_ENV
# Use lowercase based on repository owner, so that NREL -> nrel.
# That should work on forks, while not replacing 'nrel' with '***' everywhere like it does when you set CONAN_USERNAME as a repo secret...
# We want BPT/CPT to produces openstudio_ruby/2.7.2@<CONAN_USERNAME>/<channel>
# TODO: I actually do NOT want to set it now! so rename to REPO_USERNAME
REPO_USERNAME=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
echo "REPO_USERNAME=$REPO_USERNAME" >> $GITHUB_ENV
# (Can't do that before we've se the CONAN_HOME / CONAN_USER_HOME)
if [[ "$VERIFY_SSL" == "false" ]]; then
conan remote add --force --insecure nrel-v2 http://conan.openstudio.net/artifactory/api/conan/conan-v2 # ${{ secrets.CONAN_UPLOAD }}
else
conan remote add --force nrel-v2 https://conan.openstudio.net/artifactory/api/conan/conan-v2 # ${{ secrets.CONAN_UPLOAD }}
fi
conan remote list
- name: Setup Conan Cache
uses: actions/cache@v4
id: cacheconan
with:
path: |
${{ env.CONAN_USER_HOME }}/.conan-download-cache
${{ env.CONAN_USER_HOME }}/short
${{ env.CONAN_HOME }}/p
${{ env.CONAN_HOME }}/data
key: conan-cache-${{ matrix.os }}-compiler=${{ matrix.compiler }}-${{ matrix.version}}-conan-profile=${{ hashFiles(env.CONAN_PROFILE_DEFAULT) }}-recipe-version=${{ matrix.recipe_version}}-cachekey=${{ secrets.CACHE_KEY }}
restore-keys: |
conan-cache-${{ matrix.os }}-compiler=${{ matrix.compiler }}-${{ matrix.version}}-conan-profile=${{ hashFiles(env.CONAN_PROFILE_DEFAULT) }}-recipe-version=${{ matrix.recipe_version}}-
conan-cache-${{ matrix.os }}-compiler=${{ matrix.compiler }}-${{ matrix.version}}-conan-profile=${{ hashFiles(env.CONAN_PROFILE_DEFAULT) }}-
conan-cache-${{ matrix.os }}-compiler=${{ matrix.compiler }}-${{ matrix.version}}-
conan-cache-${{ matrix.os }}-compiler=${{ matrix.compiler }}-
conan-cache-${{ matrix.os }}-
save-always: ${{ matrix.compiler == 'msvc' }}
- name: Did restoring the conan-cache work? Yes
if: steps.cacheconan.outputs.cache-hit == 'true'
run: |
echo "Yes"
- name: Build Unix
if: runner.os != 'Windows'
shell: bash
run: |
set -x
conan install . --output-folder=../os-gems-deps --build=missing -s:a build_type=Release -s:a compiler.cppstd=20 -o '*/*:shared=False'
. ../os-gems-deps/conanbuild.sh
ruby --version
sqlite3 --version
echo $PKG_CONFIG_PATH
gem install rake
rake make_package
- name: Build Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
# Set-PSDebug -Trace 1
# LongPathsEnabled is already the case for the runner: https://github.com/actions/runner-images/blob/13d5100df5e7d490b069f0e284dffbc8e321a756/images/windows/scripts/build/Configure-BaseImage.ps1#L73
# But git isn't
git config --system core.longpaths true
# As of 2024-02-13, this commit isn't in conan v2 https://github.com/conan-io/conan/commit/f2b56352f6f597981ccc053f9b7982029b942bf2
$vspath=$(vswhere -products '*' -requires Microsoft.Component.MSBuild -property installationPath -latest)
$devShellModule = "$vspath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Import-Module $devShellModule
Enter-VsDevShell -VsInstallPath $vspath -SkipAutomaticLocation -Arch amd64
conan install . --output-folder=../os-gems-deps --build=missing -s:a build_type=Release -s:a compiler.cppstd=20 -o '*/*:shared=False' -c tools.env.virtualenv:powershell=True
& ..\os-gems-deps\conanbuild.ps1
ruby --version
sqlite3 --version
echo $env:PKG_CONFIG_PATH
gem install rake
rake make_package
- name: Archive TGZ or ZIP artifacts
uses: actions/upload-artifact@v4
with:
name: openstudio3-gems-${{ github.sha }}-${{ matrix.build_name }}.tar.gz
path: openstudio3-gems*.tar.gz
- name: Upload TGZ to release
if: contains(github.ref, 'refs/tags')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: openstudio3-gems*.tar.gz
tag: ${{ github.ref }}
overwrite: true
file_glob: true
- name: Remove non-critical folders from the conan cache
shell: bash
if: ${{ contains(github.ref, 'refs/tags') || ((github.event_name == 'push' && github.ref == 'refs/heads/main')) }}
run: |
set -x
if [ "$CONAN_MAJOR_VERSION" == "1" ]; then
conan remove "*" --src --builds --system-reqs -f
else
conan cache clean --source --build --download --temp
fi
# Only trigger checksums if all builds succeded and it's a tag
trigger_cheksum:
needs: build
runs-on: ubuntu-latest
steps:
- name: Trigger the Checksums workflow
if: contains(github.ref, 'refs/tags')
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow -R ${{ github.repository }} run checksums.yml -f tag=${{ github.ref_name }}