-
Notifications
You must be signed in to change notification settings - Fork 12
224 lines (197 loc) · 7.78 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
# $schema: https://json.schemastore.org/github-action.json
name: build
on:
push:
branches:
- "*"
paths-ignore:
- "doc/**"
- "scripts/*"
- "**/*.md"
# the push trigger does not apply to PRs from another fork
pull_request:
paths:
- "!doc/**"
- "!scripts/*"
- "!**/*.md"
jobs:
build:
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "true"
# defaults:
# run:
# # apparently pwsh commands are templated into a temp file outside the current directory
# working-directory: "${{ github.workspace }}"
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
rid: win-x64
configuration: Release
runTests: true
- os: ubuntu-latest
rid: linux-x64
configuration: Release
runTests: true
- os: macos-latest
rid: osx-x64
configuration: Release
runTests: true
# For Raspberry Pis
- os: ubuntu-latest
rid: linux-arm
configuration: Release
runTests: false # not currently supported by github actions
# For generic linux arm
- os: ubuntu-latest
rid: linux-arm64
configuration: Release
runTests: false # not currently supported by github actions, but also failing in .NET project SDKs. Try again in .NET 6?
# TODO: add support for macos-arm
- os: ubuntu-latest
rid: ""
configuration: Release
runTests: true
- os: ubuntu-latest
rid: "linux-musl-x64"
configuration: Release
runTests: true
name: "${{ matrix.rid || 'Any' }}, ${{ matrix.configuration }}"
runs-on: ${{ matrix.os }}
steps:
# NOTE: the preliminary steps should be identical to ./build-docs.yml
# checkout code and cache lfs
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 200
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v2
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
- name: Git LFS Pull
run: git lfs pull
# fetch more tag info so git_version.ps1 works properly
- name: Ensure tags are fetched
# Retrieve annotated tags.
run: git fetch --tags --force
- name: Install build dependencies
shell: pwsh
run: ./build/install_dependencies.ps1 '${{ matrix.rid }}'
# setup and build solution
- name: Setup .NET
uses: actions/setup-dotnet@v1
# enable stdout with ::echo::on
- name: Calculate variables
id: calc_vars
shell: pwsh
run: |
echo "::echo::on"
. ./build/ci.ps1
$runtime_arg = '${{ matrix.rid }}' ? '--runtime ${{ matrix.rid }}' : ''
Set-CiOutput "RUNTIME_ARG" "$runtime_arg"
$is_self_contained = '${{ matrix.rid }}' -ne ''
$self_contained_arg = '${{ matrix.rid }}' ? '--self-contained' : ''
Set-CiOutput "SELF_CONTAINED_ARG" "$self_contained_arg"
$variant_tag = '${{ matrix.rid }}' ? '${{ matrix.rid }}' : 'any'
Set-CiOutput "VARIANT_TAG" "$variant_tag"
$vars = . ./src/git_version.ps1 -configuration ${{ matrix.configuration }} -self_contained "$is_self_contained" -runtime_identifier '${{ matrix.rid }}' -env_vars -prefix "AP_"
$vars | Write-Output
$vars | Set-Content
$vars | ConvertTo-Json | Out-File "${{ runner.temp }}/AP_vars.json"
Set-CiOutput "AP_VERSION" "${env:AP_Version}"
$extension = $IsWindows ? ".zip" : ".tar.xz"
$configuration_tag = '${{ matrix.configuration }}' -eq 'Release' ? '' : '_Debug'
$artifact_tag = "AP_${variant_tag}_${{ matrix.configuration }}_${env:AP_Version}"
Set-CiOutput "ARTIFACT_TAG" "$artifact_tag"
$artifact_path = "${{ runner.temp }}/AP_${variant_tag}${configuration_tag}_v${env:AP_Version}${extension}"
Set-CiOutput "ARTIFACT_PATH" "$artifact_path"
- uses: actions/cache@v2
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget--${{ hashFiles('**/*.*proj') }} # hash of project files
restore-keys: |
${{ runner.os }}-nuget
- name: Restore dependencies
run: >
dotnet restore
${{ steps.calc_vars.outputs.RUNTIME_ARG }}
# The warnings are numerous for our project. Pure spam including them in our CI log, hence disabled with WarningLevel=0
# Caution: leading whitespace is interpreted like a line break
# Note: project must be specified for an RID specific build
- name: Build
run: >
dotnet build
src/AnalysisPrograms/AnalysisPrograms.csproj
--no-restore
--configuration ${{ matrix.configuration }}
${{ steps.calc_vars.outputs.RUNTIME_ARG }}
-p:WarningLevel=0
- name: Test
id: test_run
if: "matrix.runTests"
run: >
dotnet test
tests/Acoustics.Test/Acoustics.Test.csproj
-p:WarningLevel=0
--configuration ${{ matrix.configuration }}
${{ steps.calc_vars.outputs.RUNTIME_ARG }}
--logger trx
--settings tests/Acoustics.Test/.runsettings
--collect:"XPlat Code Coverage"
--results-directory '${{runner.temp}}/Acoustics.Test_Results'
# D:\a\_temp\Acoustics.Test_Results\runneradmin_fv-az41-747_2021-06-21_23_15_12.trx
- name: Publish Test Results
if: "always() && (steps.test_run.outcome == 'success' || steps.test_run.outcome == 'failure')"
uses: dorny/[email protected]
with:
name: "Test Results: ${{ matrix.rid || 'Any' }}, ${{ matrix.configuration }}"
path: "${{ runner.temp }}/Acoustics.Test_Results/**/*.trx"
reporter: "dotnet-trx"
fail-on-error: "false"
path-replace-backslashes: "true"
- name: Publish code coverage
if: always() && (steps.test_run.outcome == 'success' || steps.test_run.outcome == 'failure')
uses: codecov/codecov-action@v1
with:
directory: "${{runner.temp}}/Acoustics.Test_Results"
verbose: true
- name: Publish build
run: >
dotnet publish --no-build
src/AnalysisPrograms/AnalysisPrograms.csproj
--configuration ${{ matrix.configuration }}
${{ steps.calc_vars.outputs.RUNTIME_ARG }}
--output "${{runner.temp}}/publish"
${{ steps.calc_vars.outputs.SELF_CONTAINED_ARG }}
- name: Create archive
uses: knicknic/[email protected]
with:
macos: |
cd "${{runner.temp}}/publish"
tar -cvJf "${{ steps.calc_vars.outputs.ARTIFACT_PATH }}" *
linux: |
cd "${{runner.temp}}/publish"
tar -cvJf "${{ steps.calc_vars.outputs.ARTIFACT_PATH }}" *
windows: >
7z a -tzip "${{ steps.calc_vars.outputs.ARTIFACT_PATH }}" "${{runner.temp}}\publish\*"
- name: debug generated assets
if: always()
shell: pwsh
run: Get-ChildItem -Recurse "${{ runner.temp }}"
- name: Upload the build results
uses: actions/upload-artifact@v2
with:
name: ${{ steps.calc_vars.outputs.ARTIFACT_TAG }}
path: ${{ steps.calc_vars.outputs.ARTIFACT_PATH }}
- name: Upload AP_vars
uses: actions/upload-artifact@v2
with:
name: AP_vars
path: "${{ runner.temp }}/AP_vars.json"