-
Notifications
You must be signed in to change notification settings - Fork 13
142 lines (113 loc) · 4.85 KB
/
pr_ci.yml
File metadata and controls
142 lines (113 loc) · 4.85 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
name: PR CI
on:
pull_request:
types:
- opened
- synchronize
- reopened
permissions:
contents: read
jobs:
verify:
name: Format, Build, Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
10.0.x
8.0.x
- name: Detect changed projects
id: changes
shell: bash
run: |
set -euo pipefail
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
CHANGED="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")"
echo "Changed files:"
printf '%s\n' "$CHANGED"
build_godotutils=false
build_visualize=false
build_packetgen=false
build_optionsgen=false
build_template=false
echo "$CHANGED" | grep -q "^Template\.GodotUtils/" && build_godotutils=true || true
echo "$CHANGED" | grep -q "^Template\.Visualize/" && build_visualize=true || true
echo "$CHANGED" | grep -q "^Template\.PacketGen/" && build_packetgen=true || true
echo "$CHANGED" | grep -q "^Template\.OptionsGen/" && build_optionsgen=true || true
echo "$CHANGED" | grep -Eq "\.cs$" && build_optionsgen=true || true
echo "$CHANGED" | grep -q "^Template/" && build_template=true || true
if $build_visualize; then
build_godotutils=true
fi
if echo "$CHANGED" | grep -Eq "^(Template\.sln|\.editorconfig|NuGet\.config|\.githooks/|\.github/workflows/)"; then
build_godotutils=true
build_visualize=true
build_packetgen=true
build_optionsgen=true
build_template=true
fi
if ! $build_godotutils && ! $build_visualize && ! $build_packetgen && ! $build_optionsgen && ! $build_template; then
echo "No known project paths changed. Falling back to full validation."
build_godotutils=true
build_visualize=true
build_packetgen=true
build_optionsgen=true
build_template=true
fi
{
echo "build_godotutils=$build_godotutils"
echo "build_visualize=$build_visualize"
echo "build_packetgen=$build_packetgen"
echo "build_optionsgen=$build_optionsgen"
echo "build_template=$build_template"
} >> "$GITHUB_OUTPUT"
- name: Restore
run: dotnet restore Template.sln
- name: Format checks (targeted)
shell: bash
run: |
set -euo pipefail
if [[ "${{ steps.changes.outputs.build_godotutils }}" == "true" ]]; then
dotnet format Template.GodotUtils/GodotUtils.csproj --verify-no-changes
fi
if [[ "${{ steps.changes.outputs.build_visualize }}" == "true" ]]; then
dotnet format Template.Visualize/Visualize.csproj --verify-no-changes
fi
if [[ "${{ steps.changes.outputs.build_packetgen }}" == "true" ]]; then
dotnet format Template.PacketGen/PacketGen.sln --verify-no-changes
fi
if [[ "${{ steps.changes.outputs.build_optionsgen }}" == "true" ]]; then
dotnet format Template.OptionsGen/OptionsGen/OptionsGen.csproj --verify-no-changes
fi
if [[ "${{ steps.changes.outputs.build_template }}" == "true" ]]; then
dotnet format Template/Template.csproj --verify-no-changes
fi
- name: Targeted builds
shell: bash
run: |
set -euo pipefail
if [[ "${{ steps.changes.outputs.build_godotutils }}" == "true" ]]; then
dotnet build Template.GodotUtils/GodotUtils.csproj --no-restore -p:BuildExtras=true -warnaserror
fi
if [[ "${{ steps.changes.outputs.build_visualize }}" == "true" ]]; then
dotnet build Template.Visualize/Visualize.csproj --no-restore -p:BuildExtras=true -warnaserror
fi
if [[ "${{ steps.changes.outputs.build_packetgen }}" == "true" ]]; then
dotnet build Template.PacketGen/PacketGen/PacketGen.csproj -c Release --no-restore -warnaserror
fi
if [[ "${{ steps.changes.outputs.build_optionsgen }}" == "true" ]]; then
dotnet build Template.OptionsGen/OptionsGen/OptionsGen.csproj -c Release --no-restore -warnaserror
fi
if [[ "${{ steps.changes.outputs.build_template }}" == "true" ]]; then
dotnet build Template/Template.csproj --no-restore -warnaserror
fi
- name: Full solution build
run: dotnet build Template.sln --no-restore -warnaserror
- name: Tests
run: dotnet test Template.PacketGen/PacketGen.Tests/PacketGen.Tests.csproj --no-build