Repository navigation
120 lines (108 loc) · 5.36 KB
/
Copy pathtest.yml
File metadata and controls
120 lines (108 loc) · 5.36 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
name: Reusable Test
on:
workflow_call:
inputs:
dotnet-version:
description: .NET SDK version
required: false
type: string
default: '10.0.x'
test-dir:
description: Directory containing unit test project
required: false
type: string
default: 'Tests'
arch-test-dir:
description: Directory containing architecture test project
required: false
type: string
default: 'ArchTests'
arch-phases:
description: Comma-separated list of arch-test phases to run (A,B,C,D,E,N,Full)
required: false
type: string
default: 'Full'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Normalize Workspace Directory Alias
run: |
MOD_SHORT=$(echo "${{ github.event.repository.name }}" | sed 's/^RimWorld-RimMind-Mod-/RimMind-/')
if [ ! -e "../$MOD_SHORT" ]; then
ln -s "$GITHUB_WORKSPACE" "../$MOD_SHORT"
fi
- name: Discover Test Projects
id: check_tests
run: |
if [ -d "${{ inputs.test-dir }}" ]; then
csproj=$(find "${{ inputs.test-dir }}" -maxdepth 1 -name '*.Tests.csproj' -print -quit 2>/dev/null)
if [ -n "$csproj" ]; then
echo "has_tests=true" >> $GITHUB_OUTPUT
echo "csproj=$(basename "$csproj")" >> $GITHUB_OUTPUT
else
echo "has_tests=false" >> $GITHUB_OUTPUT
fi
else
echo "has_tests=false" >> $GITHUB_OUTPUT
fi
if [ -d "IntegrationTests" ]; then
int_csproj=$(find IntegrationTests -maxdepth 1 -name '*.Tests.csproj' -print -quit 2>/dev/null)
if [ -n "$int_csproj" ]; then
echo "has_integration=true" >> $GITHUB_OUTPUT
echo "int_csproj=$(basename "$int_csproj")" >> $GITHUB_OUTPUT
else
echo "has_integration=false" >> $GITHUB_OUTPUT
fi
else
echo "has_integration=false" >> $GITHUB_OUTPUT
fi
if [ -d "${{ inputs.arch-test-dir }}" ]; then
arch_csproj=$(find "${{ inputs.arch-test-dir }}" -maxdepth 1 -name '*.ArchTests.csproj' -print -quit 2>/dev/null)
if [ -n "$arch_csproj" ]; then
echo "has_arch=true" >> $GITHUB_OUTPUT
echo "arch_csproj=$(basename "$arch_csproj")" >> $GITHUB_OUTPUT
else
echo "has_arch=false" >> $GITHUB_OUTPUT
fi
else
echo "has_arch=false" >> $GITHUB_OUTPUT
fi
- name: Setup .NET
if: steps.check_tests.outputs.has_tests == 'true' || steps.check_tests.outputs.has_integration == 'true' || steps.check_tests.outputs.has_arch == 'true'
uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ inputs.dotnet-version }}
- name: Prepare Core & Build Dependencies (1.6 & 1.7)
if: steps.check_tests.outputs.has_tests == 'true' || steps.check_tests.outputs.has_integration == 'true' || steps.check_tests.outputs.has_arch == 'true'
run: |
if [ "${{ github.event.repository.name }}" != "RimWorld-RimMind-Mod-Core" ] && [ "${{ github.event.repository.name }}" != "RimMind-Core" ] && [ ! -d "../RimMind-Core" ]; then
git clone --depth 1 https://github.com/RimWorld-RimMind-Mod/RimWorld-RimMind-Mod-Core.git ../RimMind-Core
dotnet build ../RimMind-Core/Source/RimMindCore.csproj -c Release -p:GameVersion=1.6
dotnet build ../RimMind-Core/Source/RimMindCore.csproj -c Release -p:GameVersion=1.7
fi
if ( [ "${{ github.event.repository.name }}" = "RimWorld-RimMind-Mod-Advisor" ] || [ "${{ github.event.repository.name }}" = "RimMind-Advisor" ] ) && [ ! -d "../RimMind-Actions" ]; then
git clone --depth 1 https://github.com/RimWorld-RimMind-Mod/RimWorld-RimMind-Mod-Actions.git ../RimMind-Actions
dotnet build ../RimMind-Actions/Source/RimMindActions.csproj -c Release -p:GameVersion=1.6
dotnet build ../RimMind-Actions/Source/RimMindActions.csproj -c Release -p:GameVersion=1.7
fi
src_csproj=$(find Source -maxdepth 1 -name '*.csproj' -print -quit 2>/dev/null || true)
if [ -n "$src_csproj" ]; then
dotnet build "$src_csproj" -c Release -p:GameVersion=1.6
dotnet build "$src_csproj" -c Release -p:GameVersion=1.7
fi
- name: Restore & Build Unit Tests
if: steps.check_tests.outputs.has_tests == 'true'
run: |
dotnet restore ${{ inputs.test-dir }}/${{ steps.check_tests.outputs.csproj }}
dotnet build ${{ inputs.test-dir }}/${{ steps.check_tests.outputs.csproj }} --no-restore -c Release
- name: Run Unit Tests
if: steps.check_tests.outputs.has_tests == 'true'
run: dotnet test ${{ inputs.test-dir }}/${{ steps.check_tests.outputs.csproj }} --no-build -c Release --verbosity normal
- name: Run Integration Tests
if: steps.check_tests.outputs.has_integration == 'true'
run: dotnet test IntegrationTests/${{ steps.check_tests.outputs.int_csproj }} -c Release --verbosity normal
- name: Run Architecture Tests
if: steps.check_tests.outputs.has_arch == 'true'
run: dotnet test ${{ inputs.arch-test-dir }}/${{ steps.check_tests.outputs.arch_csproj }} -c Release --verbosity normal