-
Notifications
You must be signed in to change notification settings - Fork 240
131 lines (126 loc) · 4.98 KB
/
Copy pathpull_request.yml
File metadata and controls
131 lines (126 loc) · 4.98 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
name: Pull Request
on:
pull_request:
branches: [ master ]
jobs:
build:
name: Build
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
10.0.x
- name: Build
working-directory: ./source
run: dotnet build -c Release
test:
name: Tests on ${{ matrix.os }}
needs: [ build ]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
10.0.x
- name: Test
working-directory: ./source
run: dotnet test --logger:trx --logger:GitHubActions
sonar-pr:
name: SonarCloud
# Secrets are not available for fork PRs; skip rather than fail with an empty token.
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
10.0.x
- uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'zulu'
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v4
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Run tests
run: dotnet test source/Handlebars.sln --logger:trx --collect:"XPlat Code Coverage" --settings source/Handlebars.Test/coverlet.runsettings
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
PR_KEY: ${{ github.event.number }}
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
PR_BASE: ${{ github.event.pull_request.base.ref }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"Handlebars-Net_Handlebars.Net" /o:"handlebars-net" /d:sonar.token="$env:SONAR_TOKEN" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="**/*.opencover.xml" /d:sonar.cs.vstest.reportsPaths="**/*.trx" /d:sonar.coverage.exclusions="**/*.md;source/Handlebars.Benchmark/**/*.*" /d:sonar.cpd.exclusions="source/Handlebars/Iterators/**/*.*" /d:sonar.pullrequest.key="$env:PR_KEY" /d:sonar.pullrequest.branch="$env:PR_BRANCH" /d:sonar.pullrequest.base="$env:PR_BASE"
dotnet build source/Handlebars.sln -c Release
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="$env:SONAR_TOKEN"
benchmark:
name: Run Benchmark.Net
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
10.0.x
- name: Run benchmark
working-directory: ./source/Handlebars.Benchmark
run: dotnet run -c Release -f net10.0 --exporters json --filter '*' --join
- name: Get benchmark file name
working-directory: ./source/Handlebars.Benchmark/BenchmarkDotNet.Artifacts/results
id: benchmarkfilename
run: |
filePath=$(find . -type f -name 'BenchmarkRun-joined-*-report-full-compressed.json' | rev | cut -d '/' -f1 | rev)
echo $filePath
echo "file=$filePath" >> $GITHUB_OUTPUT
- name: Store benchmark result
uses: Happypig375/github-action-benchmark@e7cb068f90622402c0ae5b54e2c781052fcd9343 # v1.8.2
with:
name: Benchmark.Net Benchmark
tool: 'benchmarkdotnet'
output-file-path: source/Handlebars.Benchmark/BenchmarkDotNet.Artifacts/results/${{ steps.benchmarkfilename.outputs.file }}
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: false # disabled for PRs
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: false
alert-comment-cc-users: '@zjklee'
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Benchmark
path: source/Handlebars.Benchmark/BenchmarkDotNet.Artifacts/results/