From 93e93fd65c8a21da6c9f26606003d73178fcc79e Mon Sep 17 00:00:00 2001 From: "Artem V. Ageev" Date: Thu, 16 Jan 2025 19:35:48 +0200 Subject: [PATCH] fix github-actions --- .github/workflows/make.pas | 79 +++++++++++++++++++++----------------- .gitmodules | 13 +------ packages/dopf | 1 - packages/xmailer | 1 - 4 files changed, 46 insertions(+), 48 deletions(-) delete mode 160000 packages/dopf delete mode 160000 packages/xmailer diff --git a/.github/workflows/make.pas b/.github/workflows/make.pas index 306c8c0..42eaa9f 100644 --- a/.github/workflows/make.pas +++ b/.github/workflows/make.pas @@ -15,20 +15,31 @@ const Target: string = 'demos'; - Dependencies: array of string = ('Rhl'); + Dependencies: array of string = ('Rhl', 'XMailer', 'dOPF', 'Brookframework'); type + TLog = (audit, info, error); Output = record Code: boolean; Output: ansistring; end; + + procedure OutLog(Knd: TLog; Msg: string); + begin + case Knd of + error: Writeln(stderr, #27'[31m', Msg, #27'[0m'); + info: Writeln(stderr, #27'[32m', Msg, #27'[0m'); + audit: Writeln(stderr, #27'[33m', Msg, #27'[0m'); + end; + end; + function CheckModules: Output; begin if FileExists('.gitmodules') then if RunCommand('git', ['submodule', 'update', '--init', '--recursive', '--force', '--remote'], Result.Output) then - Writeln(stderr, #27'[33m', Result.Output, #27'[0m'); + OutLog(info, Result.Output); end; function AddPackage(Path: string): Output; @@ -37,14 +48,14 @@ Output = record begin Expression := {$IFDEF MSWINDOWS} - '(cocoa|x11|_template)' - {$ELSE} - '(cocoa|gdi|_template)' - {$ENDIF} + '(cocoa|x11|_template)' + {$ELSE} + '(cocoa|gdi|_template)' + {$ENDIF} ; if not Exec(Path) and RunCommand('lazbuild', ['--add-package-link', Path], Result.Output) then - Writeln(stderr, #27'[33m', 'added ', Path, #27'[0m'); + OutLog(audit, 'added ' + Path); Free; end; end; @@ -53,7 +64,7 @@ Output = record var Line: string; begin - Write(stderr, #27'[33m', 'build from ', Path, #27'[0m'); + OutLog(audit, 'build from ' + Path); try Result.Code := RunCommand('lazbuild', ['--build-all', '--recursive', '--no-write-project', Path], Result.Output); @@ -63,7 +74,7 @@ Output = record if ContainsStr(Line, 'Linking') then begin Result.Output := SplitString(Line, ' ')[2]; - Writeln(stderr, #27'[32m', ' to ', Result.Output, #27'[0m'); + OutLog(info, ' to ' + Result.Output); break; end; end @@ -75,16 +86,13 @@ Output = record begin Expression := '(Fatal|Error):'; if Exec(Line) then - begin - WriteLn(stderr); - Writeln(stderr, #27'[31m', Line, #27'[0m'); - end; + OutLog(error, #10 + Line); Free; end; end; except on E: Exception do - WriteLn(stderr, 'Error: ' + E.ClassName + #13#10 + E.Message); + OutLog(error, E.ClassName + #13#10 + E.Message); end; end; @@ -97,17 +105,19 @@ Output = record if Result.Code then try if not RunCommand(Temp, ['--all', '--format=plain', '--progress'], Result.Output) then + begin ExitCode += 1; - WriteLn(stderr, Result.Output); + OutLog(error, Result.Output); + end; except on E: Exception do - WriteLn(stderr, 'Error: ' + E.ClassName + #13#10 + E.Message); + OutLog(error, E.ClassName + #13#10 + E.Message); end; end; - function AddOPM(Each: string): string; + function InstallOPM(Each: string): string; var - TempFile, Url: string; + OutFile, Uri: string; Zip: TStream; begin Result := @@ -117,18 +127,18 @@ Output = record GetEnvironmentVariable('HOME') + '/.lazarus/onlinepackagemanager/packages/' {$ENDIF} + Each; - TempFile := GetTempFileName; - Url := 'https://packages.lazarus-ide.org/' + Each + '.zip'; + OutFile := GetTempFileName; + Uri := 'https://packages.lazarus-ide.org/' + Each + '.zip'; if not DirectoryExists(Result) then begin - Zip := TFileStream.Create(TempFile, fmCreate or fmOpenWrite); + Zip := TFileStream.Create(OutFile, fmCreate or fmOpenWrite); with TFPHttpClient.Create(nil) do begin try AddHeader('User-Agent', 'Mozilla/5.0 (compatible; fpweb)'); AllowRedirect := True; - Get(Url, Zip); - WriteLn(stderr, 'Download from ', Url, ' to ', TempFile); + Get(Uri, Zip); + OutLog(audit, 'Download from ' + Uri + ' to ' + OutFile); finally Free; end; @@ -138,32 +148,32 @@ Output = record with TUnZipper.Create do begin try - FileName := TempFile; + FileName := OutFile; OutputPath := Result; Examine; UnZipAllFiles; - WriteLn(stderr, 'Unzip from ', TempFile, ' to ', Result); + OutLog(audit, 'Unzip from ' + OutFile + ' to ' + Result); finally Free; end; end; - DeleteFile(TempFile); + DeleteFile(OutFile); end; end; - procedure Main; + procedure BuildAll; var Each, Item: string; List: TStringList; begin CheckModules; InitSSLInterface; - for Each in Dependencies do + for Item in Dependencies do begin - List := FindAllFiles(AddOPM(Each), '*.lpk', True); + List := FindAllFiles(InstallOPM(Item), '*.lpk', True); try - for Item in List do - AddPackage(Item); + for Each in List do + AddPackage(Each); finally List.Free; end; @@ -186,13 +196,12 @@ Output = record finally List.Free; end; - WriteLn(stderr); if ExitCode <> 0 then - WriteLn(stderr, #27'[31m', 'Errors: ', ExitCode, #27'[0m') + OutLog(error, #10 + 'Errors: ' + IntToStr(ExitCode)) else - WriteLn(stderr, #27'[32m', 'Errors: ', ExitCode, #27'[0m'); + OutLog(info, #10 + 'Errors: ' + IntToStr(ExitCode)); end; begin - Main; + BuildAll; end. diff --git a/.gitmodules b/.gitmodules index a0ca6d8..4a3c578 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,3 @@ [submodule "packages/rutils"] - path = packages/rutils - url = git@github.com:SormJon/rutils.git -[submodule "packages/dopf"] - path = packages/dopf - url = git@github.com:pascal-libs/dopf.git -[submodule "packages/xmailer"] - path = packages/xmailer - url = git@github.com:MFernstrom/xmailer.git -[submodule "packages/brookframework"] - path = packages/brookframework - url = git@github.com:risoflora/brookframework.git + path = packages/rutils + url = git@github.com:SormJon/rutils.git diff --git a/packages/dopf b/packages/dopf deleted file mode 160000 index de1e462..0000000 --- a/packages/dopf +++ /dev/null @@ -1 +0,0 @@ -Subproject commit de1e462e4fb666c34199a95d41ce84ac280ac119 diff --git a/packages/xmailer b/packages/xmailer deleted file mode 160000 index 0290d2f..0000000 --- a/packages/xmailer +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0290d2f81cd7db8265c125003f2e0552ade79a16