-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (112 loc) · 3.81 KB
/
Copy pathpr-validation.yml
File metadata and controls
139 lines (112 loc) · 3.81 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
name: PR Validation
on:
pull_request:
branches: [ main, develop ]
types: [opened, synchronize, reopened]
env:
DOTNET_VERSION: '10.0.x'
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
permissions:
contents: read
pull-requests: write
checks: write
jobs:
validate-pr:
name: Validate Pull Request
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore PokManager.sln
- name: Check code formatting
run: dotnet format PokManager.sln --verify-no-changes --verbosity diagnostic
- name: Build solution
run: dotnet build PokManager.sln --configuration Release --no-restore
- name: Run tests
run: dotnet test PokManager.sln --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" --results-directory ./TestResults
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2.24.0
if: always()
with:
files: TestResults/**/*.trx
check_name: PR Test Results
comment_mode: off
code-quality:
name: Code Quality Checks
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore PokManager.sln
- name: Build for analysis
run: dotnet build PokManager.sln --configuration Release --no-restore
- name: Check for TODO/FIXME comments
run: |
echo "Checking for TODO/FIXME comments..."
if grep -r "TODO\|FIXME" src/ --include="*.cs" | grep -v "PokManager.AppHost"; then
echo "Found TODO/FIXME comments. Please review before merging."
else
echo "No TODO/FIXME comments found."
fi
dependency-check:
name: Dependency Validation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Check for deprecated packages
run: |
echo "Checking for deprecated NuGet packages..."
dotnet list package --deprecated || true
- name: Check for vulnerable packages
run: |
echo "Checking for vulnerable NuGet packages..."
dotnet list package --vulnerable || true
- name: Check for outdated packages
run: |
echo "Checking for outdated NuGet packages..."
dotnet list package --outdated || true
pr-status:
name: PR Status Check
needs: [validate-pr, code-quality, dependency-check]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check all jobs
run: |
# Treat skipped jobs (from dependabot) as success
VALIDATE_STATUS="${{ needs.validate-pr.result }}"
QUALITY_STATUS="${{ needs.code-quality.result }}"
DEPENDENCY_STATUS="${{ needs.dependency-check.result }}"
if [ "$VALIDATE_STATUS" == "skipped" ]; then VALIDATE_STATUS="success"; fi
if [ "$QUALITY_STATUS" == "skipped" ]; then QUALITY_STATUS="success"; fi
if [ "$VALIDATE_STATUS" == "success" ] && \
[ "$QUALITY_STATUS" == "success" ] && \
[ "$DEPENDENCY_STATUS" == "success" ]; then
echo "All PR validation checks passed!"
exit 0
else
echo "Some PR validation checks failed!"
exit 1
fi