-
-
Notifications
You must be signed in to change notification settings - Fork 23
143 lines (128 loc) · 6.14 KB
/
integration_tests.yml
File metadata and controls
143 lines (128 loc) · 6.14 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: "Integration tests"
on:
release:
types: [published]
concurrency:
group: ci-integration-${{ github.ref }}-1
cancel-in-progress: true
jobs:
run_test_conversions:
runs-on: [self-hosted, windows]
strategy:
fail-fast: false
matrix:
save_url:
# 2.0 vanilla
- https://www.dropbox.com/scl/fi/jvb6s0zm02r3v30w09mzs/453.12.28-Dumnoniens.rome?rlkey=98y1jcscjy76mhva3m5qtyvid&st=khop16qy&dl=1 # 453.12.28 - Dumnoniens.rome
# 2.0 with mods
# - https://www.dropbox.com/scl/fi/whvbcjeojipt2ysqbwcp2/848.7.14-Indian-Empire-2.rome?rlkey=xqm0a0t24rbf8vkuepwrbezqt&st=gq3avjck&dl=1 # 848.7.14 - Indian Empire - 2.rome, uploaded 2024-06-30
# - https://www.dropbox.com/scl/fi/xya8828ceb4h3ls3dixjc/Grande-Campagne.rome?rlkey=bjihvjtdnwtzlju95o7ekkpbm&st=txoi1lk2&dl=1 # Grande Campagne.rome, uploaded 2024-09-11
- https://www.dropbox.com/scl/fi/q22wnjljvcjev6yem0kp2/Roman-Empire-Convert-Save-2.rome?rlkey=15vxn4wvrzn1fde14qn6zqvfu&st=59s2cgj7&dl=1 # Roman Empire Convert Save 2.rome, uploaded 2024-09-23
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: "Check if docs folders exist"
run: |
ls "C:\Users\Administrator\Documents\Paradox Interactive\Imperator"
ls "C:\Users\Administrator\Documents\Paradox Interactive\Imperator\mod"
ls "C:\Users\Administrator\Documents\Paradox Interactive\Crusader Kings III\mod"
# - name: "Setup Dotnet for use with actions"
# uses: actions/setup-dotnet@v4
# with:
# global-json-file: global.json
- name: "Build converter backend"
working-directory: ImperatorToCK3
run: |
dotnet build -c:Release
- name: "Download I:R save from Dropbox"
run: |
Invoke-WebRequest -Uri "${{ matrix.save_url }}" -OutFile "save.rome"
- name: "Create configuration.txt"
working-directory: Release/ImperatorToCK3
run: |
echo 'ImperatorDirectory = "C:\Program Files (x86)\Steam\steamapps\common\ImperatorRome"' > configuration.txt
echo 'ImperatorDocDirectory = "C:\Users\Administrator\Documents\Paradox Interactive\Imperator"' >> configuration.txt
echo 'CK3directory = "C:\Program Files (x86)\Steam\steamapps\common\Crusader Kings III"' >> configuration.txt
echo 'targetGameModPath = "C:\Users\Administrator\Documents\Paradox Interactive\Crusader Kings III\mod"' >> configuration.txt
echo 'SaveGame = "../../save.rome"' >> configuration.txt
echo 'SkipDynamicCoAExtraction = yes' >> configuration.txt
echo 'output_name = "test_save"' >> configuration.txt
cat configuration.txt
- name: "Run conversion"
working-directory: Release/ImperatorToCK3
run: |
dotnet ImperatorToCK3Converter.dll
- name: "Download and unzip ck3-tiger"
run: |
Invoke-WebRequest -Uri "https://github.com/amtep/tiger/releases/download/v1.17.0/ck3-tiger-windows-v1.17.0.zip" -OutFile "ck3-tiger.zip"
Expand-Archive -Path "ck3-tiger.zip" -DestinationPath "ck3-tiger"
Remove-Item -Path "ck3-tiger.zip"
- name: "Validate generated mod with ck3-tiger"
run: |
# Run ck3-tiger validation on the generated mod
$modPath = "$env:GITHUB_WORKSPACE\Release\ImperatorToCK3\output\test_save"
$tigerPath = "$env:GITHUB_WORKSPACE\ck3-tiger\ck3-tiger.exe"
$tigerConfigPath = "$env:GITHUB_WORKSPACE\.github\workflows\ck3-tiger.conf"
# Run tiger and capture output
cmd /c "`"$tigerPath`" --no-color --consolidate --config `"$tigerConfigPath`" `"$modPath`" > result.txt 2> result-error.txt"
# Display any errors from stderr
if (Test-Path "result-error.txt") {
$errorContent = Get-Content "result-error.txt" -Raw
if ($errorContent) {
Write-Host $errorContent
}
}
# Count base errors (initialization failures)
$baseErrors = 0
if (Test-Path "result-error.txt") {
$baseErrors = (Select-String -Path "result-error.txt" -Pattern "Error" -AllMatches).Matches.Count
}
# Check if validator failed to initialize
if ($baseErrors -gt 0) {
Write-Host ""
Write-Host "The validator could not be initialized!" -ForegroundColor Red -BackgroundColor Black
exit 1
}
# Process results if file exists and has content
if ((Test-Path "result.txt") -and (Get-Item "result.txt").Length -gt 0) {
# Display full results
Get-Content "result.txt"
# Count different types of issues
$warnings = (Select-String -Path "result.txt" -Pattern "warning\(" -AllMatches).Matches.Count
$errors = (Select-String -Path "result.txt" -Pattern "error\(" -AllMatches).Matches.Count
$fatal = (Select-String -Path "result.txt" -Pattern "fatal\(" -AllMatches).Matches.Count
# Check if validation failed
if ($warnings -gt 0 -or $errors -gt 0 -or $fatal -gt 0) {
Write-Host ""
Write-Host "There are warnings or errors. The validation failed!" -ForegroundColor Red -BackgroundColor Black
exit 1
}
} else {
Write-Host ""
Write-Host "Successfully validated!" -ForegroundColor Green -BackgroundColor Black
}
- name: "Cleanup"
if: always()
run: |
function Remove-ItemWithRetry {
param (
[string]$Path,
[int]$Retries = 5,
[int]$Delay = 2000
)
for ($i = 0; $i -lt $Retries; $i++) {
try {
Remove-Item -Path $Path -Force -Recurse
Write-Host "Successfully deleted $Path"
return
} catch {
Write-Host "Attempt $($i+1) failed: $_"
Start-Sleep -Milliseconds $Delay
}
}
throw "Failed to delete $Path after $Retries attempts"
}
Get-ChildItem -Path $Env:GITHUB_WORKSPACE -Recurse -Force | ForEach-Object {
Remove-ItemWithRetry -Path $_.FullName
}