Skip to content

Commit 543ad46

Browse files
committed
add Success
1 parent cfc869a commit 543ad46

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

.github/workflows/make.pas

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@
1818
Dependencies: array of string = ();
1919

2020
type
21+
TLog = (audit, info, error);
2122
Output = record
22-
Code: boolean;
23-
Output: ansistring;
23+
Success: boolean;
24+
Output: string;
2425
end;
2526

26-
procedure OutLog(Knd: string; Msg: string);
27+
28+
procedure OutLog(Knd: TLog; Msg: string);
2729
begin
2830
case Knd of
29-
'error': Writeln(stderr, #27'[31m', Msg, #27'[0m');
30-
'info': Writeln(stderr, #27'[32m', Msg, #27'[0m');
31-
'audit': Writeln(stderr, #27'[33m', Msg, #27'[0m');
31+
error: Writeln(stderr, #27'[31m', Msg, #27'[0m');
32+
info: Writeln(stderr, #27'[32m', Msg, #27'[0m');
33+
audit: Writeln(stderr, #27'[33m', Msg, #27'[0m');
3234
end;
3335
end;
3436

@@ -37,7 +39,7 @@ Output = record
3739
if FileExists('.gitmodules') then
3840
if RunCommand('git', ['submodule', 'update', '--init', '--recursive',
3941
'--force', '--remote'], Result.Output) then
40-
OutLog('info', Result.Output);
42+
OutLog(info, Result.Output);
4143
end;
4244

4345
function AddPackage(Path: string): Output;
@@ -53,7 +55,7 @@ Output = record
5355
;
5456
if not Exec(Path) and RunCommand('lazbuild', ['--add-package-link', Path],
5557
Result.Output) then
56-
OutLog('audit', 'added ' + Path);
58+
OutLog(audit, 'added ' + Path);
5759
Free;
5860
end;
5961
end;
@@ -62,17 +64,17 @@ Output = record
6264
var
6365
Line: string;
6466
begin
65-
OutLog('audit', 'build from ' + Path);
67+
OutLog(audit, 'build from ' + Path);
6668
try
67-
Result.Code := RunCommand('lazbuild', ['--build-all', '--recursive',
69+
Result.Success := RunCommand('lazbuild', ['--build-all', '--recursive',
6870
'--no-write-project', Path], Result.Output);
69-
if Result.Code then
71+
if Result.Success then
7072
for Line in SplitString(Result.Output, LineEnding) do
7173
begin
7274
if ContainsStr(Line, 'Linking') then
7375
begin
7476
Result.Output := SplitString(Line, ' ')[2];
75-
OutLog('info', ' to ' + Result.Output);
77+
OutLog(info, ' to ' + Result.Output);
7678
break;
7779
end;
7880
end
@@ -84,13 +86,13 @@ Output = record
8486
begin
8587
Expression := '(Fatal|Error):';
8688
if Exec(Line) then
87-
OutLog('error', #10 + Line);
89+
OutLog(error, #10 + Line);
8890
Free;
8991
end;
9092
end;
9193
except
9294
on E: Exception do
93-
OutLog('error', E.ClassName + #13#10 + E.Message);
95+
OutLog(error, E.ClassName + #13#10 + E.Message);
9496
end;
9597
end;
9698

@@ -100,16 +102,16 @@ Output = record
100102
begin
101103
Result := BuildProject(Path);
102104
Temp:= Result.Output;
103-
if Result.Code then
105+
if Result.Success then
104106
try
105107
if not RunCommand(Temp, ['--all', '--format=plain', '--progress'], Result.Output) then
106108
begin
107109
ExitCode += 1;
108-
OutLog('error', Result.Output);
110+
OutLog(error, Result.Output);
109111
end;
110112
except
111113
on E: Exception do
112-
OutLog('error', E.ClassName + #13#10 + E.Message);
114+
OutLog(error, E.ClassName + #13#10 + E.Message);
113115
end;
114116
end;
115117

@@ -136,7 +138,7 @@ Output = record
136138
AddHeader('User-Agent', 'Mozilla/5.0 (compatible; fpweb)');
137139
AllowRedirect := True;
138140
Get(Uri, Zip);
139-
OutLog('audit', 'Download from ' + Uri + ' to ' + OutFile);
141+
OutLog(audit, 'Download from ' + Uri + ' to ' + OutFile);
140142
finally
141143
Free;
142144
end;
@@ -150,7 +152,7 @@ Output = record
150152
OutputPath := Result;
151153
Examine;
152154
UnZipAllFiles;
153-
OutLog('audit', 'Unzip from ' + OutFile + ' to ' + Result);
155+
OutLog(audit, 'Unzip from ' + OutFile + ' to ' + Result);
154156
finally
155157
Free;
156158
end;
@@ -195,9 +197,9 @@ Output = record
195197
List.Free;
196198
end;
197199
if ExitCode <> 0 then
198-
OutLog('error', #10 + 'Errors: ' + IntToStr(ExitCode))
200+
OutLog(error, #10 + 'Errors: ' + IntToStr(ExitCode))
199201
else
200-
OutLog('info', #10 + 'Errors: ' + IntToStr(ExitCode));
202+
OutLog(info, #10 + 'Errors: ' + IntToStr(ExitCode));
201203
end;
202204

203205
begin

.github/workflows/make.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ jobs:
3535
run: |
3636
sudo bash -c 'apt-get update; apt-get install -y lazarus' >/dev/null
3737
instantfpc "-Fu/usr/lib/lazarus/3.0/components/lazutils" .github/workflows/make.pas
38-
delp -vr "${PWD}"
38+
delp -r "${PWD}"

0 commit comments

Comments
 (0)