-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (155 loc) · 5.65 KB
/
Copy pathci.yml
File metadata and controls
177 lines (155 loc) · 5.65 KB
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
name: CI
on:
push:
branches: [master, main]
# Version tags pack + publish the library to NuGet (`1.0.2` or `v1.0.2`).
tags: ['v*', '[0-9]*']
pull_request:
branches: [master, main]
workflow_dispatch:
# Least privilege by default. The tag-only publish job pushes to nuget.org via
# the `nuget` environment secret and needs no write access to this repository.
permissions:
contents: read
# Cancel superseded PR runs; never cancel a tag run that may be mid-publish.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
jobs:
build-and-test:
name: build-and-test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
# Report every OS even when one fails.
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
with:
# MinVer derives Version/InformationalVersion from git tags; a
# shallow clone reports the wrong version.
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
cache: true
cache-dependency-path: |
**/*.csproj
**/Directory.Build.props
global.json
- name: Restore
run: dotnet restore
- name: Build
# Full solution. The WPF Tester compiles on Linux/macOS through
# EnableWindowsTargeting=true (it still only runs on Windows).
# -m:1 serializes project builds: XISOSharp.Gui stages the CLI via an
# out-of-band MSBuild call (BuildCliForStaging), and a parallel
# solution build can race writes to the CLI output.
run: dotnet build --no-restore --configuration Release -m:1
- name: Test
# windows-latest only: the suite mutates the process-wide current
# directory, which races on Linux/macOS runners (getcwd fails once a
# test's directory is deleted). The 3-OS matrix still compile-checks
# every project. Scoped to the test project; the solution build above
# already compiled the Windows-only Tester/GUI harnesses.
# --blame-hang-dump-type none: hang dumps are not uploaded (too large),
# so skip collecting them and abort faster on a hung test host.
if: matrix.os == 'windows-latest'
run: >-
dotnet test XISOSharp.Tests/XISOSharp.Tests.csproj
--no-build --configuration Release
--collect:"XPlat Code Coverage"
--logger "trx;LogFileName=results.trx"
--results-directory TestResults
--blame-hang-timeout 15m
--blame-hang-dump-type none
- name: Upload test results
# Always: the trx of a crashed/hung run carries the last-running-test
# and per-test timings for post-mortems.
if: always() && matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: test-results
path: TestResults/**/*.trx
if-no-files-found: warn
- name: Upload coverage
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: TestResults/**/coverage.cobertura.xml
if-no-files-found: warn
pack:
name: pack
runs-on: ubuntu-latest
timeout-minutes: 30
needs: build-and-test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
cache: true
cache-dependency-path: |
**/*.csproj
**/Directory.Build.props
global.json
- name: Restore
run: dotnet restore XISOSharp/XISOSharp.csproj
- name: Build library
run: dotnet build XISOSharp/XISOSharp.csproj --no-restore --configuration Release
- name: Pack
# The library is the only packable project. Strict package validation
# (EnablePackageValidation) runs as part of pack; .snupkg holds symbols.
run: dotnet pack XISOSharp/XISOSharp.csproj --no-build --configuration Release --output artifacts
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: |
artifacts/*.nupkg
artifacts/*.snupkg
if-no-files-found: error
publish-nuget:
name: publish to NuGet
runs-on: ubuntu-latest
timeout-minutes: 15
needs: pack
# Tag pushes only; branch/PR runs stop at pack.
if: startsWith(github.ref, 'refs/tags/')
environment: nuget
steps:
# checkout supplies global.json for setup-dotnet.
- uses: actions/checkout@v4
- name: Download packages
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: artifacts
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
# --skip-duplicate makes re-runs safe (e.g. a manual push already landed).
- name: Push package
run: >-
dotnet nuget push ./artifacts/*.nupkg
--api-key "${{ secrets.NUGET_API_KEY }}"
--source https://api.nuget.org/v3/index.json
--skip-duplicate
- name: Push symbols
run: >-
dotnet nuget push ./artifacts/*.snupkg
--api-key "${{ secrets.NUGET_API_KEY }}"
--source https://api.nuget.org/v3/index.json
--skip-duplicate