Skip to content

GitHub Actions Test Infrastructure #11

GitHub Actions Test Infrastructure

GitHub Actions Test Infrastructure #11

Workflow file for this run

name: Test CCKP Toolkit Workflow
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: Run nf-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Nextflow
run: |
curl -s https://get.nextflow.io | bash
mv nextflow /usr/local/bin/
nextflow -version
- name: Install nf-test
run: |
curl -fsSL https://get.nf-test.com | bash
mv nf-test /usr/local/bin/
nf-test --version
- name: Set up Docker
uses: docker/setup-buildx-action@v2
- name: Run tests
run: |
nf-test test main.nf.test
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: |
work/
.nextflow/
.nextflow.log
retention-days: 7
output-validation:
name: Output Validation
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download test results
uses: actions/download-artifact@v4
with:
name: test-results
path: work/
- name: Validate outputs
run: |
# Test 1: Check consolidated report
if [ ! -f "work/consolidated_report.csv" ] || [ ! -s "work/consolidated_report.csv" ]; then
echo "❌ Consolidated report is missing or empty"
exit 1
fi
echo "✓ Consolidated report exists and is not empty"
# Test 2: Check Almanack results
if [ ! -f "work/PythonOT_POT_almanack-results.json" ] || [ ! -s "work/PythonOT_POT_almanack-results.json" ]; then
echo "❌ Almanack results are missing or empty"
exit 1
fi
echo "✓ Almanack results exist and are not empty"
# Test 3: Validate CSV structure
if ! head -n 1 "work/consolidated_report.csv" | grep -q "target"; then
echo "❌ CSV header is missing or incorrect"
exit 1
fi
echo "✓ CSV header is valid"
# Test 4: Check status values
if ! grep -q "PASS\|FAIL" "work/consolidated_report.csv"; then
echo "❌ No valid status values found in CSV"
exit 1
fi
echo "✓ Status values are present"
# Test 5: Check status files
if [ ! -f "work/status_repo.txt" ]; then
echo "❌ Repository status file is missing"
exit 1
fi
echo "✓ Repository status file exists"
if [ ! -f "work/status_almanack_POT.txt" ]; then
echo "❌ Almanack status file is missing"
exit 1
fi
echo "✓ Almanack status file exists"
error-handling:
name: Error Handling
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Nextflow
run: |
curl -s https://get.nextflow.io | bash
mv nextflow /usr/local/bin/
nextflow -version
- name: Set up Docker
uses: docker/setup-buildx-action@v2
- name: Test invalid repository URL
run: |
rm -rf error_test_results
if nextflow run main.nf --repo_url "invalid-url" --output_dir error_test_results 2>&1 | grep -q "ERROR: Invalid repository URL format. Expected: https://github.com/username/repo.git"; then
echo "✓ Invalid repository URL test passed"
else
echo "❌ Workflow should fail with invalid repository URL"
exit 1
fi
- name: Test invalid sample sheet
run: |
rm -rf error_test_results
# Create a temporary invalid CSV file with wrong column name and data
echo "wrong_column" > invalid.csv
echo "https://github.com/test/repo.git" >> invalid.csv
if nextflow run main.nf --sample_sheet invalid.csv --output_dir error_test_results 2>&1 | grep -q "ERROR: Sample sheet must contain a 'repo_url' column"; then
echo "✓ Invalid sample sheet test passed"
else
echo "❌ Workflow should fail with invalid sample sheet"
exit 1
fi
rm invalid.csv
- name: Test conflicting parameters
run: |
rm -rf error_test_results
if nextflow run main.nf \
--repo_url https://github.com/PythonOT/POT.git \
--sample_sheet tests/fixtures/example-input.csv \
--output_dir error_test_results 2>&1 | grep -q "ERROR: Provide either a sample_sheet or repo_url"; then
echo "✓ Conflicting parameters test passed"
else
echo "❌ Workflow should fail when both repo_url and sample_sheet are provided"
exit 1
fi
- name: Test Synapse parameter validation
run: |
rm -rf error_test_results
# Test that workflow runs without synapse_folder_id when upload_to_synapse is false
if ! nextflow run main.nf \
--repo_url https://github.com/PythonOT/POT.git \
--output_dir error_test_results; then
echo "❌ Workflow should run without synapse_folder_id when upload_to_synapse is false"
exit 1
fi
echo "✓ Workflow runs without synapse_folder_id when upload_to_synapse is false"
# Test that workflow fails without synapse_folder_id when upload_to_synapse is true
if nextflow run main.nf \
--repo_url https://github.com/PythonOT/POT.git \
--upload_to_synapse \
--output_dir error_test_results 2>&1 | grep -q "ERROR: synapse_folder_id must be provided when --upload_to_synapse is true"; then
echo "✓ Workflow fails without synapse_folder_id when upload_to_synapse is true"
else
echo "❌ Workflow should fail without synapse_folder_id when upload_to_synapse is true"
exit 1
fi
- name: Upload error test results
uses: actions/upload-artifact@v4
if: always()
with:
name: error-test-results
path: error_test_results/
retention-days: 7