From bdbce0c3de77004008eb24b77a0fd21f4446f35d Mon Sep 17 00:00:00 2001 From: "Artem V. Ageev" Date: Fri, 10 Jan 2025 18:46:22 +0200 Subject: [PATCH] remove noise --- .github/dependabot.yml | 2 +- .github/workflows/make.json | 8 ++ .github/workflows/make.ps1 | 189 ++++++++++++++++++++++++++++++++++++ .github/workflows/make.sh | 112 +++++++++++++++++++++ .github/workflows/make.yml | 14 ++- make.ps1 | 92 ------------------ make.sh | 62 ------------ use/components.txt | 1 - 8 files changed, 322 insertions(+), 158 deletions(-) create mode 100644 .github/workflows/make.json create mode 100644 .github/workflows/make.ps1 create mode 100644 .github/workflows/make.sh delete mode 100644 make.ps1 delete mode 100644 make.sh delete mode 100644 use/components.txt diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 23c4cb3..64284b9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,4 +4,4 @@ updates: - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "weekly" + interval: "monthly" diff --git a/.github/workflows/make.json b/.github/workflows/make.json new file mode 100644 index 0000000..bb37240 --- /dev/null +++ b/.github/workflows/make.json @@ -0,0 +1,8 @@ +{ + "app" : "src", + "lib" : "src", + "tst" : "tst", + "pkg" : [ + "PlaysoundPackage" + ] +} diff --git a/.github/workflows/make.ps1 b/.github/workflows/make.ps1 new file mode 100644 index 0000000..76c173c --- /dev/null +++ b/.github/workflows/make.ps1 @@ -0,0 +1,189 @@ +#!/usr/bin/env pwsh +############################################################################################################## + +Function Show-Usage { + " +vagrant = 'it-gro/win10-ltsc-eval' +download = 'https://microsoft.com/en-us/evalcenter' +package = 'https://learn.microsoft.com/en-us/mem/configmgr/develop/apps/how-to-create-the-windows-installer-file-msi' +shell = 'https://learn.microsoft.com/en-us/powershell' + +Usage: pwsh -File $($PSCommandPath) [OPTIONS] +Options: + build + lint +" | Out-Host +} + +Function Build-Project { + New-Variable -Option Constant -Name VAR -Value (Get-Content -Path $PSCommandPath.Replace('ps1', 'json') | ConvertFrom-Json) + If (! (Test-Path -Path $Var.app)) { + "$([char]27)[31m.... $($Var.app) did not find!$([char]27)[0m" | Out-Host + Exit 1 + } + If (Test-Path -Path '.gitmodules') { + & git submodule update --init --recursive --force --remote | Out-Host + "$([char]27)[33m.... [[$($LastExitCode)]] git submodule update$([char]27)[0m" | Out-Host + } + @( + @{ + Cmd = 'lazbuild' + Url = 'https://fossies.org/windows/misc/lazarus-3.6-fpc-3.2.2-win64.exe' + Path = "C:\Lazarus" + } + ) | Where-Object { + ! (Test-Path -Path $_.Path) + } | ForEach-Object { + $_.Url | Request-File | Install-Program + $Env:PATH+=";$($_.Path)" + Return (Get-Command $_.Cmd).Source + } | Out-Host + $VAR.Pkg | ForEach-Object { + @{ + Name = $_ + Uri = "https://packages.lazarus-ide.org/$($_).zip" + Path = "$($Env:APPDATA)\.lazarus\onlinepackagemanager\packages\$($_)" + OutFile = (New-TemporaryFile).FullName + } + } | Where-Object { + ! (Test-Path -Path $_.Path) && + ! (& lazbuild --verbose-pkgsearch $_.Name ) && + ! (& lazbuild --add-package $_.Name) + } | ForEach-Object -Parallel { + Invoke-WebRequest -OutFile $_.OutFile -Uri $_.Uri + New-Item -Type Directory -Path $_.Path | Out-Null + Expand-Archive -Path $_.OutFile -DestinationPath $_.Path + Remove-Item $_.OutFile + (Get-ChildItem -Filter '*.lpk' -Recurse -File –Path $_.Path).FullName | + ForEach-Object { + & lazbuild --add-package-link $_ | Out-Null + Return "$([char]27)[33m.... [$($LastExitCode)] add package link $($_)$([char]27)[0m" + } + } | Out-Host + If (Test-Path -Path $VAR.lib) { + (Get-ChildItem -Filter '*.lpk' -Recurse -File –Path $VAR.lib).FullName | + Where-Object { + $_ -notmatch '(cocoa|x11|_template)' + } | ForEach-Object { + & lazbuild --add-package-link $_ | Out-Null + Return "$([char]27)[33m.... [$($LastExitCode)] add package link $($_)$([char]27)[0m" + } | Out-Host + } + Exit $(Switch (Test-Path -Path $Var.tst) { + true { + $Output = ( + & lazbuild --build-all --recursive --no-write-project $VAR.tst | + Where-Object { + $_.Contains('Linking') + } | ForEach-Object { + $_.Split(' ')[2].Replace('bin', 'bin\.') + } + ) + $Output = (& $Output --all --format=plain --progress) + $exitCode = Switch ($LastExitCode) { + 0 {0} + Default { + 1 + } + } + $Output | Out-Host + Return $exitCode + } + Default {0} + }) + ( + (Get-ChildItem -Filter '*.lpi' -Recurse -File –Path $Var.app).FullName | + ForEach-Object { + $Output = (& lazbuild --build-all --recursive --no-write-project $_) + $Result = @("$([char]27)[32m.... [$($LastExitCode)] build project $($_)$([char]27)[0m") + $exitCode = $(Switch ($LastExitCode) { + 0 { + $Result += $Output | Select-String -Pattern 'Linking' + 0 + } + Default { + $Result += $Output | Select-String -Pattern 'Error:', 'Fatal:' + 1 + } + }) + $Result | Out-Host + Return $exitCode + } | Measure-Object -Sum + ).Sum +} + +Function Request-File { + While ($Input.MoveNext()) { + New-Variable -Option Constant -Name VAR -Value @{ + Uri = $Input.Current + OutFile = (Split-Path -Path $Input.Current -Leaf).Split('?')[0] + } + Invoke-WebRequest @VAR + Return $VAR.OutFile + } +} + +Function Install-Program { + While ($Input.MoveNext()) { + Switch ((Split-Path -Path $Input.Current -Leaf).Split('.')[-1]) { + 'msi' { + & msiexec /passive /package $Input.Current | Out-Null + } + Default { + & ".\$($Input.Current)" /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART | Out-Null + } + } + Remove-Item $Input.Current + } +} + +Function Request-URL([Switch] $Post) { + $VAR = Switch ($Post) { + true { + @{ + Method = 'POST' + Headers = @{ + ContentType = 'application/json' + } + Uri = 'https://postman-echo.com/post' + Body = @{ + One = '1' + } | ConvertTo-Json + } + } + false { + @{ + Uri = 'https://postman-echo.com/get' + } + } + } + Return (Invoke-WebRequest @VAR | ConvertFrom-Json).Headers +} + +Function Switch-Action { + $ErrorActionPreference = 'stop' + Set-PSDebug -Strict #-Trace 1 + Invoke-ScriptAnalyzer -EnableExit -Path $PSCommandPath + If ($args.count -gt 0) { + Switch ($args[0]) { + 'lint' { + Invoke-ScriptAnalyzer -EnableExit -Recurse -Path '.' + (Get-ChildItem -Filter '*.ps1' -Recurse -Path '.').FullName | + ForEach-Object { + Invoke-Formatter -ScriptDefinition $(Get-Content -Path $_ | Out-String) | + Set-Content -Path $_ + } + } + 'build' { + Build-Project + } + Default { + Show-Usage + } + } + } Else { + Show-Usage + } +} + +############################################################################################################## +Switch-Action @args diff --git a/.github/workflows/make.sh b/.github/workflows/make.sh new file mode 100644 index 0000000..6e17493 --- /dev/null +++ b/.github/workflows/make.sh @@ -0,0 +1,112 @@ +#!/usr/bin/env bash +############################################################################################################## + +function priv_clippit +( + cat <&2 + if [[ -f '.gitmodules' ]]; then + git submodule update --init --recursive --force --remote & + fi + if ! (command -v lazbuild); then + # shellcheck source=/dev/null + source '/etc/os-release' + case ${ID:?} in + debian | ubuntu) + sudo apt-get update + sudo apt-get install -y lazarus{-ide-qt5,} & + ;; + esac + fi &>/dev/null + wait + while read -r; do + ( + declare -rA TMP=( + [url]="https://packages.lazarus-ide.org/${REPLY}.zip" + [dir]="${HOME}/.lazarus/onlinepackagemanager/packages/${REPLY}" + [out]=$(mktemp) + ) + if ! [[ -d "${TMP[dir]}" ]] && + ! (lazbuild --verbose-pkgsearch "${REPLY}") && + ! (lazbuild --add-package "${REPLY}"); then + wget --quiet --output-document "${TMP[out]}" "${TMP[url]}" + mkdir --parents "${TMP[dir]}" + unzip -o "${TMP[out]}" -d "${TMP[dir]}" + rm --verbose "${TMP[out]}" + find "${TMP[dir]}" -type 'f' -name '*.lpk' -printf '\033[33m\tadd package link\t%p\033[0m\n' -exec \ + lazbuild --add-package-link {} + >&2 + fi + ) & + done < <(jq --raw-output --exit-status '.pkg[]' <<< "${MAPFILE[@]}") + wait + if [[ -d "${VAR[lib]}" ]]; then + while read -r; do + if ! [[ ${REPLY} =~ (cocoa|gdi|_template) ]]; then + lazbuild --add-package-link "${REPLY}" + printf '\033[33m\tadd package link\t%s\033[0m\n' "${REPLY}" + fi + done < <(find "${VAR[lib]}" -type 'f' -name '*.lpk') + fi >&2 + declare -i exitCode=0 + if [[ -f "${VAR[tst]}" ]]; then + read -r < <( + lazbuild --build-all --recursive --no-write-project "${VAR[tst]}" | + awk '/Linking/{print $3}' + ) + if ! ("${REPLY}" --all --format=plain --progress >&2); then + ((exitCode+=1)) + fi + fi + while read -r; do + mapfile -t < <(mktemp) + if (lazbuild --build-all --recursive --no-write-project "${REPLY:?}" > "${MAPFILE[0]:?}"); then + printf '\x1b[32m\t[%s]\t%s\x1b[0m\n' "${?}" "${REPLY:?}" + grep --color='always' 'Linking' "${MAPFILE[0]:?}" + else + printf '\x1b[31m\t[%s]\t%s\x1b[0m\n' "${?}" "${REPLY:?}" + grep --color='always' --extended-regexp '(Error|Fatal):' "${MAPFILE[0]:?}" + ((exitCode+=1)) + fi >&2 + rm "${MAPFILE[0]:?}" + done < <(find "${VAR[app]}" -type 'f' -name '*.lpi') + exit "${exitCode}" +) + +function priv_main +( + set -euo pipefail + if ((${#})); then + case ${1} in + build) priv_lazbuild ;; + *) priv_clippit ;; + esac + else + priv_clippit + fi +) + +############################################################################################################## +priv_main "${@}" >/dev/null diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index 58aa0a1..006d55c 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -2,12 +2,15 @@ name: Make on: + schedule: + - cron: '0 0 1 * *' push: branches: - "**" pull_request: branches: - master + - main concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -31,9 +34,16 @@ jobs: - name: Build on Linux if: runner.os == 'Linux' shell: bash - run: bash -x make.sh build + run: bash .github/workflows/make.sh build - name: Build on Windows if: runner.os == 'Windows' shell: powershell - run: pwsh -File make.ps1 build + run: pwsh -File .github/workflows/make.ps1 build + + - name: Archive + if: runner.os == 'Windows' + uses: actions/upload-artifact@v4 + with: + retention-days: 1 + path: src\bin\*.exe diff --git a/make.ps1 b/make.ps1 deleted file mode 100644 index 1dc75af..0000000 --- a/make.ps1 +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env pwsh -############################################################################################################## - -Function Show-Usage { - Return " -Usage: pwsh -File $($PSCommandPath) [OPTIONS] -Options: - build Build program -" -} - -Function Request-File { - ForEach ($REPLY in $args) { - $params = @{ - Uri = $REPLY - OutFile = (Split-Path -Path $REPLY -Leaf).Split('?')[0] - } - Invoke-WebRequest @params | Out-Null - Return $params.OutFile - } -} - -Function Install-Program { - While ($Input.MoveNext()) { - Switch ((Split-Path -Path $Input.Current -Leaf).Split('.')[-1]) { - 'msi' { - & msiexec /passive /package $Input.Current | Out-Host - } - 'exe' { - & ".\$($Input.Current)" /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART | Out-Host - } - } - Remove-Item $Input.Current - } -} - -Function Build-Project { - $VAR = @{ - Cmd = 'lazbuild' - Url = 'https://netix.dl.sourceforge.net/project/lazarus/Lazarus%20Windows%2064%20bits/Lazarus%203.6/lazarus-3.6-fpc-3.2.2-win64.exe?viasf=1' - Path = "C:\Lazarus" - } - Try { - Get-Command $VAR.Cmd - } Catch { - Request-File $VAR.Url | Install-Program - $env:PATH+=";$($VAR.Path)" - Get-Command $VAR.Cmd - } - If ( Test-Path -Path 'use' ) { - & git submodule update --recursive --init | Out-Host - & git submodule update --recursive --remote | Out-Host - If ( Test-Path -Path 'use\components.txt' ) { - Get-Content -Path 'use\components.txt' | ForEach-Object { - If ((! (& lazbuild --verbose-pkgsearch $_)) && - (! (& lazbuild --add-package $_)) && - (! (Test-Path -Path "use\$($_)"))) { - $OutFile = Request-File "https://packages.lazarus-ide.org/$($_).zip" - Expand-Archive -Path $OutFile -DestinationPath "use\$($_)" -Force - Remove-Item $OutFile - } - } - } - Get-ChildItem -Filter '*.lpk' -Recurse -File –Path $Env:PWD | ForEach-Object { - & lazbuild --add-package-link $_ | Out-Host - } - } - Get-ChildItem -Filter '*.lpi' -Recurse -File –Path 'src' | ForEach-Object { - & lazbuild --no-write-project --recursive --build-mode=release $_ | Out-Host - } -} - -Function Switch-Action { - $ErrorActionPreference = 'stop' - Set-PSDebug -Strict -Trace 1 - Invoke-ScriptAnalyzer -EnableExit -Path $PSCommandPath - If ($args.count -gt 0) { - Switch ($args[0]) { - 'build' { - Build-Project - } - Default { - Show-Usage - } - } - } Else { - Show-Usage - } -} - -############################################################################################################## -Switch-Action @args diff --git a/make.sh b/make.sh deleted file mode 100644 index 1138a73..0000000 --- a/make.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env bash - -function priv_clippit -( - cat </dev/null - unzip -o "${VAR[out]}" -d "use/${REPLY}" - rm --verbose "${VAR[out]}" - fi - done < 'use/components.txt' - fi - find "${PWD}" -type 'f' -name '*.lpk' -exec lazbuild --add-package-link {} + - fi - find 'src' -type 'f' -name '*.lpi' \ - -exec lazbuild --no-write-project --recursive --no-write-project --build-mode=release {} + 1>&2 -) - -function priv_main -( - set -euo pipefail - if ((${#})); then - case ${1} in - build) priv_lazbuild ;; - *) priv_clippit ;; - esac - else - priv_clippit - fi -) - -priv_main "${@}" >/dev/null diff --git a/use/components.txt b/use/components.txt deleted file mode 100644 index b9d4735..0000000 --- a/use/components.txt +++ /dev/null @@ -1 +0,0 @@ -PlaysoundPackage