forked from flagarde/YAODAQ
-
Notifications
You must be signed in to change notification settings - Fork 1
225 lines (193 loc) · 6.31 KB
/
Windows-MSVC.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
name: Windows MSVC ROOT
on:
push:
pull_request:
schedule:
#Every Sunday at midnight
- cron: '0 0 * * 0'
env:
CMAKE_VERSION: 3.16.x
NINJA_VERSION: 1.10.2
BUILD_TYPE: Release
CC: cl
CXX: cl
artifact: "Windows-MSVC.tar.xz"
BUILDCACHE_VERSION: 0.23.0
BUILDCACHE_DIR: ${{ github.workspace }}/buildcache_dir
INSTALL_ROOT: TRUE
ROOT_VERSION: "6.24.00"
ROOT_URL: "https://root.cern/download"
jobs:
# Checkout apply clang-format and upload artifact
format:
name: "Format"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Use clang-format
uses: DoozyX/[email protected]
with:
source: '.'
clangFormatVersion: 11
inplace: True
- name: Setup Python
uses: actions/setup-python@v2
- name: Install cmakelang
uses: BSFishy/pip-action@v1
with:
packages: cmakelang pyyaml jinja2
- name: Use cmake-format
run: find . \( -name '*.cmake' -o -name 'CMakeLists.txt' \) -exec cmake-format -i {} \;
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: clang-format
path: ${{ github.workspace }}
build:
needs: format
name: "Build"
runs-on: windows-latest
strategy:
fail-fast: false
steps:
- uses: actions/download-artifact@v2
with:
name: clang-format
- name: Install cmake
uses: jwlawson/[email protected]
with:
cmake-version: '${{env.CMAKE_VERSION}}'
github-api-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@v3
with:
version: '${{env.NINJA_VERSION}}'
- name: Setup vsdevenv
uses: seanmiddleditch/gha-setup-vsdevenv@master
with:
arch: 'x86'
host_arch: 'x86'
- name: Download buildcache
id: buildcache-download
shell: cmake -P {0}
run: |
set(buildcache_suffix "win-msvc.zip")
set(buildcache_version $ENV{BUILDCACHE_VERSION})
set(buildcache_url "https://github.com/mbitsnbites/buildcache/releases/download/v${buildcache_version}/buildcache-${buildcache_suffix}")
file(DOWNLOAD "${buildcache_url}" ./buildcache.zip)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./buildcache.zip)
- name: Prepare cache timestamp
id: cache_timestamp_string
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d" UTC)
message("::set-output name=timestamp::${current_date}")
- name: Cache Buildcache
id: cache-buildcache
uses: actions/cache@v2
with:
path: ${{ env.BUILDCACHE_DIR }}
key: ${{ matrix.config.name }}-cache-v02-${{ steps.cache_timestamp_string.outputs.timestamp }}
- name: Create Folder for buildcache
run: New-Item ${{ env.BUILDCACHE_DIR }} -ItemType "directory" -Force
shell: pwsh
- name: Add buildcache to system path
run: echo "${{github.workspace}}/buildcache/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
shell: pwsh
- name: Cache ROOT
if: env.INSTALL_ROOT == 'TRUE'
id: cache-root
uses: actions/cache@v2
with:
path: .\root
key: ${{ matrix.config.name }}-${{ steps.cache_timestamp_string.outputs.timestamp }}
- name: Download and unzip ROOT
if: steps.cache-root.outputs.cache-hit != 'true' && env.INSTALL_ROOT == 'TRUE'
shell: cmake -P {0}
run: |
if(${{ env.BUILD_TYPE }} STREQUAL "Debug")
set(ROOT_URL "$ENV{ROOT_URL}/root_v$ENV{ROOT_VERSION}.win32.vc16.debug.zip")
else()
set(ROOT_URL "$ENV{ROOT_URL}/root_v$ENV{ROOT_VERSION}.win32.vc16.zip")
endif()
file(DOWNLOAD "${ROOT_URL}" "./root.zip")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./root.zip)
- name: Set ROOT env
if: env.INSTALL_ROOT == 'TRUE'
shell: cmd
run: .\root\bin\thisroot.bat
- name: Test ROOT
if: env.INSTALL_ROOT == 'TRUE'
shell: cmd
run: .\root\bin\thisroot.bat && root --version
- name: Configure
run: .\root\bin\thisroot.bat && cmake -S . -G Ninja -B build -D CMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -D CMAKE_C_COMPILER_LAUNCHER=buildcache -D CMAKE_CXX_COMPILER_LAUNCHER=buildcache
shell: cmd
- name: Build
run: cmake --build build --config ${{ env.BUILD_TYPE }} --parallel 2
shell: cmd
- name: Run tests
working-directory: ${{ github.workspace }}/build
run: ctest -C ${{ env.BUILD_TYPE }} -j2 -VV --output-on-failure
shell: cmd
- name: Install Strip
run: cmake --install build --prefix instdir --strip
shell: cmd
release:
name: "Release"
if: contains(github.ref, 'tags/v')
runs-on: ubuntu-latest
needs: build
steps:
- name: Create Release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Store Release url
run: |
echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url
- name: Pack
working-directory: instdir
run: cmake -E tar cJfv ../${{ env.artifact }} .
- name: Upload
uses: actions/upload-artifact@v2
with:
path: instdir
name: ${{ env.artifact }}
publish:
if: contains(github.ref, 'tags/v')
name: "Publish"
runs-on: ubuntu-latest
needs: release
steps:
- name: Download artifact
uses: actions/download-artifact@v1
with:
name: ${{ env.artifact }}
path: ./
- name: Download URL
uses: actions/download-artifact@v1
with:
name: upload_url
path: ./
- id: set_upload_url
run: |
upload_url=`cat ./upload_url`
echo ::set-output name=upload_url::$upload_url
- name: Upload to Release
id: upload_to_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.set_upload_url.outputs.upload_url }}
asset_path: ./${{ env.artifact }}
asset_name: ${{ env.artifact }}
asset_content_type: application/x-gtar