-
Notifications
You must be signed in to change notification settings - Fork 7
131 lines (112 loc) · 4.63 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
name: Build
on:
workflow_call:
inputs:
buildConfiguration:
type: string
required: true
description: 'The build configuration to use'
default: 'Release'
outputs:
newVersion:
description: 'The new version number'
value: ${{ jobs.build.outputs.newVersion }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
newVersion: ${{ steps.version.outputs.newVersion }}
steps:
- uses: actions/checkout@v4
- name: Get Version Info
uses: actions/github-script@v7
id: get-version-info
with:
script: |
async function getLatestRelease() {
try {
const response = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
});
core.info('Previous Release Version = ' + response.data.tag_name);
core.setOutput('previousVersion', response.data.tag_name);
} catch (error) {
if (error.status === 404) {
core.info('No releases found for this repository.');
core.setOutput('previousVersion', '0.0.0');
} else {
console.error('An error occurred while fetching the latest release: ', error);
throw error;
}
}
}
async function getCommitMessage() {
try {
const response = await github.rest.repos.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.sha
});
core.info('Commit Message = ' + response.data.commit.message);
core.setOutput('commitMessage', response.data.commit.message);
} catch (error) {
console.error('An error occurred while fetching the commit message: ', error);
throw error;
}
}
await getLatestRelease();
await getCommitMessage();
- name: Version
id: version
shell: pwsh
run: |
$message = @"
${{ steps.get-version-info.outputs.commitMessage }}
"@
./.github/workflows/Version.ps1 -Path "./src/Directory.Build.props" -PreviousVersion ${{ steps.get-version-info.outputs.previousVersion }} -Message $message >> $Env:GITHUB_OUTPUT
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build -c ${{ inputs.buildConfiguration }} --no-restore
- name: Test
run: dotnet test -c ${{ inputs.buildConfiguration }} --no-build --verbosity normal --logger trx --collect:"XPlat Code Coverage" --results-directory TestResults -p:Exclude=\"[Sitecore.AspNetCore.SDK.AutoFixture]*,[Sitecore.AspNetCore.SDK.TestData]*\"
- name: Code Coverage Report
run: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:"TestResults/**/*.xml" -targetdir:"TestResults/Report" -reporttypes:Html -assemblyfilters:"-Sitecore.AspNetCore.SDK.AutoFixture;-Sitecore.AspNetCore.SDK.TestData"
reportgenerator -reports:"TestResults/**/*.xml" -targetdir:"TestResults/Summary" -reporttypes:XmlSummary -assemblyfilters:"-Sitecore.AspNetCore.SDK.AutoFixture;-Sitecore.AspNetCore.SDK.TestData"
- name: Test Summary
shell: pwsh
run: ./.github/workflows/TestSummary.ps1 -CoverageReportPath "./TestResults/Summary/Summary.xml" -ResultFolderPath "./TestResults/*" >> $Env:GITHUB_STEP_SUMMARY
- name: Upload dotnet test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: TestResults
if: ${{ always() }}
- name: Run Benchmarks
working-directory: ./tests/Sitecore.AspNetCore.SDK.RenderingEngine.Benchmarks
run: dotnet run -c Release
- name: Benchmark Summary
working-directory: ./tests/Sitecore.AspNetCore.SDK.RenderingEngine.Benchmarks/BenchmarkDotNet.Artifacts/results
shell: pwsh
run: |
"# :rocket: Benchmarks" >> $Env:GITHUB_STEP_SUMMARY
Get-Content -Path .\* -Filter *.md >> $Env:GITHUB_STEP_SUMMARY
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: perf-results
path: ./tests/Sitecore.AspNetCore.SDK.RenderingEngine.Benchmarks/BenchmarkDotNet.Artifacts
- name: Package
run: dotnet pack -c ${{ inputs.buildConfiguration }} --no-build --output nupkgs
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: packages
path: nupkgs