-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (167 loc) Β· 5.66 KB
/
pr-validation.yml
File metadata and controls
195 lines (167 loc) Β· 5.66 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: PR Validation
on:
pull_request:
branches:
- main
paths-ignore:
- '**.md'
- 'docs/**'
- '.vscode/**'
- '.editorconfig'
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
permissions:
contents: read
pull-requests: write
checks: write
jobs:
validate-pr:
name: Validate PR
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0 # Full history for GitVersion
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
9.0.x
10.0.x
cache: true
cache-dependency-path: |
**/packages.lock.json
global.json
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4
with:
versionSpec: '6.x'
- name: Run GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v4
- name: Set version
id: version
run: |
VERSION="${{ steps.gitversion.outputs.nuGetVersionV2 }}"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "π¦ Version: $VERSION"
- name: Restore dependencies
run: |
dotnet restore --use-lock-file
dotnet tool restore
- name: Build solution
run: |
dotnet build PatternKit.slnx \
--configuration Release \
--no-restore \
/p:ContinuousIntegrationBuild=true \
/p:Deterministic=true
- name: Run tests
run: |
dotnet test PatternKit.slnx \
--configuration Release \
--no-build \
--verbosity normal \
--logger "trx;LogFileName=test-results.trx" \
--collect:"XPlat Code Coverage" \
--results-directory ./TestResults \
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
TestResults/**/*.trx
check_name: Test Results
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v6
if: always()
with:
files: ./TestResults/**/coverage.opencover.xml
flags: unittests
name: pr-${{ github.event.pull_request.number }}
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Build Documentation
run: |
dotnet tool update -g docfx
docfx metadata docs/docfx.json
docfx build docs/docfx.json
- name: Dry-run NuGet packaging
run: |
echo "π¦ Performing dry-run of NuGet packaging..."
mkdir -p ./dry-run-packages
# Package all library projects
for project in src/PatternKit.Core \
src/PatternKit.Generators \
src/PatternKit.Generators.Abstractions; do
if [ -d "$project" ]; then
echo " Packing $project..."
dotnet pack "$project" \
--configuration Release \
--no-build \
--output ./dry-run-packages \
/p:PackageVersion=${{ steps.version.outputs.VERSION }} \
/p:RepositoryUrl=https://github.com/JerrettDavis/PatternKit \
/p:RepositoryType=git \
/p:ContinuousIntegrationBuild=true || echo " β οΈ Failed to pack $project"
fi
done
echo ""
echo "π Dry-run packaging summary:"
ls -lh ./dry-run-packages/*.nupkg 2>/dev/null || echo " No packages created"
- name: Upload dry-run artifacts
uses: actions/upload-artifact@v7
if: always()
with:
name: dry-run-artifacts-${{ github.event.pull_request.number }}
path: |
./dry-run-packages/
retention-days: 7
- name: Create PR comment
uses: actions/github-script@v9
if: always()
with:
script: |
const body = `## π PR Validation Results
**Version:** \`${{ steps.version.outputs.VERSION }}\`
### β
Validation Steps
- [x] Build solution
- [x] Run tests
- [x] Build documentation
- [x] Dry-run NuGet packaging
### π Artifacts
Dry-run artifacts have been uploaded and will be available for 7 days.
---
*This comment was automatically generated by the PR validation workflow.*
`;
// Find existing comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('PR Validation Results')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}