feat: add test script and GitHub Actions workflow (#584) #6
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: Test Install Script | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - "installTorrServerLinux.sh" | |
| - ".github/workflows/test-install-script.yml" | |
| - ".github/scripts/test-install-script.sh" | |
| pull_request: | |
| branches: | |
| - master | |
| paths: | |
| - "installTorrServerLinux.sh" | |
| - ".github/workflows/test-install-script.yml" | |
| - ".github/scripts/test-install-script.sh" | |
| workflow_dispatch: | |
| # OSes that require version 135 due to glibc < 2.32 | |
| # Version 136+ requires glibc >= 2.32 | |
| env: | |
| GLIBC_LIMITED_OSES: "debian-11|almalinux-8|rocky-8|amazonlinux-2" | |
| MAX_RETRIES: "3" | |
| RETRY_DELAY: "60" | |
| jobs: | |
| test-script-syntax: | |
| name: Test Script Syntax | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Test script syntax | |
| run: | | |
| chmod +x installTorrServerLinux.sh | |
| bash -n installTorrServerLinux.sh | |
| echo "✓ Script syntax is valid" | |
| - name: Test help command | |
| run: | | |
| ./installTorrServerLinux.sh --help > /dev/null | |
| ./installTorrServerLinux.sh help > /dev/null | |
| echo "✓ Help command works" | |
| test-install-script: | |
| name: Test on ${{ matrix.os }} (${{ matrix.test-user }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-22.04 | |
| - ubuntu-24.04 | |
| - debian-11 | |
| - debian-12 | |
| - debian-13 | |
| - fedora-latest | |
| - almalinux-8 | |
| - almalinux-9 | |
| - almalinux-10 | |
| - rocky-8 | |
| - rocky-9 | |
| - rocky-10 | |
| - amazonlinux-2 | |
| test-user: [root, default] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Setup Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Get Docker image for OS | |
| id: get-image | |
| run: | | |
| # Map OS to Docker image | |
| case "${{ matrix.os }}" in | |
| ubuntu-22.04) IMAGE="ubuntu:22.04" ;; | |
| ubuntu-24.04) IMAGE="ubuntu:24.04" ;; | |
| debian-11) IMAGE="debian:11" ;; | |
| debian-12) IMAGE="debian:12" ;; | |
| debian-13) IMAGE="debian:13" ;; | |
| fedora-latest) IMAGE="fedora:latest" ;; | |
| almalinux-8) IMAGE="almalinux:8" ;; | |
| almalinux-9) IMAGE="almalinux:9" ;; | |
| almalinux-10) IMAGE="almalinux:10" ;; | |
| rocky-8) IMAGE="rockylinux/rockylinux:8" ;; | |
| rocky-9) IMAGE="rockylinux/rockylinux:9" ;; | |
| rocky-10) IMAGE="rockylinux/rockylinux:10" ;; | |
| amazonlinux-2) IMAGE="amazonlinux:2" ;; | |
| *) | |
| echo "Warning: Unknown OS ${{ matrix.os }}, using ubuntu:22.04 as default" | |
| IMAGE="ubuntu:22.04" | |
| ;; | |
| esac | |
| echo "image=$IMAGE" >> $GITHUB_OUTPUT | |
| echo "Using Docker image: $IMAGE for OS: ${{ matrix.os }}" | |
| - name: Run tests in container | |
| run: | | |
| docker run --rm \ | |
| -v "$PWD:/workspace" \ | |
| -w /workspace \ | |
| --privileged \ | |
| -e MATRIX_OS="${{ matrix.os }}" \ | |
| -e TEST_USER="${{ matrix.test-user }}" \ | |
| -e GLIBC_LIMITED_OSES="${{ env.GLIBC_LIMITED_OSES }}" \ | |
| -e MAX_RETRIES="${{ env.MAX_RETRIES }}" \ | |
| -e RETRY_DELAY="${{ env.RETRY_DELAY }}" \ | |
| "${{ steps.get-image.outputs.image }}" \ | |
| bash -c " | |
| set -e | |
| # Make test script executable | |
| chmod +x .github/scripts/test-install-script.sh | |
| # Run the test script | |
| .github/scripts/test-install-script.sh | |
| " |