Skip to content

Commit 66ab67d

Browse files
authored
Merge pull request #168 from thawn/copilot/add-macos-windows-ci-support
Add macOS and Windows support to E2E test workflow with optimized CI execution
2 parents cb59cf3 + 684a796 commit 66ab67d

13 files changed

+629
-113
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Script to install Chrome and ChromeDriver on Windows
2+
# Usage: install-chrome-windows.ps1
3+
4+
$ErrorActionPreference = "Stop"
5+
6+
Write-Host "Installing Chrome and ChromeDriver for Windows"
7+
8+
# Install Chrome using Chocolatey
9+
Write-Host "Installing Chrome via Chocolatey..."
10+
choco install googlechrome -y --ignore-checksums
11+
12+
# Find Chrome installation (check multiple common paths)
13+
$chromePaths = @(
14+
"C:\Program Files\Google\Chrome\Application\chrome.exe",
15+
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
16+
"$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe"
17+
)
18+
19+
$chromePath = $null
20+
foreach ($path in $chromePaths) {
21+
if (Test-Path $path) {
22+
$chromePath = $path
23+
break
24+
}
25+
}
26+
27+
if (-not $chromePath) {
28+
Write-Host "Error: Chrome installation not found"
29+
exit 1
30+
}
31+
32+
# Get Chrome version and download matching ChromeDriver
33+
$chromeVersion = (Get-Item $chromePath).VersionInfo.ProductVersion
34+
$majorVersion = $chromeVersion.Split('.')[0]
35+
Write-Host "Chrome version: $chromeVersion (found at: $chromePath)"
36+
37+
# Get ChromeDriver download URL for Windows
38+
Write-Host "Downloading ChromeDriver..."
39+
$json = Invoke-RestMethod -Uri "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json"
40+
$driverUrl = ($json.channels.Stable.downloads.chromedriver | Where-Object { $_.platform -eq "win64" }).url
41+
42+
# Download and extract ChromeDriver
43+
$tempDir = New-Item -ItemType Directory -Path (Join-Path $env:TEMP "chromedriver-temp-$(Get-Random)")
44+
$zipPath = Join-Path $tempDir "chromedriver.zip"
45+
Invoke-WebRequest -Uri $driverUrl -OutFile $zipPath
46+
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
47+
48+
# Move chromedriver to a location in PATH
49+
$binDir = Join-Path $env:RUNNER_TEMP "bin"
50+
New-Item -ItemType Directory -Force -Path $binDir | Out-Null
51+
Copy-Item -Path (Join-Path $tempDir "chromedriver-win64\chromedriver.exe") -Destination (Join-Path $binDir "chromedriver.exe") -Force
52+
Add-Content -Path $env:GITHUB_PATH -Value $binDir
53+
54+
# Cleanup
55+
Remove-Item -Recurse -Force $tempDir
56+
57+
Write-Host "ChromeDriver installed successfully"

.github/scripts/install-ffmpeg-macos.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
#!/bin/bash
22
# Script to install ffmpeg on macOS with timeout and retry
33
# Usage: install-ffmpeg-macos.sh <target_dir>
4-
# Example: install-ffmpeg-macos.sh lib/mac
4+
# Example: install-ffmpeg-macos.sh lib/mac (for builds)
5+
# install-ffmpeg-macos.sh (for CI - installs via Homebrew)
56

67
set -e
78

8-
TARGET_DIR="${1:-lib/mac}"
9+
TARGET_DIR="${1:-}"
10+
11+
# If no target directory specified, install via Homebrew (for CI)
12+
if [ -z "$TARGET_DIR" ]; then
13+
echo "Installing ffmpeg via Homebrew for CI..."
14+
brew install ffmpeg
15+
ffmpeg -version | head -n1
16+
echo "ffmpeg installation complete"
17+
exit 0
18+
fi
19+
20+
# Otherwise, download static binary (for builds)
21+
echo "Downloading and installing ffmpeg for macOS to $TARGET_DIR..."
22+
923
TIMEOUT_SECONDS=60
1024
URL="https://evermeet.cx/ffmpeg/getrelease/ffmpeg/zip"
1125

