-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathazure-pipelines.yml
executable file
·161 lines (127 loc) · 5.14 KB
/
azure-pipelines.yml
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
variables:
title_pack: 'obstacle@smokegun'
user_config_url: 'http://onedrive.live.com/download?cid=2EC0D2E0D9DA402A&resid=2EC0D2E0D9DA402A%2113388&authkey=APoRojn5vQhBS60'
tp_data_url: 'http://onedrive.live.com/download?cid=2EC0D2E0D9DA402A&resid=2EC0D2E0D9DA402A%2113525&authkey=AKLRq2DUxFhuFiU'
maniaplanet_url: 'http://onedrive.live.com/download?cid=2EC0D2E0D9DA402A&resid=2EC0D2E0D9DA402A%2113389&authkey=AC0somuBOCqaAAc'
maker_files_url: 'http://onedrive.live.com/download?cid=2EC0D2E0D9DA402A&resid=2EC0D2E0D9DA402A%2113524&authkey=ALyh4OiUekTaLPI'
trigger:
- master
pool:
vmImage: 'windows-2019'
steps:
- pwsh: |
Invoke-WebRequest "$(user_config_url)" -OutFile "./user.7z"
7z.exe x ./user.7z -bb
New-Item -Path $(Build.StagingDirectory)/User/WorkTitles/$(title_pack) -ItemType SymbolicLink -Value $(Build.SourcesDirectory)
workingDirectory: $(Build.StagingDirectory)
displayName: 'Downloading and Extracting User config'
- pwsh: |
Invoke-WebRequest "$(maniaplanet_url)" -OutFile "./maniaplanet.7z"
7z.exe x ./maniaplanet.7z -bb
workingDirectory: $(Build.StagingDirectory)
displayName: 'Downloading and Extracting Maniaplanet'
- pwsh: |
Invoke-WebRequest "$(maker_files_url)" -OutFile "./maker_files.7z"
7z.exe x ./maker_files.7z -bb
workingDirectory: $(Build.SourcesDirectory)
displayName: 'Downloading and Extracting Maker files'
- pwsh: |
Invoke-WebRequest "$(tp_data_url)" -OutFile "./tp_data_files.7z"
7z.exe x ./tp_data_files.7z -bb
workingDirectory: $(Build.SourcesDirectory)
displayName: 'Downloading and Extracting Titlepack data'
- task: PythonScript@0
displayName: 'Build titlepack'
inputs:
scriptSource: inline
workingDirectory: $(Build.StagingDirectory)
failOnStderr: true
script: |
import time
import subprocess
import glob
import os
import sys
tp = 'obstacle@smokegun'
tp_path = f"./User/Packs/{tp}.Title.Pack.Gbx"
program = f"./Maniaplanet/ManiaplanetLogs.exe /userdir=User /profile=vince /createpack={tp} /windowless /inputless /silent"
logs = './User/Maniaplanet*.txt'
def is_error(line):
return 'error' in line \
or 'Error' in line \
or 'ERROR' in line \
or 'failed' in line
def kill_wait(p):
p.kill()
while p.poll() is None:
continue
print("Maniaplanet.exe was killed properly")
def fail(msg, p = None):
if p is not None:
kill_wait(p)
print(msg)
exit(1)
def build_tp():
# Remove existing logs if any
for filename in [f for f in glob.glob(logs, recursive=True)]:
os.remove(filename)
p = subprocess.Popen(program)
needs_restart = False
last_line = 0
# While Maniaplanet.exe is running
while p.poll() is None:
time.sleep(0.25)
# Find the log file
log_files = [f for f in glob.glob(logs, recursive=True)]
if len(log_files) != 1:
fail("There is more than one log file.", p)
# Open the log file
log = open(log_files[0], 'r')
error = False
restart = False
to_print = []
# Read log file to display new lines
# and check if there is an error
# or if it needs to be restarted
i = 0
for line in log.readlines():
if 'Console' in line:
if i >= last_line:
to_print.append(line)
last_line += 1
error = error or is_error(line)
restart = restart or 'restart' in line
i += 1
log.close()
# Print the new lines
if len(to_print) > 0:
print(log_files[0])
for l in to_print:
print(l, end="")
print()
if error:
print('There is an error in the log file.')
break
if restart:
print("Maniaplanet needs to restart.")
needs_restart = True
break
kill_wait(p)
return needs_restart
if __name__ == "__main__":
should_restart = build_tp()
attempts = 1
while should_restart:
print()
print(f"Attempt {attempts}")
should_restart = build_tp()
attempts += 1
if attempts > 10:
print("Stopped trying after 10 attemps...")
break
if os.path.exists(tp_path):
print("The titlepack was built correctly.")
else:
fail(f"The titlepack was not built correctly. (no {tp_path})")
- publish: $(Build.StagingDirectory)/User/Packs/$(title_pack).Title.Pack.Gbx
artifact: Titlepack