Repository navigation
180 lines (158 loc) · 7.05 KB
/
Copy pathci.yml
File metadata and controls
180 lines (158 loc) · 7.05 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
178
179
180
name: CI
on:
push:
branches: [main, 'feature/**']
paths-ignore:
- 'docs/**'
- '.github/dependabot.yml'
pull_request:
branches: [main]
paths-ignore:
- 'docs/**'
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
pull-requests: write
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
jobs:
build-test-pack:
name: Build, test and package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- name: Setup .NET from global.json
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
- name: Display .NET SDK info
run: dotnet --info
- name: Set deterministic package timestamp
run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> "$GITHUB_ENV"
- name: Cache NuGet packages
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('global.json', 'Directory.Packages.props', 'Directory.Build.props', 'Directory.Build.targets', '**/packages.lock.json') }}
restore-keys: nuget-${{ runner.os }}-
- name: Restore
run: dotnet restore CaeriusNet.slnx --locked-mode
- name: Build (Release)
run: dotnet build CaeriusNet.slnx --configuration Release --no-restore -p:TreatWarningsAsErrors=true
- name: Test unit and compiler projects
run: |
set -euo pipefail
for test_project in \
tests/CaeriusNet.Tests/CaeriusNet.Tests.csproj \
tests/CaeriusNet.Analyzer.Tests/CaeriusNet.Analyzer.Tests.csproj \
tests/CaeriusNet.Generator.Tests/CaeriusNet.Generator.Tests.csproj; do
test_name=$(basename "$(dirname "$test_project")")
dotnet test --project "$test_project" \
--configuration Release \
--no-restore \
--no-build \
--results-directory ./artifacts/test-results \
--report-trx \
--report-trx-filename "$test_name.trx" \
--coverage \
--coverage-output "$test_name.coverage.cobertura.xml" \
--coverage-output-format cobertura
done
- name: Pack the four release artifacts once
run: |
set -euo pipefail
package_directory="$GITHUB_WORKSPACE/artifacts/packages"
mkdir -p "$package_directory"
dotnet pack src/CaeriusNet/CaeriusNet.csproj --configuration Release --no-build --output "$package_directory"
dotnet pack src/CaeriusNet.Redis/CaeriusNet.Redis.csproj --configuration Release --no-build --output "$package_directory"
dotnet pack src/CaeriusNet.Aspire/CaeriusNet.Aspire.csproj --configuration Release --no-build --output "$package_directory"
dotnet pack src/CaeriusNet.Contracts/CaeriusNet.Contracts.csproj --configuration Release --no-build --output "$package_directory"
repro_directory="$RUNNER_TEMP/caeriusnet-packages-repro"
mkdir -p "$repro_directory"
for project in \
src/CaeriusNet/CaeriusNet.csproj \
src/CaeriusNet.Redis/CaeriusNet.Redis.csproj \
src/CaeriusNet.Aspire/CaeriusNet.Aspire.csproj \
src/CaeriusNet.Contracts/CaeriusNet.Contracts.csproj; do
dotnet pack "$project" --configuration Release --no-build --output "$repro_directory"
done
for artifact in "$package_directory"/*.nupkg "$package_directory"/*.snupkg; do
cmp --silent "$artifact" "$repro_directory/$(basename "$artifact")"
done
- name: Exercise packaging acceptance tests from the packed nupkgs
run: |
dotnet test --project tests/CaeriusNet.Packaging.Tests/CaeriusNet.Packaging.Tests.csproj \
--configuration Release \
--no-restore \
--no-build \
--results-directory ./artifacts/test-results/packaging \
--report-trx \
--report-trx-filename packaging-results.trx \
--coverage \
--coverage-output packaging.coverage.cobertura.xml \
--coverage-output-format cobertura
- name: Exercise Contracts Pull and Verify from the packed nupkg
env:
CAERIUS_RUN_CONTAINERS: 'true'
CAERIUS_PACKAGE_DIRECTORY: ${{ github.workspace }}/artifacts/packages
run: |
dotnet test --project tests/CaeriusNet.IntegrationTests/CaeriusNet.IntegrationTests.csproj \
--configuration Release \
--no-restore \
--no-build \
--filter-class "*ContractsPackageAcceptanceTests*" \
--results-directory ./artifacts/test-results/contracts \
--report-trx \
--report-trx-filename contracts-results.trx \
--coverage \
--coverage-output contracts.coverage.cobertura.xml \
--coverage-output-format cobertura
- name: Validate packed artifacts with the repository verifier
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
& ./.github/scripts/ValidatePackage.ps1 `
-Configuration Release `
-PackageDirectory "$env:GITHUB_WORKSPACE/artifacts/packages" `
-OutputDirectory "$env:RUNNER_TEMP/caeriusnet-package-validation"
- name: Verify Source Link
shell: pwsh
run: |
& ./.github/scripts/ValidateSourceLink.ps1 `
-Configuration Release `
-PackageDirectory "$env:GITHUB_WORKSPACE/artifacts/packages"
- name: Restore four isolated consumers from the packed packages
run: bash ./.github/scripts/ValidatePackageConsumers.sh "$GITHUB_WORKSPACE/artifacts/packages" "$RUNNER_TEMP/caeriusnet-consumers"
- name: Upload packages
if: always()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: caeriusnet-packages
path: artifacts/packages/*
retention-days: 30
if-no-files-found: error
- name: Upload test results and coverage
if: always()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: test-results-and-coverage
path: |
artifacts/test-results/**/*.trx
artifacts/test-results/**/*.coverage.cobertura.xml
retention-days: 14
if-no-files-found: warn
- name: Upload coverage to Codecov
if: success()
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v6.0.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: artifacts/test-results/**/*.coverage.cobertura.xml
flags: unittests
name: caeriusnet-coverage
fail_ci_if_error: false