Skip to content

Commit 21a8f92

Browse files
authored
Add GitHub Actions for Building and Running Sample Demo (#2)
Add GitHub Actions for Building and Running Sample Demo
1 parent fadd6e4 commit 21a8f92

File tree

8 files changed

+420
-0
lines changed

8 files changed

+420
-0
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: xor_el # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
5+
---
6+
7+
**Describe the bug**
8+
A clear and concise description of what the bug is.
9+
10+
**To Reproduce**
11+
Steps to reproduce the behavior:
12+
1. Go to '...'
13+
2. Click on '....'
14+
3. Scroll down to '....'
15+
4. See error
16+
17+
**Expected behavior**
18+
A clear and concise description of what you expected to happen.
19+
20+
**Screenshots**
21+
If applicable, add screenshots to help explain your problem.
22+
23+
**Environment (please complete the following information):**
24+
- OS: [e.g. Windows, Linux, Mac]
25+
- Compiler Version [e.g. FreePascal 3.0.0]
26+
- Package Version [e.g. 1.0]
27+
28+
**Additional context**
29+
Add any other context about the problem here.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
5+
---
6+
7+
**Is your feature request related to a problem? Please describe.**
8+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9+
10+
**Describe the solution you'd like**
11+
A clear and concise description of what you want to happen.
12+
13+
**Describe alternatives you've considered**
14+
A clear and concise description of any alternative solutions or features you've considered.
15+
16+
**Additional context**
17+
Add any other context or screenshots about the feature request here.

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "monthly"

.github/workflows/make.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"app" : "PatternFinder",
3+
"lib" : "PatternFinder",
4+
"tst" : "PatternFinder.Console.Tests/FreePascal.Tests/PatternFinder.Console.lpi",
5+
"pkg" : [
6+
]
7+
}

