Skip to content

Merge pull request #12 from tidymodels/dials #39

Merge pull request #12 from tidymodels/dials

Merge pull request #12 from tidymodels/dials #39

name: Test Repository Clone Scripts
on:
push:
branches: [ main, updates ]
paths:
- 'developers/shared-references/scripts/**'
- '.github/workflows/test-clone-scripts.yml'
pull_request:
branches: [ main ]
paths:
- 'developers/shared-references/scripts/**'
- '.github/workflows/test-clone-scripts.yml'
workflow_dispatch: # Allow manual triggering
jobs:
test-bash-macos:
name: Test Bash Script on macOS
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Verify git is installed
run: git --version
- name: Make script executable
run: chmod +x developers/shared-references/scripts/clone-tidymodels-repos.sh
- name: Test script with no arguments (should fail)
run: |
set +e
./developers/shared-references/scripts/clone-tidymodels-repos.sh
exit_code=$?
if [ $exit_code -eq 1 ]; then
echo "✓ Script correctly exits with code 1 when no arguments provided"
exit 0
else
echo "✗ Expected exit code 1, got $exit_code"
exit 1
fi
- name: Test cloning yardstick
run: |
cd /tmp
mkdir -p test-yardstick
cd test-yardstick
$GITHUB_WORKSPACE/developers/shared-references/scripts/clone-tidymodels-repos.sh yardstick
- name: Verify yardstick clone
run: |
cd /tmp/test-yardstick
# Check repository exists
if [ ! -d "repos/yardstick" ]; then
echo "✗ repos/yardstick directory not found"
exit 1
fi
echo "✓ repos/yardstick directory exists"
# Check for R files
if [ ! -d "repos/yardstick/R" ]; then
echo "✗ repos/yardstick/R directory not found"
exit 1
fi
echo "✓ repos/yardstick/R directory exists"
# Check shallow clone
if [ ! -f "repos/yardstick/.git/shallow" ]; then
echo "✗ Not a shallow clone"
exit 1
fi
echo "✓ Shallow clone verified"
# Check .gitignore
if ! grep -q "repos/" .gitignore; then
echo "✗ repos/ not found in .gitignore"
exit 1
fi
echo "✓ .gitignore contains 'repos/'"
# Check .Rbuildignore
if ! grep -qF "^repos$" .Rbuildignore; then
echo "✗ ^repos$ not found in .Rbuildignore"
exit 1
fi
echo "✓ .Rbuildignore contains '^repos$'"
- name: Test idempotency (run again)
run: |
cd /tmp/test-yardstick
$GITHUB_WORKSPACE/developers/shared-references/scripts/clone-tidymodels-repos.sh yardstick
- name: Verify no duplicates in ignore files
run: |
cd /tmp/test-yardstick
repos_count=$(grep -c "repos/" .gitignore || true)
if [ "$repos_count" -ne 1 ]; then
echo "✗ Found $repos_count occurrences of 'repos/' in .gitignore (expected 1)"
exit 1
fi
echo "✓ No duplicates in .gitignore"
rbuild_count=$(grep -cF "^repos$" .Rbuildignore || true)
if [ "$rbuild_count" -ne 1 ]; then
echo "✗ Found $rbuild_count occurrences of '^repos$' in .Rbuildignore (expected 1)"
exit 1
fi
echo "✓ No duplicates in .Rbuildignore"
- name: Test cloning all packages
run: |
cd /tmp
mkdir -p test-all
cd test-all
$GITHUB_WORKSPACE/developers/shared-references/scripts/clone-tidymodels-repos.sh all
- name: Verify all packages cloned
run: |
cd /tmp/test-all
if [ ! -d "repos/yardstick" ] || [ ! -d "repos/recipes" ] || [ ! -d "repos/dials" ]; then
echo "✗ Not all packages cloned"
exit 1
fi
echo "✓ All packages cloned successfully"
test-bash-linux:
name: Test Bash Script on Linux
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Verify git is installed
run: git --version
- name: Make script executable
run: chmod +x developers/shared-references/scripts/clone-tidymodels-repos.sh
- name: Test cloning yardstick
run: |
cd /tmp
mkdir -p test-yardstick
cd test-yardstick
$GITHUB_WORKSPACE/developers/shared-references/scripts/clone-tidymodels-repos.sh yardstick
- name: Verify yardstick clone
run: |
cd /tmp/test-yardstick
# Check repository exists
if [ ! -d "repos/yardstick" ]; then
echo "✗ repos/yardstick directory not found"
exit 1
fi
echo "✓ repos/yardstick directory exists"
# Check shallow clone
if [ ! -f "repos/yardstick/.git/shallow" ]; then
echo "✗ Not a shallow clone"
exit 1
fi
echo "✓ Shallow clone verified"
# Check ignore files
if ! grep -q "repos/" .gitignore; then
echo "✗ repos/ not found in .gitignore"
exit 1
fi
echo "✓ .gitignore updated correctly"
test-powershell-windows:
name: Test PowerShell Script on Windows
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Verify git is installed
run: git --version
- name: Test script with no arguments (should fail)
shell: powershell
run: |
$ErrorActionPreference = 'Continue'
& "$env:GITHUB_WORKSPACE\developers\shared-references\scripts\clone-tidymodels-repos.ps1" 2>&1 | Out-Null
if ($LASTEXITCODE -ne 1) {
Write-Error "Expected exit code 1, got $LASTEXITCODE"
exit 1
}
Write-Host "[PASS] Script correctly exits with code 1 when no arguments provided"
exit 0
- name: Test cloning yardstick
shell: powershell
run: |
$testDir = "$env:TEMP\test-yardstick"
New-Item -ItemType Directory -Path $testDir -Force | Out-Null
Set-Location $testDir
& "$env:GITHUB_WORKSPACE\developers\shared-references\scripts\clone-tidymodels-repos.ps1" yardstick
- name: Verify yardstick clone
shell: powershell
run: |
$testDir = "$env:TEMP\test-yardstick"
Set-Location $testDir
# Check repository exists
if (!(Test-Path "repos\yardstick")) {
Write-Error "repos\yardstick directory not found"
exit 1
}
Write-Host "[PASS] repos\yardstick directory exists"
# Check for R files
if (!(Test-Path "repos\yardstick\R")) {
Write-Error "repos\yardstick\R directory not found"
exit 1
}
Write-Host "[PASS] repos\yardstick\R directory exists"
# Check shallow clone
if (!(Test-Path "repos\yardstick\.git\shallow")) {
Write-Error "Not a shallow clone"
exit 1
}
Write-Host "[PASS] Shallow clone verified"
# Check .gitignore
if (!(Select-String -Path .gitignore -Pattern "repos/" -Quiet)) {
Write-Error "repos/ not found in .gitignore"
exit 1
}
Write-Host "[PASS] .gitignore contains 'repos/'"
# Check .Rbuildignore
if (!(Select-String -Path .Rbuildignore -Pattern "\^repos\$" -Quiet)) {
Write-Error "^repos$ not found in .Rbuildignore"
exit 1
}
Write-Host "[PASS] .Rbuildignore contains '^repos$'"
- name: Test idempotency (run again)
shell: powershell
run: |
$testDir = "$env:TEMP\test-yardstick"
Set-Location $testDir
& "$env:GITHUB_WORKSPACE\developers\shared-references\scripts\clone-tidymodels-repos.ps1" yardstick
- name: Verify no duplicates in ignore files
shell: powershell
run: |
$testDir = "$env:TEMP\test-yardstick"
Set-Location $testDir
$gitignoreCount = (Select-String -Path .gitignore -Pattern "repos/" -AllMatches).Matches.Count
if ($gitignoreCount -ne 1) {
Write-Error "Found $gitignoreCount occurrences of 'repos/' in .gitignore (expected 1)"
exit 1
}
Write-Host "[PASS] No duplicates in .gitignore"
$rbuildCount = (Select-String -Path .Rbuildignore -Pattern "\^repos\$" -AllMatches).Matches.Count
if ($rbuildCount -ne 1) {
Write-Error "Found $rbuildCount occurrences of '^repos$' in .Rbuildignore (expected 1)"
exit 1
}
Write-Host "[PASS] No duplicates in .Rbuildignore"
- name: Test cloning all packages
shell: powershell
run: |
$testDir = "$env:TEMP\test-all"
New-Item -ItemType Directory -Path $testDir -Force | Out-Null
Set-Location $testDir
& "$env:GITHUB_WORKSPACE\developers\shared-references\scripts\clone-tidymodels-repos.ps1" all
- name: Verify all packages cloned
shell: powershell
run: |
$testDir = "$env:TEMP\test-all"
Set-Location $testDir
if (!(Test-Path "repos\yardstick") -or !(Test-Path "repos\recipes") -or !(Test-Path "repos\dials")) {
Write-Error "Not all packages cloned"
exit 1
}
Write-Host "[PASS] All packages cloned successfully"
test-python:
name: Test Python Script on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.11']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Verify git is installed
run: git --version
- name: Test script with no arguments (should fail)
run: |
python developers/shared-references/scripts/clone-tidymodels-repos.py 2>&1 || true
continue-on-error: true
- name: Test cloning yardstick (Unix)
if: runner.os != 'Windows'
run: |
cd /tmp
mkdir -p test-python
cd test-python
python $GITHUB_WORKSPACE/developers/shared-references/scripts/clone-tidymodels-repos.py yardstick
- name: Test cloning yardstick (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$testDir = "$env:TEMP\test-python"
New-Item -ItemType Directory -Path $testDir -Force | Out-Null
Set-Location $testDir
python "$env:GITHUB_WORKSPACE\developers\shared-references\scripts\clone-tidymodels-repos.py" yardstick
- name: Verify yardstick clone (Unix)
if: runner.os != 'Windows'
run: |
cd /tmp/test-python
if [ ! -d "repos/yardstick" ]; then
echo "✗ repos/yardstick directory not found"
exit 1
fi
echo "✓ repos/yardstick directory exists"
if [ ! -f "repos/yardstick/.git/shallow" ]; then
echo "✗ Not a shallow clone"
exit 1
fi
echo "✓ Shallow clone verified"
- name: Verify yardstick clone (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$testDir = "$env:TEMP\test-python"
Set-Location $testDir
if (!(Test-Path "repos\yardstick")) {
Write-Error "repos\yardstick directory not found"
exit 1
}
Write-Host "✓ repos\yardstick directory exists"
if (!(Test-Path "repos\yardstick\.git\shallow")) {
Write-Error "Not a shallow clone"
exit 1
}
Write-Host "✓ Shallow clone verified"
summary:
name: Test Summary
needs: [test-bash-macos, test-bash-linux, test-powershell-windows, test-python]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check test results
run: |
echo "## Test Results Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Script | Platform | Status |" >> $GITHUB_STEP_SUMMARY
echo "|--------|----------|--------|" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.test-bash-macos.result }}" == "success" ]; then
echo "| Bash | macOS | :white_check_mark: Passed |" >> $GITHUB_STEP_SUMMARY
else
echo "| Bash | macOS | :x: Failed |" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ needs.test-bash-linux.result }}" == "success" ]; then
echo "| Bash | Linux | :white_check_mark: Passed |" >> $GITHUB_STEP_SUMMARY
else
echo "| Bash | Linux | :x: Failed |" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ needs.test-powershell-windows.result }}" == "success" ]; then
echo "| PowerShell | Windows | :white_check_mark: Passed |" >> $GITHUB_STEP_SUMMARY
else
echo "| PowerShell | Windows | :x: Failed |" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ needs.test-python.result }}" == "success" ]; then
echo "| Python | All platforms | :white_check_mark: Passed |" >> $GITHUB_STEP_SUMMARY
else
echo "| Python | All platforms | :x: Failed |" >> $GITHUB_STEP_SUMMARY
fi
# Fail if any job failed
if [ "${{ needs.test-bash-macos.result }}" != "success" ] || \
[ "${{ needs.test-bash-linux.result }}" != "success" ] || \
[ "${{ needs.test-powershell-windows.result }}" != "success" ] || \
[ "${{ needs.test-python.result }}" != "success" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo ":warning: Some tests failed. Please review the logs above." >> $GITHUB_STEP_SUMMARY
exit 1
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo ":white_check_mark: All tests passed successfully!" >> $GITHUB_STEP_SUMMARY