mirror of
https://github.com/oSoWoSo/DistroHopper.git
synced 2026-12-06 04:43:46 +00:00
288 lines
9.8 KiB
YAML
288 lines
9.8 KiB
YAML
name: "Test"
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'templates/**'
|
|
- 'qget'
|
|
- 'generate'
|
|
- 'tests/**'
|
|
- 'website-source/**'
|
|
- 'lib.sh'
|
|
- 'icons/**'
|
|
- 'TODO/distrowatch/**'
|
|
- 'data/rosette/**'
|
|
- '*.md'
|
|
- 'web-create'
|
|
- 'web-deploy'
|
|
- 'scripts/publish-website-branch'
|
|
- 'scripts/sync-upstream.sh'
|
|
- 'docs/website-deployment.md'
|
|
- '.github/workflows/website.yml'
|
|
- '.github/workflows/test-qget.yml'
|
|
schedule:
|
|
- cron: '0 0 * * *'
|
|
workflow_dispatch:
|
|
inputs:
|
|
windows_probe:
|
|
description: 'Try Windows download URL generation from the CI runner (no ISO downloads)'
|
|
type: boolean
|
|
default: false
|
|
|
|
jobs:
|
|
detect-distros:
|
|
name: "Detect distros 🔍"
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
distros: ${{ steps.get-distros.outputs.distros }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: "Install dependencies 📦️"
|
|
run: |
|
|
sudo apt-get -y update
|
|
sudo apt-get -y install curl jq
|
|
|
|
- name: "Extract unique distros 📋"
|
|
id: get-distros
|
|
run: |
|
|
# List distros from templates (offline, no generation needed)
|
|
DISTROS=$(ls templates | sort -u)
|
|
JSON=$(echo "$DISTROS" | jq -R -s -c 'split("\n") | map(select(length > 0))')
|
|
echo "distros=${JSON}" >> "$GITHUB_OUTPUT"
|
|
echo "Found $(echo "$DISTROS" | wc -l | tr -d ' ') distros to test"
|
|
|
|
test-distro:
|
|
name: "${{ matrix.distro }}"
|
|
needs: detect-distros
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DISTRO: ${{ matrix.distro }}
|
|
WINDOWS_PROBE: ${{ github.event_name == 'workflow_dispatch' && inputs.windows_probe }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
distro: ${{ fromJson(needs.detect-distros.outputs.distros) }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: "Install dependencies 📦️"
|
|
run: |
|
|
sudo apt-get -y update
|
|
sudo apt-get -y install curl jq qemu-utils uuid-runtime
|
|
- name: "Generate public metadata 🏗️"
|
|
if: ${{ !startsWith(matrix.distro, 'windows') && matrix.distro != 'redox-os' }}
|
|
run: |
|
|
mkdir -p results
|
|
./generate "${{ matrix.distro }}" 2>&1 | tee results/generate.log
|
|
|
|
- name: "Check ${{ matrix.distro }} downloads 💿️"
|
|
id: check
|
|
run: |
|
|
mkdir -p results
|
|
case "${DISTRO}" in
|
|
redox-os)
|
|
echo "SKIP: ${DISTRO} (host blocks automated access from CI runners)" | tee results/check.txt
|
|
;;
|
|
windows*)
|
|
if [ "${WINDOWS_PROBE:-false}" = true ]; then
|
|
./scripts/check-windows-ci "${DISTRO}" 2>&1 | tee results/check.txt
|
|
else
|
|
echo "SKIP: ${DISTRO} (manual Windows probe not enabled)" | tee results/check.txt
|
|
fi
|
|
;;
|
|
*) ./qget --check "${DISTRO}" 2>&1 | tee results/check.txt ;;
|
|
esac
|
|
|
|
# awk also succeeds for zero matches when the shell uses pipefail.
|
|
PASSED=$(awk '/^PASS:/{n++} END {print n+0}' results/check.txt)
|
|
FAILED=$(awk '/^FAIL:/{n++} END {print n+0}' results/check.txt)
|
|
SKIPPED=$(awk '/^SKIP:/{n++} END {print n+0}' results/check.txt)
|
|
|
|
echo "passed=${PASSED}" >> "$GITHUB_OUTPUT"
|
|
echo "failed=${FAILED}" >> "$GITHUB_OUTPUT"
|
|
echo "skipped=${SKIPPED}" >> "$GITHUB_OUTPUT"
|
|
|
|
# Extract failed URLs for reporting
|
|
grep '^FAIL' results/check.txt > results/failed.txt || true
|
|
|
|
echo "Results for ${DISTRO}: PASS=${PASSED} FAIL=${FAILED} SKIP=${SKIPPED}"
|
|
- name: "Upload diagnostic logs and metadata"
|
|
if: ${{ !cancelled() }}
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: diagnostics-${{ matrix.distro }}
|
|
path: |
|
|
results/
|
|
public/
|
|
retention-days: 7
|
|
|
|
- name: "Create result JSON 📝"
|
|
run: |
|
|
mkdir -p result
|
|
jq -n \
|
|
--arg distro "${{ matrix.distro }}" \
|
|
--argjson passed "${{ steps.check.outputs.passed }}" \
|
|
--argjson failed "${{ steps.check.outputs.failed }}" \
|
|
--argjson skipped "${{ steps.check.outputs.skipped }}" \
|
|
'{distro: $distro, passed: $passed, failed: $failed, skipped: $skipped}' \
|
|
> result/result.json
|
|
|
|
# Include failed URLs if any
|
|
if [ -s results/failed.txt ]; then
|
|
cp results/failed.txt result/failed.txt
|
|
fi
|
|
|
|
cat result/result.json
|
|
- name: "Upload result artifact 📤"
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: result-${{ matrix.distro }}
|
|
path: result/
|
|
retention-days: 1
|
|
- name: "Fail if any failures ❌"
|
|
if: steps.check.outputs.failed != '0'
|
|
run: |
|
|
echo "::error::${{ matrix.distro }} has ${{ steps.check.outputs.failed }} failed downloads"
|
|
exit 1
|
|
|
|
deploy-website:
|
|
name: Build and deploy website
|
|
needs: test-distro
|
|
# Upstream download failures should not prevent a catalog refresh.
|
|
# Publish only the repository's default branch, even if it is renamed.
|
|
# A failed matrix is allowed; a cancelled or skipped matrix is not.
|
|
if: ${{ !cancelled() && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && needs.test-distro.result != 'skipped' }}
|
|
permissions:
|
|
contents: write
|
|
uses: ./.github/workflows/website.yml
|
|
with:
|
|
reuse_matrix_metadata: true
|
|
secrets:
|
|
SURFER_USER: ${{ secrets.SURFER_USER }}
|
|
SURFER_TOKEN: ${{ secrets.SURFER_TOKEN }}
|
|
|
|
report-results:
|
|
name: "Report results 📊"
|
|
needs: test-distro
|
|
runs-on: ubuntu-22.04
|
|
if: always()
|
|
steps:
|
|
- name: "Download all result artifacts 📥"
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
pattern: result-*
|
|
path: results
|
|
- name: "Generate summary report 📈"
|
|
run: |
|
|
# Aggregate all results
|
|
TOTAL_PASSED=0
|
|
TOTAL_FAILED=0
|
|
TOTAL_SKIPPED=0
|
|
HAS_FAILURES=false
|
|
|
|
# Temp file for collecting per-distro table rows
|
|
TEMP_ROWS=$(mktemp)
|
|
|
|
for json_file in $(find results -name 'result.json'); do
|
|
[ -f "$json_file" ] || continue
|
|
|
|
DISTRO=$(jq -r '.distro' "$json_file")
|
|
PASSED=$(jq -r '.passed' "$json_file")
|
|
FAILED=$(jq -r '.failed' "$json_file")
|
|
SKIPPED=$(jq -r '.skipped' "$json_file")
|
|
|
|
TOTAL_PASSED=$((TOTAL_PASSED + PASSED))
|
|
TOTAL_FAILED=$((TOTAL_FAILED + FAILED))
|
|
TOTAL_SKIPPED=$((TOTAL_SKIPPED + SKIPPED))
|
|
|
|
if [ "$FAILED" -gt 0 ]; then
|
|
HAS_FAILURES=true
|
|
if [ "$PASSED" -eq 0 ]; then
|
|
STATUS="❌"
|
|
else
|
|
STATUS="⚠️"
|
|
fi
|
|
else
|
|
STATUS="✅"
|
|
fi
|
|
|
|
echo "| ${DISTRO} | ${PASSED} | ${FAILED} | ${SKIPPED} | ${STATUS} |" >> "$TEMP_ROWS"
|
|
done
|
|
|
|
# Write summary header
|
|
echo "## Test Results 📊" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "| Metric | Count |" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "|--------|-------|" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "| ✅ Passed | ${TOTAL_PASSED} |" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "| ❌ Failed | ${TOTAL_FAILED} |" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "| ⏭️ Skipped | ${TOTAL_SKIPPED} |" >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
# Write per-distro breakdown
|
|
echo "" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "### Per-distro breakdown" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "| Distro | Passed | Failed | Skipped | Status |" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "|--------|--------|--------|---------|--------|" >> "$GITHUB_STEP_SUMMARY"
|
|
sort "$TEMP_ROWS" >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
# Collect and display failed URLs if any
|
|
if [ "$HAS_FAILURES" = true ]; then
|
|
echo "" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "### ❌ Failed URLs" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "" >> "$GITHUB_STEP_SUMMARY"
|
|
echo '```' >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
for failed_file in results/result-*/failed.txt; do
|
|
[ -f "$failed_file" ] && cat "$failed_file" >> "$GITHUB_STEP_SUMMARY"
|
|
done
|
|
|
|
echo '```' >> "$GITHUB_STEP_SUMMARY"
|
|
fi
|
|
|
|
# Print summary to log as well
|
|
echo "===== SUMMARY ====="
|
|
echo "Total Passed: ${TOTAL_PASSED}"
|
|
echo "Total Failed: ${TOTAL_FAILED}"
|
|
echo "Total Skipped: ${TOTAL_SKIPPED}"
|
|
echo "=================="
|
|
|
|
# Clean up temp file
|
|
rm -f "$TEMP_ROWS"
|
|
|
|
# Exit with failure if any distro had failures
|
|
if [ "$HAS_FAILURES" = true ]; then
|
|
echo "::error::Some distros have failed downloads. Check the summary for details."
|
|
exit 1
|
|
fi
|
|
|
|
feed-check:
|
|
name: "Feed check (distro-feeds) 📡"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: "Install dependencies 📦️"
|
|
run: |
|
|
SUDO_ASKPASS="$__hermes_sudo_dir/a" sudo "${__hermes_sudo_o[@]}" apt-get -y update
|
|
SUDO_ASKPASS="$__hermes_sudo_dir/a" sudo "${__hermes_sudo_o[@]}" apt-get -y install curl jq
|
|
|
|
- name: "Run feed-check 📡"
|
|
run: |
|
|
chmod +x ./feed-check
|
|
./feed-check
|
|
|
|
test-scripts:
|
|
name: "Script regression tests 🧪"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: "Install bats 📦️"
|
|
run: |
|
|
sudo apt-get -y update
|
|
sudo apt-get -y install bats
|
|
|
|
- name: "Run bats regression tests 🧪"
|
|
run: |
|
|
bats tests/test-sync-upstream*.bats
|