fix: apply fork fixes — byparr tag, .env corruption, mask_val heredoc… #77
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lint & Test | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| branches: [main, master] | |
| # Cancel superseded runs on the same PR/branch to save CI minutes. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| shfmt: | |
| name: Shell Format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install shfmt | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| curl -sSL "https://github.com/mvdan/sh/releases/download/v3.8.0/shfmt_v3.8.0_linux_amd64" -o /tmp/shfmt | |
| echo "27b3c6f9d9592fc5b4856c341d1ff2c88856709b9e76469313642a1d7b558fe0 /tmp/shfmt" | sha256sum -c - || { echo "shfmt checksum mismatch — update the fixed checksum"; exit 1; } | |
| sudo install -m 755 /tmp/shfmt /usr/local/bin/shfmt | |
| shfmt --version | |
| - name: Check formatting | |
| run: shfmt -d -i 4 -ci setup.sh uninstall.sh tests/ | |
| shellcheck: | |
| name: ShellCheck | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install ShellCheck | |
| run: sudo apt-get update && sudo apt-get install -y shellcheck | |
| - name: Lint setup.sh | |
| run: shellcheck setup.sh | |
| - name: Lint uninstall.sh | |
| run: shellcheck uninstall.sh | |
| - name: Lint tests | |
| run: shellcheck tests/*.sh | |
| powershell-lint: | |
| name: PowerShell Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install PowerShell | |
| run: | | |
| # Install PowerShell Core so PSScriptAnalyzer can run on Linux. | |
| curl -sSL "https://packages.microsoft.com/keys/microsoft.asc" | sudo gpg --dearmor -o /usr/share/keyrings/microsoft.gpg | |
| echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/ubuntu/22.04/prod jammy main" | sudo tee /etc/apt/sources.list.d/microsoft.list | |
| sudo apt-get update && sudo apt-get install -y powershell | |
| - name: Install PSScriptAnalyzer | |
| shell: pwsh | |
| run: | | |
| Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | |
| Install-Module -Name PSScriptAnalyzer -Scope CurrentUser -Force -SkipPublisherCheck | |
| - name: Lint setup.ps1 | |
| shell: pwsh | |
| run: | | |
| $results = Invoke-ScriptAnalyzer -Path setup.ps1 -Severity Warning | |
| if ($results) { | |
| $results | Format-Table -AutoSize | |
| # Fail on errors; warnings are reported but non-fatal. | |
| $errors = $results | Where-Object Severity -eq 'Error' | |
| if ($errors) { exit 1 } | |
| } | |
| - name: Lint uninstall.ps1 | |
| shell: pwsh | |
| run: | | |
| $results = Invoke-ScriptAnalyzer -Path uninstall.ps1 -Severity Warning | |
| if ($results) { | |
| $results | Format-Table -AutoSize | |
| $errors = $results | Where-Object Severity -eq 'Error' | |
| if ($errors) { exit 1 } | |
| } | |
| - name: Validate PowerShell syntax | |
| shell: pwsh | |
| run: | | |
| $files = @('setup.ps1', 'uninstall.ps1') | |
| foreach ($f in $files) { | |
| $errors = $null | |
| [System.Management.Automation.Language.Parser]::ParseFile((Resolve-Path $f), [ref]$null, [ref]$errors) | |
| if ($errors.Count -gt 0) { | |
| Write-Host "::error::Syntax errors in $f" | |
| $errors | ForEach-Object { Write-Host " $_" } | |
| exit 1 | |
| } | |
| Write-Host "$f syntax OK" | |
| } | |
| test: | |
| name: Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run API key tests | |
| run: bash tests/test_api_key.sh | |
| - name: Run setup function tests | |
| run: bash tests/test_setup_functions.sh | |
| - name: Extract and validate manage.sh | |
| run: | | |
| # Extract the heredoc content that generates manage.sh from setup.sh. | |
| # Track heredoc delimiters per opening `cat ... manage.sh <<'TAG'` line so | |
| # that nested heredocs (or same-named delimiters in a single file) are | |
| # captured correctly. Strip the cat/EOF wrapper lines from the output. | |
| # Use perl instead of gawk-only 3-arg match() so this works on mawk. | |
| perl -ne ' | |
| if (/^\s*cat >+"\$\{INSTALL_DIR\}\/manage\.sh" <<'\''(MANAGE_[A-Z_]+)'\''/) { | |
| $tag = $1; $capturing = 1; next; | |
| } | |
| if ($capturing && $_ eq "$tag\n") { $capturing = 0; $tag = ""; next; } | |
| print if $capturing; | |
| ' setup.sh > /tmp/manage_extracted.sh | |
| if [[ ! -s /tmp/manage_extracted.sh ]]; then | |
| echo "::error::manage.sh extraction failed: no content captured from setup.sh heredocs" | |
| exit 1 | |
| fi | |
| bash -n /tmp/manage_extracted.sh && echo "manage.sh syntax OK" || { | |
| echo "::error::manage.sh has syntax errors" | |
| exit 1 | |
| } | |
| - name: Validate uninstall.sh syntax | |
| run: bash -n uninstall.sh && echo "uninstall.sh syntax OK" | |
| - name: Validate setup.sh syntax | |
| run: bash -n setup.sh && echo "setup.sh syntax OK" | |
| - name: Validate docker-compose.yml (plex profile) | |
| run: | | |
| # Validate compose template with representative environment variables. | |
| # Run twice — once with each COMPOSE_PROFILES value — so that | |
| # profile-gated services (plex, jellyfin) are also syntax-checked. | |
| export PUID=1000 | |
| export PGID=1000 | |
| export TZ=UTC | |
| export CONFIG_DIR=/tmp/config | |
| export DATA_DIR=/tmp/data | |
| export MOUNT_DIR=/tmp/mount | |
| export TORBOX_API_KEY=testkey1234567890123456789012345 | |
| export RADARR_API_KEY=radarrkey12345678901234567890123 | |
| export SONARR_API_KEY=sonarrkey12345678901234567890123 | |
| export PROWLARR_API_KEY=prowlarrkey1234567890123456789012 | |
| export DECYPHARR_USER=torbox | |
| export DECYPHARR_PASS=password | |
| export PLEX_CLAIM=claim-xxxxx | |
| export JELLYFIN_PUBLISHED_URL=http://localhost:8096 | |
| export COMPOSE_PROFILES=plex | |
| docker compose config -q | |
| echo "docker-compose.yml (plex profile) OK" | |
| - name: Validate docker-compose.yml (jellyfin profile) | |
| run: | | |
| export PUID=1000 | |
| export PGID=1000 | |
| export TZ=UTC | |
| export CONFIG_DIR=/tmp/config | |
| export DATA_DIR=/tmp/data | |
| export MOUNT_DIR=/tmp/mount | |
| export TORBOX_API_KEY=testkey1234567890123456789012345 | |
| export RADARR_API_KEY=radarrkey12345678901234567890123 | |
| export SONARR_API_KEY=sonarrkey12345678901234567890123 | |
| export PROWLARR_API_KEY=prowlarrkey1234567890123456789012 | |
| export DECYPHARR_USER=torbox | |
| export DECYPHARR_PASS=password | |
| export JELLYFIN_PUBLISHED_URL=http://localhost:8096 | |
| export COMPOSE_PROFILES=jellyfin | |
| docker compose config -q | |
| echo "docker-compose.yml (jellyfin profile) OK" |