|
| 1 | +name: Test Package Installation |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'pyproject.toml' |
| 7 | + - 'setup.py' |
| 8 | + - 'MANIFEST.in' |
| 9 | + - 'tableauserverclient/**' |
| 10 | + - '.github/workflows/test-package-install.yml' |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + test-wheel-install: |
| 18 | + name: Test wheel installation on ${{ matrix.os }} |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 23 | + python-version: ['3.11'] |
| 24 | + |
| 25 | + runs-on: ${{ matrix.os }} |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v7 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - uses: actions/setup-python@v6 |
| 33 | + with: |
| 34 | + python-version: ${{ matrix.python-version }} |
| 35 | + |
| 36 | + - name: Install build tools |
| 37 | + run: | |
| 38 | + python -m pip install --upgrade pip |
| 39 | + pip install build check-wheel-contents |
| 40 | + |
| 41 | + - name: Build wheel |
| 42 | + run: python -m build |
| 43 | + |
| 44 | + - name: Check wheel contents |
| 45 | + run: check-wheel-contents dist/*.whl |
| 46 | + |
| 47 | + - name: Inspect wheel structure (Unix) |
| 48 | + if: runner.os != 'Windows' |
| 49 | + run: | |
| 50 | + unzip -l dist/*.whl > wheel-contents.txt |
| 51 | + cat wheel-contents.txt |
| 52 | + |
| 53 | + echo "Checking for correct package structure..." |
| 54 | + |
| 55 | + # Check for required files |
| 56 | + if ! grep -q "tableauserverclient/__init__.py" wheel-contents.txt; then |
| 57 | + echo "❌ ERROR: tableauserverclient/__init__.py not found in wheel!" |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | + |
| 61 | + if ! grep -q "tableauserverclient/server/server.py" wheel-contents.txt; then |
| 62 | + echo "❌ ERROR: tableauserverclient/server/server.py not found in wheel!" |
| 63 | + exit 1 |
| 64 | + fi |
| 65 | + |
| 66 | + if ! grep -q "tableauserverclient/models/workbook_item.py" wheel-contents.txt; then |
| 67 | + echo "❌ ERROR: tableauserverclient/models/workbook_item.py not found in wheel!" |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | + |
| 71 | + # Check that files are NOT at wrong location (missing tableauserverclient/ prefix) |
| 72 | + # Look for lines like " 123 server/server.py" which would be wrong |
| 73 | + if grep -E "^[[:space:]]+[0-9]+.*[[:space:]]server/server.py" wheel-contents.txt; then |
| 74 | + echo "❌ ERROR: Files found at wrong location (missing tableauserverclient/ prefix)!" |
| 75 | + echo "Files should be under tableauserverclient/, not at root level" |
| 76 | + exit 1 |
| 77 | + fi |
| 78 | + |
| 79 | + echo "✅ Wheel structure looks correct" |
| 80 | + |
| 81 | + - name: Inspect wheel structure (Windows) |
| 82 | + if: runner.os == 'Windows' |
| 83 | + shell: pwsh |
| 84 | + run: | |
| 85 | + $wheel = Get-ChildItem dist/*.whl | Select-Object -First 1 |
| 86 | + Add-Type -AssemblyName System.IO.Compression.FileSystem |
| 87 | + $zip = [System.IO.Compression.ZipFile]::OpenRead($wheel.FullName) |
| 88 | + $zip.Entries | Select-Object FullName | Out-File wheel-contents.txt |
| 89 | + $zip.Dispose() |
| 90 | + |
| 91 | + Get-Content wheel-contents.txt |
| 92 | + |
| 93 | + $contents = Get-Content wheel-contents.txt -Raw |
| 94 | + |
| 95 | + if ($contents -notmatch "tableauserverclient/__init__.py") { |
| 96 | + Write-Error "❌ ERROR: tableauserverclient/__init__.py not found in wheel!" |
| 97 | + exit 1 |
| 98 | + } |
| 99 | + |
| 100 | + if ($contents -notmatch "tableauserverclient/server/server.py") { |
| 101 | + Write-Error "❌ ERROR: tableauserverclient/server/server.py not found in wheel!" |
| 102 | + exit 1 |
| 103 | + } |
| 104 | + |
| 105 | + Write-Host "✅ Wheel structure looks correct" |
| 106 | + |
| 107 | + - name: Test installation in clean environment |
| 108 | + shell: bash |
| 109 | + run: | |
| 110 | + # Create and activate virtual environment |
| 111 | + python -m venv test-env |
| 112 | + |
| 113 | + if [ "$RUNNER_OS" == "Windows" ]; then |
| 114 | + source test-env/Scripts/activate |
| 115 | + else |
| 116 | + source test-env/bin/activate |
| 117 | + fi |
| 118 | + |
| 119 | + # Install the wheel (not editable!) |
| 120 | + pip install dist/*.whl |
| 121 | + |
| 122 | + # Move to temp directory to ensure we're not importing from source |
| 123 | + if [ "$RUNNER_OS" == "Windows" ]; then |
| 124 | + cd $TEMP |
| 125 | + else |
| 126 | + cd /tmp |
| 127 | + fi |
| 128 | + |
| 129 | + # Test basic import |
| 130 | + python -c "import tableauserverclient as TSC; print('✅ Import successful!')" |
| 131 | + |
| 132 | + # Test version access |
| 133 | + python -c "import tableauserverclient as TSC; print(f'Version info: {TSC.get_versions()}')" |
| 134 | + |
| 135 | + # Test that key classes are available |
| 136 | + python -c " |
| 137 | +import tableauserverclient as TSC |
| 138 | + |
| 139 | +# Check main classes are available |
| 140 | +assert hasattr(TSC, 'Server'), 'Server class not found' |
| 141 | +assert hasattr(TSC, 'TableauAuth'), 'TableauAuth class not found' |
| 142 | +assert hasattr(TSC, 'WorkbookItem'), 'WorkbookItem class not found' |
| 143 | +assert hasattr(TSC, 'DatasourceItem'), 'DatasourceItem class not found' |
| 144 | +assert hasattr(TSC, 'ProjectItem'), 'ProjectItem class not found' |
| 145 | + |
| 146 | +print('✅ All expected classes are available') |
| 147 | +" |
| 148 | + |
| 149 | + # Test basic functionality |
| 150 | + python -c " |
| 151 | +import tableauserverclient as TSC |
| 152 | + |
| 153 | +server = TSC.Server('http://example.com', use_server_version=False) |
| 154 | +print(f'✅ Server object created: {server}') |
| 155 | + |
| 156 | +auth = TSC.TableauAuth('username', 'password', 'site') |
| 157 | +print(f'✅ TableauAuth object created: {auth}') |
| 158 | +" |
| 159 | + |
| 160 | + # Show where package is installed |
| 161 | + python -c " |
| 162 | +import tableauserverclient |
| 163 | +import os |
| 164 | +pkg_location = os.path.dirname(tableauserverclient.__file__) |
| 165 | +print(f'Package installed at: {pkg_location}') |
| 166 | +" |
| 167 | + |
| 168 | + echo "✅ All installation tests passed!" |
| 169 | + |
| 170 | + - name: Upload wheel as artifact |
| 171 | + if: runner.os == 'Linux' # Only upload once |
| 172 | + uses: actions/upload-artifact@v7 |
| 173 | + with: |
| 174 | + name: wheel |
| 175 | + path: dist/*.whl |
| 176 | + retention-days: 7 |
0 commit comments