|
| 1 | +name: Test download.py |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + paths: |
| 7 | + - 'download.py' |
| 8 | + - '.github/workflows/test-download.yml' |
| 9 | + pull_request: |
| 10 | + branches: [ main ] |
| 11 | + paths: |
| 12 | + - 'download.py' |
| 13 | + - '.github/workflows/test-download.yml' |
| 14 | + schedule: |
| 15 | + # Run tests weekly to ensure scripts work with latest releases |
| 16 | + - cron: '0 0 * * 0' |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + test_version: |
| 20 | + description: 'Specific version to test (e.g., 20.1.8)' |
| 21 | + required: false |
| 22 | + default: 20.1.8 # set a default version for manual runs |
| 23 | + test_tool: |
| 24 | + description: 'Tool to test (clang-format, clang-tidy, or both)' |
| 25 | + required: false |
| 26 | + default: 'both' |
| 27 | + type: choice |
| 28 | + options: |
| 29 | + - both |
| 30 | + - clang-format |
| 31 | + - clang-tidy |
| 32 | + |
| 33 | +jobs: |
| 34 | + test-python-script: |
| 35 | + name: Test Python Script |
| 36 | + strategy: |
| 37 | + fail-fast: false |
| 38 | + matrix: |
| 39 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 40 | + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] |
| 41 | + tool: [clang-format, clang-tidy] |
| 42 | + exclude: |
| 43 | + # Skip some combinations to reduce CI time |
| 44 | + - os: windows-latest |
| 45 | + python-version: '3.8' |
| 46 | + - os: windows-latest |
| 47 | + python-version: '3.9' |
| 48 | + - os: macos-latest |
| 49 | + python-version: '3.8' |
| 50 | + - os: macos-latest |
| 51 | + python-version: '3.9' |
| 52 | + |
| 53 | + runs-on: ${{ matrix.os }} |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Checkout repository |
| 57 | + uses: actions/checkout@v4 |
| 58 | + |
| 59 | + - name: Set up Python ${{ matrix.python-version }} |
| 60 | + uses: actions/setup-python@v4 |
| 61 | + with: |
| 62 | + python-version: ${{ matrix.python-version }} |
| 63 | + |
| 64 | + - name: Test script help functionality |
| 65 | + run: python3 download.py --help |
| 66 | + |
| 67 | + - name: Test list platforms functionality (latest) |
| 68 | + run: python3 download.py ${{ matrix.tool }} --list-platforms |
| 69 | + |
| 70 | + - name: Test list platforms functionality (specific version) |
| 71 | + if: ${{ github.event.inputs.test_version != '' || github.event_name == 'schedule' }} |
| 72 | + run: | |
| 73 | + VERSION="${{ github.event.inputs.test_version || '20.1.8' }}" |
| 74 | + python3 download.py ${{ matrix.tool }} --version $VERSION --list-platforms |
| 75 | +
|
| 76 | + - name: Create test output directory |
| 77 | + run: mkdir -p test-downloads |
| 78 | + |
| 79 | + - name: Test download latest version |
| 80 | + run: | |
| 81 | + python3 download.py ${{ matrix.tool }} --output test-downloads |
| 82 | +
|
| 83 | + - name: Verify downloaded wheel (latest) |
| 84 | + shell: bash |
| 85 | + run: | |
| 86 | + ls -la test-downloads/ |
| 87 | + # Check if wheel file exists |
| 88 | + if [ "$(ls test-downloads/${{ matrix.tool }}*.whl 2>/dev/null | wc -l)" -eq 0 ]; then |
| 89 | + # Try with underscore naming |
| 90 | + if [ "$(ls test-downloads/${{'${{ matrix.tool }}' | sed 's/-/_/g'}}*.whl 2>/dev/null | wc -l)" -eq 0 ]; then |
| 91 | + echo "ERROR: No wheel file found for ${{ matrix.tool }}" |
| 92 | + exit 1 |
| 93 | + fi |
| 94 | + fi |
| 95 | + echo "✅ Successfully downloaded latest ${{ matrix.tool }} wheel" |
| 96 | +
|
| 97 | + - name: Test download specific version |
| 98 | + if: ${{ github.event.inputs.test_version != '' || github.event_name == 'schedule' }} |
| 99 | + run: | |
| 100 | + VERSION="${{ github.event.inputs.test_version || '20.1.8' }}" |
| 101 | + python3 download.py ${{ matrix.tool }} --version $VERSION --output test-downloads |
| 102 | +
|
| 103 | + - name: Verify downloaded wheel (specific version) |
| 104 | + if: ${{ github.event.inputs.test_version != '' || github.event_name == 'schedule' }} |
| 105 | + shell: bash |
| 106 | + run: | |
| 107 | + VERSION="${{ github.event.inputs.test_version || '20.1.8' }}" |
| 108 | + # Check if wheel file with specific version exists |
| 109 | + if [ "$(ls test-downloads/*$VERSION*.whl 2>/dev/null | wc -l)" -eq 0 ]; then |
| 110 | + echo "ERROR: No wheel file found for version $VERSION" |
| 111 | + exit 1 |
| 112 | + fi |
| 113 | + echo "✅ Successfully downloaded ${{ matrix.tool }} wheel version $VERSION" |
| 114 | +
|
| 115 | + - name: Test wheel installation |
| 116 | + run: | |
| 117 | + pip install test-downloads/${{ matrix.tool }}*.whl |
| 118 | +
|
| 119 | + - name: Test installed tool functionality |
| 120 | + shell: bash |
| 121 | + run: | |
| 122 | + TOOL_NAME="${{ matrix.tool }}" |
| 123 | + TOOL_CMD="${TOOL_NAME//-/_}" # Replace hyphens with underscores |
| 124 | +
|
| 125 | + # Test basic functionality |
| 126 | + if command -v $TOOL_CMD &> /dev/null; then |
| 127 | + echo "✅ $TOOL_CMD is available in PATH" |
| 128 | + $TOOL_CMD --version || $TOOL_CMD --help | head -5 |
| 129 | + else |
| 130 | + echo "⚠️ $TOOL_CMD not found in PATH, checking python module" |
| 131 | + python3 -m $TOOL_CMD --version || python3 -m $TOOL_CMD --help | head -5 |
| 132 | + fi |
| 133 | +
|
| 134 | + - name: Test platform override functionality |
| 135 | + run: | |
| 136 | + # Test with a different but compatible platform |
| 137 | + if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then |
| 138 | + python3 download.py ${{ matrix.tool }} --platform musllinux_1_2_x86_64 --output test-downloads/alt-platform |
| 139 | + elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then |
| 140 | + # Test both Intel and ARM platforms on macOS |
| 141 | + python3 download.py ${{ matrix.tool }} --platform macosx_10_9_x86_64 --output test-downloads/alt-platform |
| 142 | + fi |
| 143 | + continue-on-error: true # Platform override might not have wheels for all versions |
0 commit comments