12-
echo "Downloading and installing ffmpeg for macOS..."
13-
1426
# Function to run command with timeout using Python
1527
# Only used internally with controlled commands (no user input)
1628
run_with_timeout() {
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Script to install ffmpeg on Windows with timeout and retry
2+
# Usage: install-ffmpeg-windows.ps1
3+
4+
$ErrorActionPreference = "Stop"
5+
6+
$TIMEOUT_SECONDS = 120
7+
$URL = "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip"
8+
9+
Write-Host "Downloading and installing ffmpeg for Windows..."
10+
11+
# Function to install ffmpeg with timeout
12+
function Install-Ffmpeg {
13+
param([int]$TimeoutSeconds = 120)
14+
15+
$tempDir = New-Item -ItemType Directory -Path (Join-Path $env:TEMP "ffmpeg-temp-$(Get-Random)")
16+
$zipPath = Join-Path $tempDir "ffmpeg.zip"
17+
18+
try {
19+
# Download with timeout
20+
Write-Host "Downloading ffmpeg..."
21+
$job = Start-Job -ScriptBlock {
22+
param($url, $zipPath)
23+
Invoke-WebRequest -Uri $url -OutFile $zipPath
24+
} -ArgumentList $URL, $zipPath
25+
26+
if (Wait-Job -Job $job -Timeout $TimeoutSeconds) {
27+
Receive-Job -Job $job
28+
Remove-Job -Job $job -Force
29+
30+
# Extract with timeout
31+
Write-Host "Extracting ffmpeg..."
32+
$extractJob = Start-Job -ScriptBlock {
33+
param($zipPath, $tempDir)
34+
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
35+
} -ArgumentList $zipPath, $tempDir
36+
37+
if (Wait-Job -Job $extractJob -Timeout $TimeoutSeconds) {
38+
Receive-Job -Job $extractJob
39+
Remove-Job -Job $extractJob -Force
40+
41+
# Find and move ffmpeg.exe to PATH
42+
$ffmpegDir = Get-ChildItem -Path $tempDir -Directory -Filter "ffmpeg-*" | Select-Object -First 1
43+
if (-not $ffmpegDir) {
44+
Write-Host "Error: ffmpeg directory not found in archive"
45+
return $false
46+
}
47+
$ffmpegExe = Join-Path (Join-Path $ffmpegDir.FullName "bin") "ffmpeg.exe"
48+
if (-not (Test-Path $ffmpegExe)) {
49+
Write-Host "Error: ffmpeg.exe not found at $ffmpegExe"
50+
return $false
51+
}
52+
53+
# Copy to a location in PATH (using GitHub Actions runner's bin directory)
54+
$targetBin = $null
55+
if ($env:GITHUB_PATH) {
56+
# In GitHub Actions, add to GITHUB_PATH
57+
$binDir = Join-Path $env:RUNNER_TEMP "bin"
58+
New-Item -ItemType Directory -Force -Path $binDir | Out-Null
59+
Copy-Item -Path $ffmpegExe -Destination (Join-Path $binDir "ffmpeg.exe") -Force
60+
Add-Content -Path $env:GITHUB_PATH -Value $binDir
61+
$targetBin = Join-Path $binDir "ffmpeg.exe"
62+
Write-Host "Added $binDir to PATH via GITHUB_PATH"
63+
} else {
64+
# For local testing, copy to a user directory
65+
# Note: You may need to add this directory to your PATH manually
66+
# In PowerShell: $env:PATH += ";$env:USERPROFILE\bin"
67+
# Or permanently: [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$env:USERPROFILE\bin", [System.EnvironmentVariableTarget]::User)
68+
$localBin = Join-Path $env:USERPROFILE "bin"
69+
New-Item -ItemType Directory -Force -Path $localBin | Out-Null
70+
Copy-Item -Path $ffmpegExe -Destination (Join-Path $localBin "ffmpeg.exe") -Force
71+
$targetBin = Join-Path $localBin "ffmpeg.exe"
72+
Write-Host "Installed to $localBin"
73+
Write-Host "IMPORTANT: Add this directory to your PATH if not already present:"
74+
Write-Host " PowerShell: `$env:PATH += ';$localBin'"
75+
Write-Host " Permanent: [Environment]::SetEnvironmentVariable('Path', `$env:Path + ';$localBin', [System.EnvironmentVariableTarget]::User)"
76+
}
77+
78+
# Verify installation using full path
79+
& $targetBin -version | Select-Object -First 1
80+
if ($LASTEXITCODE -eq 0) {
81+
return $true
82+
} else {
83+
Write-Host "Error: ffmpeg verification failed"
84+
return $false
85+
}
86+
} else {
87+
Stop-Job -Job $extractJob
88+
Remove-Job -Job $extractJob -Force
89+
return $false
90+
}
91+
} else {
92+
Stop-Job -Job $job
93+
Remove-Job -Job $job -Force
94+
return $false
95+
}
96+
} finally {
97+
# Cleanup temp directory
98+
if (Test-Path $tempDir) {
99+
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
100+
}
101+
}
102+
}
103+
104+
# First attempt
105+
Write-Host "Attempting to download ffmpeg (attempt 1)..."
106+
if (Install-Ffmpeg -TimeoutSeconds $TIMEOUT_SECONDS) {
107+
Write-Host "ffmpeg installed successfully on first attempt"
108+
} else {
109+
Write-Host "First attempt failed or timed out, retrying..."
110+
111+
# Clean up any stale temp directories
112+
Get-ChildItem -Path $env:TEMP -Directory -Filter "ffmpeg-temp-*" -ErrorAction SilentlyContinue |
113+
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
114+
115+
# Retry
116+
Write-Host "Attempting to download ffmpeg (attempt 2)..."
117+
if (Install-Ffmpeg -TimeoutSeconds $TIMEOUT_SECONDS) {
118+
Write-Host "ffmpeg installed successfully on second attempt"
119+
} else {
120+
Write-Host "ffmpeg installation failed after 2 attempts"
121+
exit 1
122+
}
123+
}
124+
125+
Write-Host "ffmpeg installation complete"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
# Script to install tttool on Linux
3+
# Usage: install-tttool-linux.sh <target_dir>
4+
# Example: install-tttool-linux.sh lib/linux
5+
# install-tttool-linux.sh (installs to /usr/local/bin for CI)
6+
7+
set -e
8+
9+
TARGET_DIR="${1:-}"
10+
TTTOOL_VERSION="1.8.1"
11+
12+
echo "Installing tttool version $TTTOOL_VERSION for Linux"
13+
14+
# Create temp directory for extraction
15+
TEMP_DIR=$(mktemp -d)
16+
cd "$TEMP_DIR"
17+
18+
# Download and extract tttool
19+
wget -q "https://github.com/entropia/tip-toi-reveng/releases/download/${TTTOOL_VERSION}/tttool-${TTTOOL_VERSION}.zip"
20+
unzip -q "tttool-${TTTOOL_VERSION}.zip"
21+
22+
# Make binary executable
23+
chmod +x tttool
24+
25+
if [ -n "$TARGET_DIR" ]; then
26+
# Install to specified directory (for build if needed)
27+
echo "Installing to $TARGET_DIR"
28+
mkdir -p "$TARGET_DIR"
29+
mv tttool "$TARGET_DIR/tttool"
30+
31+
# Cleanup temp directory
32+
cd "$GITHUB_WORKSPACE"
33+
chmod -R u+w "$TEMP_DIR" || true
34+
rm -rf "$TEMP_DIR"
35+
36+
# Verify
37+
"$TARGET_DIR/tttool" --help || {
38+
echo "Error: tttool installation failed"
39+
exit 1
40+
}
41+
echo "tttool installed successfully to $TARGET_DIR"
42+
else
43+
# Install to /usr/local/bin (for CI)
44+
echo "Installing to /usr/local/bin"
45+
sudo mv tttool /usr/local/bin/
46+
47+
# Cleanup temp directory
48+
cd "$GITHUB_WORKSPACE"
49+
chmod -R u+w "$TEMP_DIR" || true
50+
rm -rf "$TEMP_DIR"
51+
52+
# Verify
53+
tttool --help || {
54+
echo "Error: tttool installation failed"
55+
exit 1
56+
}
57+
echo "tttool installed successfully to /usr/local/bin"
58+
fi
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
# Script to install tttool on macOS
3+
# Usage: install-tttool-macos.sh <target_dir>
4+
# Example: install-tttool-macos.sh lib/mac
5+
# install-tttool-macos.sh (installs to /usr/local/bin for CI)
6+
7+
set -e
8+
9+
TARGET_DIR="${1:-}"
10+
TTTOOL_VERSION="1.11"
11+
12+
echo "Installing tttool version $TTTOOL_VERSION for macOS"
13+
14+
# Create temp directory for extraction
15+
TEMP_DIR=$(mktemp -d)
16+
cd "$TEMP_DIR"
17+
18+
# Download and extract tttool
19+
wget -q "https://github.com/entropia/tip-toi-reveng/releases/download/${TTTOOL_VERSION}/tttool-${TTTOOL_VERSION}.zip"
20+
unzip -q "tttool-${TTTOOL_VERSION}.zip"
21+
cd "tttool-${TTTOOL_VERSION}/osx"
22+
23+
# Make binary executable
24+
chmod +x tttool
25+
26+
if [ -n "$TARGET_DIR" ]; then
27+
# Install to specified directory (for build)
28+
echo "Installing to $TARGET_DIR"
29+
mkdir -p "$GITHUB_WORKSPACE/$TARGET_DIR"
30+
mv tttool "$GITHUB_WORKSPACE/$TARGET_DIR/tttool"
31+
32+
# Copy all .dylib files if they exist
33+
if ls *.dylib 1> /dev/null 2>&1; then
34+
mv *.dylib "$GITHUB_WORKSPACE/$TARGET_DIR/"
35+
fi
36+
37+
# Cleanup temp directory
38+
cd "$GITHUB_WORKSPACE"
39+
chmod -R u+w "$TEMP_DIR" || true
40+
rm -rf "$TEMP_DIR"
41+
42+
# Verify
43+
"$GITHUB_WORKSPACE/$TARGET_DIR/tttool" --help || {
44+
echo "Error: tttool installation failed"
45+
exit 1
46+
}
47+
echo "tttool installed successfully to $TARGET_DIR"
48+
else
49+
# Install to /usr/local/bin (for CI)
50+
echo "Installing to /usr/local/bin"
51+
sudo mv tttool /usr/local/bin/tttool
52+
53+
# Copy all .dylib files if they exist
54+
if ls *.dylib 1> /dev/null 2>&1; then
55+
sudo mv *.dylib /usr/local/bin/
56+
fi
57+
58+
# Cleanup temp directory
59+
cd "$GITHUB_WORKSPACE"
60+
chmod -R u+w "$TEMP_DIR" || true
61+
rm -rf "$TEMP_DIR"
62+
63+
# Verify
64+
tttool --help || {
65+
echo "Error: tttool installation failed"
66+
exit 1
67+
}
68+
echo "tttool installed successfully to /usr/local/bin"
69+
fi

0 commit comments

Comments
 (0)