.github/workflows/make.ps1

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
#!/usr/bin/env pwsh
2+
##############################################################################################################
3+
4+
Function Show-Usage {
5+
"
6+
vagrant = 'it-gro/win10-ltsc-eval'
7+
download = 'https://microsoft.com/en-us/evalcenter'
8+
package = 'https://learn.microsoft.com/en-us/mem/configmgr/develop/apps/how-to-create-the-windows-installer-file-msi'
9+
shell = 'https://learn.microsoft.com/en-us/powershell'
10+
11+
Usage: pwsh -File $($PSCommandPath) [OPTIONS]
12+
Options:
13+
build
14+
lint
15+
" | Out-Host
16+
}
17+
18+
Function Build-Project {
19+
New-Variable -Option Constant -Name VAR -Value (Get-Content -Path $PSCommandPath.Replace('ps1', 'json') | ConvertFrom-Json)
20+
If (! (Test-Path -Path $Var.app)) {
21+
"$([char]27)[31m.... $($Var.app) did not find!$([char]27)[0m" | Out-Host
22+
Exit 1
23+
}
24+
If (Test-Path -Path '.gitmodules') {
25+
& git submodule update --init --recursive --force --remote | Out-Host
26+
"$([char]27)[33m.... [[$($LastExitCode)]] git submodule update$([char]27)[0m" | Out-Host
27+
}
28+
@(
29+
@{
30+
Cmd = 'lazbuild'
31+
Url = 'https://fossies.org/windows/misc/lazarus-3.6-fpc-3.2.2-win64.exe'
32+
Path = "C:\Lazarus"
33+
}
34+
) | Where-Object {
35+
! (Test-Path -Path $_.Path)
36+
} | ForEach-Object {
37+
$_.Url | Request-File | Install-Program
38+
$Env:PATH+=";$($_.Path)"
39+
Return (Get-Command $_.Cmd).Source
40+
} | Out-Host
41+
$VAR.Pkg | ForEach-Object {
42+
@{
43+
Name = $_
44+
Uri = "https://packages.lazarus-ide.org/$($_).zip"
45+
Path = "$($Env:HOME)\.lazarus\onlinepackagemanager\packages\$($_)"
46+
OutFile = (New-TemporaryFile).FullName
47+
}
48+
} | Where-Object {
49+
! (Test-Path -Path $_.Path) &&
50+
! (& lazbuild --verbose-pkgsearch $_.Name ) &&
51+
! (& lazbuild --add-package $_.Name)
52+
} | ForEach-Object -Parallel {
53+
Invoke-WebRequest -OutFile $_.OutFile -Uri $_.Uri
54+
New-Item -Type Directory -Path $_.Path | Out-Null
55+
Expand-Archive -Path $_.OutFile -DestinationPath $_.Path
56+
Remove-Item $_.OutFile
57+
(Get-ChildItem -Filter '*.lpk' -Recurse -File –Path $_.Path).FullName |
58+
ForEach-Object {
59+
& lazbuild --add-package-link $_ | Out-Null
60+
Return "$([char]27)[33m.... [$($LastExitCode)] add package link $($_)$([char]27)[0m"
61+
}
62+
} | Out-Host
63+
If (Test-Path -Path $VAR.lib) {
64+
(Get-ChildItem -Filter '*.lpk' -Recurse -File –Path $VAR.lib).FullName |
65+
ForEach-Object {
66+
& lazbuild --add-package-link $_ | Out-Null
67+
Return "$([char]27)[33m.... [$($LastExitCode)] add package link $($_)$([char]27)[0m"
68+
} | Out-Host
69+
}
70+
Exit $(Switch (Test-Path -Path $Var.tst) {
71+
true {
72+
$Output = (
73+
& lazbuild --build-all --recursive --no-write-project $VAR.tst |
74+
Where-Object {
75+
$_.Contains('Linking')
76+
} | ForEach-Object {
77+
$_.Split(' ')[2].Replace('bin', 'bin\.')
78+
}
79+
)
80+
$Output = (& $Output --all --format=plain --progress)
81+
$exitCode = Switch ($LastExitCode) {
82+
0 {0}
83+
Default {
84+
1
85+
}
86+
}
87+
$Output | Out-Host
88+
Return $exitCode
89+
K }
90+
Default {0}
91+
}) + (
92+
(Get-ChildItem -Filter '*.lpi' -Recurse -File –Path $Var.app).FullName |
93+
ForEach-Object {
94+
$Output = (& lazbuild --build-all --recursive --no-write-project $_)
95+
$Result = @("$([char]27)[32m.... [$($LastExitCode)] build project $($_)$([char]27)[0m")
96+
$exitCode = $(Switch ($LastExitCode) {
97+
0 {
98+
$Result += $Output | Select-String -Pattern 'Linking'
99+
0
100+
}
101+
Default {
102+
$Result += $Output | Select-String -Pattern 'Error:', 'Fatal:'
103+
1
104+
}
105+
})
106+
$Result | Out-Host
107+
Return $exitCode
108+
} | Measure-Object -Sum
109+
).Sum
110+
}
111+
112+
Function Request-File {
113+
While ($Input.MoveNext()) {
114+
New-Variable -Option Constant -Name VAR -Value @{
115+
Uri = $Input.Current
116+
OutFile = (Split-Path -Path $Input.Current -Leaf).Split('?')[0]
117+
}
118+
Invoke-WebRequest @VAR
119+
Return $VAR.OutFile
120+
}
121+
}
122+
123+
Function Install-Program {
124+
While ($Input.MoveNext()) {
125+
Switch ((Split-Path -Path $Input.Current -Leaf).Split('.')[-1]) {
126+
'msi' {
127+
& msiexec /passive /package $Input.Current | Out-Null
128+
}
129+
Default {
130+
& ".\$($Input.Current)" /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART | Out-Null
131+
}
132+
}
133+
Remove-Item $Input.Current
134+
}
135+
}
136+
137+
Function Request-URL([Switch] $Post) {
138+
$VAR = Switch ($Post) {
139+
true {
140+
@{
141+
Method = 'POST'
142+
Headers = @{
143+
ContentType = 'application/json'
144+
}
145+
Uri = 'https://postman-echo.com/post'
146+
Body = @{
147+
One = '1'
148+
} | ConvertTo-Json
149+
}
150+
}
151+
false {
152+
@{
153+
Uri = 'https://postman-echo.com/get'
154+
}
155+
}
156+
}
157+
Return (Invoke-WebRequest @VAR | ConvertFrom-Json).Headers
158+
}
159+
160+
Function Switch-Action {
161+
$ErrorActionPreference = 'stop'
162+
Set-PSDebug -Strict #-Trace 1
163+
Invoke-ScriptAnalyzer -EnableExit -Path $PSCommandPath
164+
If ($args.count -gt 0) {
165+
Switch ($args[0]) {
166+
'lint' {
167+
Invoke-ScriptAnalyzer -EnableExit -Recurse -Path '.'
168+
(Get-ChildItem -Filter '*.ps1' -Recurse -Path '.').FullName |
169+
ForEach-Object {
170+
Invoke-Formatter -ScriptDefinition $(Get-Content -Path $_ | Out-String) |
171+
Set-Content -Path $_
172+
}
173+
}
174+
'build' {
175+
Build-Project
176+
}
177+
Default {
178+
Show-Usage
179+
}
180+
}
181+
} Else {
182+
Show-Usage
183+
}
184+
}
185+
186+
##############################################################################################################
187+
Switch-Action @args

