name: Test Build Script Flags (Reusable) on: workflow_call: # Make this workflow reusable workflow_dispatch: # Allows manual triggering for testing concurrency: group: test-flags-${{ github.ref }} # Matches ci.yml: queue rather than cancel, so a reusable invocation # from an in-flight CI run isn't killed mid-flight on the next push. cancel-in-progress: false jobs: test-flags: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 # FUSE install removed - not needed for --test-flags - name: Make build script executable run: chmod +x ./build.sh # Test Case 1: Defaults (deb, clean=yes) - name: Test Case 1 - Defaults (deb, clean=yes) run: | echo "--- Running Test Case 1: ./build.sh --test-flags ---" OUTPUT=$(./build.sh --test-flags) echo "$OUTPUT" # Print output for logs echo "--- Verifying Test Case 1 ---" echo "$OUTPUT" | grep -q "Build Format: deb" || (echo "❌ Expected 'Build Format: deb'" && exit 1) echo "$OUTPUT" | grep -q "Clean Action: yes" || (echo "❌ Expected 'Clean Action: yes'" && exit 1) echo "✓ Test Case 1 Passed" # No cleanup needed # Test Case 2: --build deb (clean=yes) - name: Test Case 2 - --build deb (clean=yes) run: | echo "--- Running Test Case 2: ./build.sh --build deb --test-flags ---" OUTPUT=$(./build.sh --build deb --test-flags) echo "$OUTPUT" echo "--- Verifying Test Case 2 ---" echo "$OUTPUT" | grep -q "Build Format: deb" || (echo "❌ Expected 'Build Format: deb'" && exit 1) echo "$OUTPUT" | grep -q "Clean Action: yes" || (echo "❌ Expected 'Clean Action: yes'" && exit 1) echo "✓ Test Case 2 Passed" # No cleanup needed # Test Case 3: --build appimage (clean=yes) - name: Test Case 3 - --build appimage (clean=yes) run: | echo "--- Running Test Case 3: ./build.sh --build appimage --test-flags ---" OUTPUT=$(./build.sh --build appimage --test-flags) echo "$OUTPUT" echo "--- Verifying Test Case 3 ---" echo "$OUTPUT" | grep -q "Build Format: appimage" || (echo "❌ Expected 'Build Format: appimage'" && exit 1) echo "$OUTPUT" | grep -q "Clean Action: yes" || (echo "❌ Expected 'Clean Action: yes'" && exit 1) echo "✓ Test Case 3 Passed" # No cleanup needed # Test Case 4: --clean yes (build=deb) - name: Test Case 4 - --clean yes (build=deb) run: | echo "--- Running Test Case 4: ./build.sh --clean yes --test-flags ---" OUTPUT=$(./build.sh --clean yes --test-flags) echo "$OUTPUT" echo "--- Verifying Test Case 4 ---" echo "$OUTPUT" | grep -q "Build Format: deb" || (echo "❌ Expected 'Build Format: deb'" && exit 1) echo "$OUTPUT" | grep -q "Clean Action: yes" || (echo "❌ Expected 'Clean Action: yes'" && exit 1) echo "✓ Test Case 4 Passed" # No cleanup needed # Test Case 5: --clean no (build=deb) - name: Test Case 5 - --clean no (build=deb) run: | echo "--- Running Test Case 5: ./build.sh --clean no --test-flags ---" OUTPUT=$(./build.sh --clean no --test-flags) echo "$OUTPUT" echo "--- Verifying Test Case 5 ---" echo "$OUTPUT" | grep -q "Build Format: deb" || (echo "❌ Expected 'Build Format: deb'" && exit 1) echo "$OUTPUT" | grep -q "Clean Action: no" || (echo "❌ Expected 'Clean Action: no'" && exit 1) echo "✓ Test Case 5 Passed" # No cleanup needed # Test Case 6: --build deb --clean yes - name: Test Case 6 - --build deb --clean yes run: | echo "--- Running Test Case 6: ./build.sh --build deb --clean yes --test-flags ---" OUTPUT=$(./build.sh --build deb --clean yes --test-flags) echo "$OUTPUT" echo "--- Verifying Test Case 6 ---" echo "$OUTPUT" | grep -q "Build Format: deb" || (echo "❌ Expected 'Build Format: deb'" && exit 1) echo "$OUTPUT" | grep -q "Clean Action: yes" || (echo "❌ Expected 'Clean Action: yes'" && exit 1) echo "✓ Test Case 6 Passed" # No cleanup needed # Test Case 7: --build deb --clean no - name: Test Case 7 - --build deb --clean no run: | echo "--- Running Test Case 7: ./build.sh --build deb --clean no --test-flags ---" OUTPUT=$(./build.sh --build deb --clean no --test-flags) echo "$OUTPUT" echo "--- Verifying Test Case 7 ---" echo "$OUTPUT" | grep -q "Build Format: deb" || (echo "❌ Expected 'Build Format: deb'" && exit 1) echo "$OUTPUT" | grep -q "Clean Action: no" || (echo "❌ Expected 'Clean Action: no'" && exit 1) echo "✓ Test Case 7 Passed" # No cleanup needed # Test Case 8: --build appimage --clean yes - name: Test Case 8 - --build appimage --clean yes run: | echo "--- Running Test Case 8: ./build.sh --build appimage --clean yes --test-flags ---" OUTPUT=$(./build.sh --build appimage --clean yes --test-flags) echo "$OUTPUT" echo "--- Verifying Test Case 8 ---" echo "$OUTPUT" | grep -q "Build Format: appimage" || (echo "❌ Expected 'Build Format: appimage'" && exit 1) echo "$OUTPUT" | grep -q "Clean Action: yes" || (echo "❌ Expected 'Clean Action: yes'" && exit 1) echo "✓ Test Case 8 Passed" # No cleanup needed # Test Case 9: --build appimage --clean no - name: Test Case 9 - --build appimage --clean no run: | echo "--- Running Test Case 9: ./build.sh --build appimage --clean no --test-flags ---" OUTPUT=$(./build.sh --build appimage --clean no --test-flags) echo "$OUTPUT" echo "--- Verifying Test Case 9 ---" echo "$OUTPUT" | grep -q "Build Format: appimage" || (echo "❌ Expected 'Build Format: appimage'" && exit 1) echo "$OUTPUT" | grep -q "Clean Action: no" || (echo "❌ Expected 'Clean Action: no'" && exit 1) echo "✓ Test Case 9 Passed" # No cleanup needed # Test Case 10: --arch arm64 overrides the detected architecture # (cross-build support; the runner itself is amd64). The last # "Target Architecture" line is the authoritative post-override one # from parse_arguments; detect_architecture's earlier line reports # the raw host detection by design. - name: Test Case 10 - --arch arm64 override run: | echo "--- Running Test Case 10: ./build.sh --arch arm64 --build appimage --test-flags ---" OUTPUT=$(./build.sh --arch arm64 --build appimage --test-flags) echo "$OUTPUT" echo "--- Verifying Test Case 10 ---" echo "$OUTPUT" | grep "Target Architecture:" | tail -1 | grep -q "arm64" || (echo "❌ Expected final 'Target Architecture: arm64'" && exit 1) echo "$OUTPUT" | grep -q "Build Format: appimage" || (echo "❌ Expected 'Build Format: appimage'" && exit 1) echo "✓ Test Case 10 Passed" # Test Case 11: --arch rejects invalid values - name: Test Case 11 - --arch rejects invalid values run: | echo "--- Running Test Case 11: ./build.sh --arch bogus --test-flags ---" if OUTPUT=$(./build.sh --arch bogus --test-flags 2>&1); then echo "$OUTPUT" echo "❌ Expected non-zero exit for invalid --arch" exit 1 fi echo "$OUTPUT" echo "--- Verifying Test Case 11 ---" echo "$OUTPUT" | grep -q "Invalid architecture specified" || (echo "❌ Expected invalid-architecture error message" && exit 1) echo "✓ Test Case 11 Passed"