Skip to content

Test Binaries

Test Binaries #655

Workflow file for this run

name: Test Binaries
on:
release:
types: [edited]
schedule:
- cron: '0 0 * * *' # Run daily
workflow_dispatch:
push:
paths:
- '.github/workflows/test-binaries.yml'
- 'test-binaries/**'
- 'packages/**'
jobs:
test-packages:
# Only run when Binaries release is updated
if: ${{ github.event_name != 'release' || github.event.release.tag_name == 'Binaries' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
cbp_bin: cbp.linux
- os: macos-latest
cbp_bin: cbp.macos
- os: windows-latest
cbp_bin: cbp.windows.exe
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download cbp
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
curl.exe -LO https://github.com/wang-q/cbp/releases/latest/download/${{ matrix.cbp_bin }}
else
curl -LO https://github.com/wang-q/cbp/releases/latest/download/${{ matrix.cbp_bin }}
chmod +x ${{ matrix.cbp_bin }}
fi
shell: bash
- name: Initialize cbp
run: |
./${{ matrix.cbp_bin }} init
if [ "$RUNNER_OS" == "Windows" ]; then
echo "$HOME/.cbp/bin" >> $GITHUB_PATH
else
echo "$HOME/.cbp/bin" >> $GITHUB_PATH
source ~/.bashrc
fi
shell: bash
- name: Test cbp installation
run: cbp --version || exit 1
shell: bash
- name: Install and test packages
run: |
platform=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
echo "==> Current platform: $platform"
# Get all packages and platform-specific available packages with retry
max_attempts=5
attempt=1
while [ $attempt -le $max_attempts ]; do
echo "==> Attempt $attempt of $max_attempts to get package lists"
if all_pkgs=$(cbp avail 2>/dev/null | grep -v "^==>" | tr -s '[:space:]' '\n' | grep -v '^$' | sed 's/[[:space:]]*$//' ) && \
platform_pkgs=$(cbp avail $platform 2>/dev/null | grep -v "^==>" | tr -s '[:space:]' '\n' | grep -v '^$' | sed 's/[[:space:]]*$//' ) && \
[ -n "$all_pkgs" ] && [ -n "$platform_pkgs" ]; then
break
fi
echo "==> Failed attempt $attempt, waiting 30 seconds before retry..."
sleep 30
attempt=$((attempt + 1))
done
if [ $attempt -gt $max_attempts ]; then
echo "Error: Failed to get package lists after $max_attempts attempts"
exit 1
fi
# Mark packages not available for current platform
for pkg in $all_pkgs; do
if ! echo "$platform_pkgs" | grep -q "^$pkg\$"; then
skipped_unavailable="${skipped_unavailable:-} $pkg"
fi
done
# Initialize result arrays
standalone_pass=""
standalone_fail=""
package_pass=""
package_fail=""
skipped_unavailable=""
skipped_notest=""
# Test available packages
for pkg in $platform_pkgs; do
echo "Testing $pkg..."
# Install package first
if ! cbp install $pkg; then
echo "❌ Failed to install $pkg"
continue
fi
# Run standalone test script
if [ -f "test-binaries/$pkg.sh" ]; then
echo "-> Running standalone tests"
if bash "test-binaries/$pkg.sh"; then
standalone_pass="${standalone_pass:+$standalone_pass }$pkg"
else
standalone_fail="${standalone_fail}❌ Failed: $pkg\n"
fi
fi
# Run package tests
if [ -f "packages/$pkg.json" ]; then
echo "-> Running package tests"
if cbp build test $pkg; then
package_pass="${package_pass:+$package_pass }$pkg"
else
package_fail="${package_fail}❌ Failed: $pkg\n"
fi
fi
# Mark as no test if neither exists
if [ ! -f "test-binaries/$pkg.sh" ] && [ ! -f "packages/$pkg.json" ]; then
skipped_notest="${skipped_notest:-} $pkg"
fi
done
echo -e "\n==> Test Summary:"
[ -n "${standalone_pass}" ] && echo -e "✅ Standalone tests passed: ${standalone_pass}"
[ -n "${standalone_fail}" ] && echo -e "${standalone_fail}"
[ -n "${package_pass}" ] && echo -e "✅ Package tests passed: ${package_pass}"
[ -n "${package_fail}" ] && echo -e "${package_fail}"
[ -n "${skipped_unavailable:-}" ] && echo -e "⏭️ Skipped (not available):${skipped_unavailable}"
[ -n "${skipped_notest:-}" ] && echo -e "⏭️ Skipped (no test):${skipped_notest}"
shell: bash