.github/workflows/make.sh

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/usr/bin/env bash
2+
##############################################################################################################
3+
4+
function priv_clippit
5+
(
6+
cat <<EOF
7+
https://google.github.io/styleguide/shellguide.html
8+
https://guide.bash.academy
9+
https://devhints.io/bash
10+
https://tldr.sh
11+
12+
Usage: bash ${0} [OPTIONS]
13+
Options:
14+
build Build program
15+
EOF
16+
)
17+
18+
function priv_lazbuild
19+
(
20+
mapfile -t < "${0//sh/json}"
21+
declare -rA VAR=(
22+
[app]=$(jq --raw-output --exit-status '.app' <<< "${MAPFILE[@]}")
23+
[lib]=$(jq --raw-output --exit-status '.lib' <<< "${MAPFILE[@]}")
24+
[tst]=$(jq --raw-output --exit-status '.tst' <<< "${MAPFILE[@]}")
25+
[opt]=$(jq --raw-output --exit-status '.opt' <<< "${MAPFILE[@]}")
26+
)
27+
if ! [[ -d "${VAR[app]}" ]]; then
28+
printf '\x1b[32m\t[%s] did not find!\x1b[0m\n' "${VAR[app]}"
29+
exit 1
30+
fi >&2
31+
if [[ -f '.gitmodules' ]]; then
32+
git submodule update --init --recursive --force --remote &
33+
fi
34+
if ! (command -v lazbuild); then
35+
# shellcheck source=/dev/null
36+
source '/etc/os-release'
37+
case ${ID:?} in
38+
debian | ubuntu)
39+
sudo apt-get update
40+
sudo apt-get install -y lazarus{-ide-qt5,} &
41+
;;
42+
esac
43+
fi &>/dev/null
44+
wait
45+
while read -r; do
46+
(
47+
declare -rA TMP=(
48+
[url]="https://packages.lazarus-ide.org/${REPLY}.zip"
49+
[dir]="${HOME}/.lazarus/onlinepackagemanager/packages/${REPLY}"
50+
[out]=$(mktemp)
51+
)
52+
if ! [[ -d "${TMP[dir]}" ]] &&
53+
! (lazbuild --verbose-pkgsearch "${REPLY}") &&
54+
! (lazbuild --add-package "${REPLY}"); then
55+
wget --quiet --output-document "${TMP[out]}" "${TMP[url]}"
56+
mkdir --parents "${TMP[dir]}"
57+
unzip -o "${TMP[out]}" -d "${TMP[dir]}"
58+
rm --verbose "${TMP[out]}"
59+
find "${TMP[dir]}" -type 'f' -name '*.lpk' -printf '\033[33m\tadd package link\t%p\033[0m\n' -exec \
60+
lazbuild --add-package-link {} + >&2
61+
fi
62+
) &
63+
done < <(jq --raw-output --exit-status '.pkg[]' <<< "${MAPFILE[@]}")
64+
wait
65+
if [[ -d "${VAR[lib]}" ]]; then
66+
find "${VAR[lib]}" -type 'f' -name '*.lpk' -printf '\033[33m\tadd package link\t%p\033[0m\n' -exec \
67+
lazbuild --add-package-link {} + >&2
68+
fi
69+
declare -i exitCode=0
70+
if [[ -f "${VAR[tst]}" ]]; then
71+
declare -A TMP=(
72+
[tst]=$(
73+
lazbuild --build-all --recursive --no-write-project "${VAR[tst]}" |
74+
awk '/Linking/{print $3}'
75+
)
76+
)
77+
if ! ("${TMP[tst]}" --all --format=plain --progress >&2); then
78+
((exitCode+=1))
79+
fi
80+
fi
81+
while read -r; do
82+
declare -A TMP=(
83+
[out]=$(mktemp)
84+
)
85+
if (lazbuild --build-all --recursive --no-write-project "${REPLY}" > "${TMP[out]}"); then
86+
printf '\x1b[32m\t[%s]\t%s\x1b[0m\n' "${?}" "${REPLY}"
87+
grep --color='always' 'Linking' "${TMP[out]}"
88+
else
89+
printf '\x1b[31m\t[%s]\t%s\x1b[0m\n' "${?}" "${REPLY}"
90+
grep --color='always' --extended-regexp '(Error|Fatal):' "${TMP[out]}"
91+
((exitCode+=1))
92+
fi >&2
93+
rm "${TMP[out]}"
94+
done < <(find "${VAR[app]}" -type 'f' -name '*.lpi')
95+
exit "${exitCode}"
96+
)
97+
98+
function priv_main
99+
(
100+
set -euo pipefail
101+
if ((${#})); then
102+
case ${1} in
103+
build) priv_lazbuild ;;
104+
*) priv_clippit ;;
105+
esac
106+
else
107+
priv_clippit
108+
fi
109+
)
110+
111+
##############################################################################################################
112+
priv_main "${@}" >/dev/null

0 commit comments

Comments
 (0)