Skip to content

Commit

Permalink
Merge pull request #2 from theavege/add/github-actions
Browse files Browse the repository at this point in the history
Add/GitHub actions
  • Loading branch information
circular17 authored Jan 22, 2025
2 parents e670bcf + 30d19ec commit 7743219
Show file tree
Hide file tree
Showing 5 changed files with 250 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ['https://sourceforge.net/p/lazpaint/donate/?source=navbar'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
184 changes: 184 additions & 0 deletions .github/workflows/make.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
program Make;
{$mode objfpc}{$H+}

uses
Classes,
SysUtils,
StrUtils,
FileUtil,
Zipper,
fphttpclient,
RegExpr,
openssl,
opensslsockets,
eventlog,
Process;

const
Target: string = '.';
Dependencies: array of string = ('BGRAControls', 'BGRABitmap');

type
Output = record
Success: boolean;
Output: string;
end;

procedure OutLog(const Knd: TEventType; const Msg: string);
begin
case Knd of
etError: Writeln(stderr, #27'[31m', Msg, #27'[0m');
etInfo: Writeln(stderr, #27'[32m', Msg, #27'[0m');
etDebug: Writeln(stderr, #27'[33m', Msg, #27'[0m');
end;
end;

function CheckModules: string;
begin
if FileExists('.gitmodules') then
if RunCommand('git', ['submodule', 'update', '--init', '--recursive',
'--force', '--remote'], Result) then
OutLog(etInfo, Result)
else
OutLog(etError, Result);
end;

function AddPackage(const Path: string): string;
begin
if RunCommand('lazbuild', ['--add-package-link', Path], Result) then
OutLog(etDebug, 'Add package:'#9 + Path);
end;

function SelectString(const Input, Reg: string): string;
var
Line: string;
begin
Result := EmptyStr;
for Line in Input.Split(LineEnding) do
with TRegExpr.Create do
begin
Expression := Reg;
if Exec(Line) then
Result += Line + LineEnding;
Free;
end;
end;

function RunTest(const Path: String): string;
begin
OutLog(etDebug, #9'run:'#9 + Path);
if RunCommand(Path, ['--all', '--format=plain'], Result) then
OutLog(etInfo, #9'success!')
else
begin
ExitCode += 1;
OutLog(etError, Result);
end;
end;

function BuildProject(const Path: string): Output;
begin
OutLog(etDebug, 'Build from:'#9 + Path);
Result.Success := RunCommand('lazbuild',
['--build-all', '--recursive', '--no-write-project', Path], Result.Output);
Result.Output := SelectString(Result.Output, '(Fatal:|Error:|Linking)');
if Result.Success then
begin
Result.Output := Result.Output.Split(' ')[2].Replace(LineEnding, EmptyStr);
OutLog(etInfo, #9'to:'#9 + Result.Output);
if ContainsStr(ReadFileToString(Path.Replace('.lpi', '.lpr')), 'consoletestrunner') then
RunTest(Result.Output);
end
else
begin
ExitCode += 1;
OutLog(etError, Result.Output);
end;
end;

function DownloadFile(const Uri: string): string;
var
OutFile: TStream;
begin
InitSSLInterface;
Result := GetTempFileName;
OutFile := TFileStream.Create(Result, fmCreate or fmOpenWrite);
with TFPHttpClient.Create(nil) do
begin
try
AddHeader('User-Agent', 'Mozilla/5.0 (compatible; fpweb)');
AllowRedirect := True;
Get(Uri, OutFile);
OutLog(etDebug, 'Download from ' + Uri + ' to ' + Result);
finally
Free;
OutFile.Free;
end;
end;
end;

procedure UnZip(const ZipFile, ZipPath: string);
begin
with TUnZipper.Create do
begin
try
FileName := ZipFile;
OutputPath := ZipPath;
Examine;
UnZipAllFiles;
OutLog(etDebug, 'Unzip from'#9 + ZipFile + #9'to'#9 + ZipPath);
DeleteFile(ZipFile);
finally
Free;
end;
end;
end;

function InstallOPM(const Path: string): string;
begin
Result :=
{$IFDEF MSWINDOWS}
GetEnvironmentVariable('APPDATA') + '\.lazarus\onlinepackagemanager\packages\'
{$ELSE}
GetEnvironmentVariable('HOME') + '/.lazarus/onlinepackagemanager/packages/'
{$ENDIF}
+ Path;
if not DirectoryExists(Result) then
begin
CreateDir(Result);
UnZip(DownloadFile('https://packages.lazarus-ide.org/' + Path + '.zip'), Result);
end;
end;

function BuildAll: string;
var
List: TStringList;
begin
CheckModules;
List := FindAllFiles(GetCurrentDir, '*.lpk', True);
try
for Result in Dependencies do
List.AddStrings(FindAllFiles(InstallOPM(Result), '*.lpk', True));
for Result in List do
AddPackage(Result);
List := FindAllFiles(Target, '*.lpi', True);
for Result in List do
BuildProject(Result);
finally
List.Free;
end;
case ExitCode of
0: OutLog(etInfo, 'Errors:'#9 + IntToStr(ExitCode));
else
OutLog(etError, 'Errors:'#9 + IntToStr(ExitCode));
end;
end;

begin
try
BuildAll
except
on E: Exception do
Writeln(E.ClassName, #9, E.Message);
end;
end.
39 changes: 39 additions & 0 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Make

on:
schedule:
- cron: '0 0 1 * *'
push:
branches:
- "**"
pull_request:
branches:
- master
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
matrix:
os:
- ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Build
shell: bash
run: |
set -xeuo pipefail
sudo bash -c 'apt-get update; apt-get install -y lazarus' >/dev/null
instantfpc -Fu/usr/lib/lazarus/*/components/lazutils \
-B '.github/workflows/make.pas'
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ Sample projects made with BGRABitmap and related packages
## dots
This is a demo to play with random, dots and lines.

![dots](https://raw.githubusercontent.com/bgrabitmap/demo/master/docs/img/dots.PNG)
![dots](docs/img/dots.PNG)

## fractal_tree
🌲 with randomness, to make it fractal, tweak it a bit adding even values.

![fractal_tree](https://raw.githubusercontent.com/bgrabitmap/demo/master/docs/img/fractaltree.PNG)
![fractal_tree](docs/img/fractaltree.PNG)

## hello_world
This is an example of animations with easings and how to use them with BGRABitmap.

![hello_world](https://raw.githubusercontent.com/bgrabitmap/demo/master/docs/img/helloworld.gif)
![hello_world](docs/img/helloworld.gif)

## hello_world_2
This is the second example of animations with easings, including image manipulation (load from file and stretch draw).

## mouse_down_and_draw_circles
Hold the mouse button down and draw a circle (it vanishes due to animation). When you do that score increases.

![mouse_down_and_draw_circles](https://raw.githubusercontent.com/bgrabitmap/demo/master/docs/img/mousedownanddrawcircles.png)
![mouse_down_and_draw_circles](docs/img/mousedownanddrawcircles.png)

## mouse_tail
This is an animation of a line that follows the mouse cursor.

![mouse_tail](https://raw.githubusercontent.com/bgrabitmap/demo/master/docs/img/mousetail.gif)
![mouse_tail](docs/img/mousetail.gif)

## superformula
This is an animation based on the superformula.

![superformula](https://raw.githubusercontent.com/bgrabitmap/demo/master/docs/img/superformula.gif)
![superformula](docs/img/superformula.gif)

## superformula_ui
This is the same algorythm of the superformula, but you can tweak it with controls (set color, line widh, and actual formula values).
Expand All @@ -45,9 +45,9 @@ This is an animation with the technique turtle graphics.
## voxel
Move with arrows. Jump and crouch with page up/down. You can go outside of the map and see from the outside.

![superformula](https://raw.githubusercontent.com/bgrabitmap/demo/master/docs/img/voxeldemo.png)
![superformula](docs/img/voxeldemo.png)

## waves
Move the mouse and click to draw.

![superformula](https://raw.githubusercontent.com/bgrabitmap/demo/master/docs/img/waves.jpg)
![superformula](docs/img/waves.jpg)

0 comments on commit 7743219

Please sign in to comment.