batch 2 final #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Nextflow on Arm64 | |
| on: | |
| workflow_call: | |
| push: | |
| branches: | |
| - main | |
| - smoke_tests | |
| paths: | |
| - 'content/opensource_packages/nextflow.md' | |
| - '.github/workflows/test-nextflow.yml' | |
| jobs: | |
| test-nextflow: | |
| runs-on: ubuntu-24.04-arm | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set test metadata | |
| id: metadata | |
| run: | | |
| echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT | |
| echo "package_slug=nextflow" >> $GITHUB_OUTPUT | |
| echo "dashboard_link=/opensource_packages/nextflow" >> $GITHUB_OUTPUT | |
| # ============================================================ | |
| # CUSTOMIZE THIS: Install your package | |
| # ============================================================ | |
| - name: Install Nextflow | |
| id: install | |
| run: | | |
| echo "Installing Prerequisites (Java 17)..." | |
| sudo apt-get update | |
| sudo apt-get install -y openjdk-17-jre-headless default-jre curl | |
| echo "Installing Nextflow via official script..." | |
| # The official script is more robust and handles environment better | |
| if curl -s https://get.nextflow.io | bash; then | |
| chmod +x nextflow | |
| sudo mv nextflow /usr/local/bin/ | |
| echo "Nextflow installed successfully" | |
| echo "install_status=success" >> $GITHUB_OUTPUT | |
| else | |
| echo "Nextflow installation failed" | |
| echo "install_status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| # ============================================================ | |
| # CUSTOMIZE THIS: Get the package version | |
| # ============================================================ | |
| - name: Get Nextflow version | |
| id: version | |
| run: | | |
| if command -v nextflow &> /dev/null; then | |
| # Output format: "nextflow version 23.10.0.5891" | |
| VERSION=$(nextflow -version 2>&1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | head -n 1 || nextflow -version 2>&1 | grep "nextflow version" | awk '{print $3}' || echo "unknown") | |
| else | |
| VERSION="unknown" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Detected Nextflow version: $VERSION" | |
| # ============================================================ | |
| # ADD YOUR TESTS BELOW | |
| # Each test should: | |
| # 1. Have a unique id (test1, test2, etc.) | |
| # 2. Track start/end time for duration | |
| # 3. Set status=passed or status=failed | |
| # 4. Exit 1 on failure | |
| # ============================================================ | |
| - name: Test 1 - Check nextflow binary | |
| id: test1 | |
| continue-on-error: true | |
| run: | | |
| START_TIME=$(date +%s) | |
| if command -v nextflow &> /dev/null; then | |
| echo "✓ nextflow binary found" | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ nextflow binary not found" | |
| echo "status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| END_TIME=$(date +%s) | |
| echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT | |
| - name: Test 2 - Check version command | |
| id: test2 | |
| continue-on-error: true | |
| run: | | |
| START_TIME=$(date +%s) | |
| if nextflow -version 2>&1 | grep -q "nextflow version"; then | |
| echo "✓ version command works" | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ version command failed" | |
| echo "status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| END_TIME=$(date +%s) | |
| echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT | |
| - name: Test 3 - Check help command | |
| id: test3 | |
| continue-on-error: true | |
| run: | | |
| START_TIME=$(date +%s) | |
| if nextflow -help 2>&1 | grep -q "Usage"; then | |
| echo "✓ help command works" | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ help command failed" | |
| echo "status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| END_TIME=$(date +%s) | |
| echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT | |
| - name: Test 4 - Architecture Verification | |
| id: test4 | |
| continue-on-error: true | |
| run: | | |
| START_TIME=$(date +%s) | |
| echo "Checking system architecture..." | |
| ARCH=$(uname -m) | |
| if [ "$ARCH" = "aarch64" ]; then | |
| echo "✓ System architecture is ARM64 ($ARCH)" | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ System architecture is NOT ARM64 ($ARCH)" | |
| echo "status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| END_TIME=$(date +%s) | |
| echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT | |
| - name: Test 5 - Run Hello World pipeline | |
| id: test5 | |
| continue-on-error: true | |
| run: | | |
| START_TIME=$(date +%s) | |
| # Run the built-in hello pipeline | |
| # First run often involves self-update or capsule download | |
| if nextflow run hello; then | |
| echo "✓ Hello world pipeline ran successfully" | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ Hello world pipeline failed" | |
| echo "status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| END_TIME=$(date +%s) | |
| echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT | |
| # ============================================================ | |
| # UPDATE THIS: Calculate summary based on your number of tests | |
| # Add/remove test result checks to match your tests above | |
| - name: Calculate test summary | |
| if: always() | |
| id: summary | |
| run: | | |
| set +e # Disable exit on error for this step | |
| PASSED=0 | |
| FAILED=0 | |
| TOTAL_DURATION=0 | |
| # Helper function to add duration safely | |
| add_duration() { | |
| local val=$1 | |
| if [[ "$val" =~ ^[0-9]+$ ]]; then | |
| TOTAL_DURATION=$((TOTAL_DURATION + val)) | |
| fi | |
| } | |
| # Iterate through possible steps to check status | |
| # We check explicit passed status, everything else is failure if not skipped (but simplification: if not passed, and supposed to run, it failed) | |
| # Check Test 1 | |
| if [ "${{ steps.test1.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| elif [ "${{ steps.test1.conclusion }}" == "failure" ] || [ "${{ steps.test1.outcome }}" == "failure" ]; then | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| add_duration "${{ steps.test1.outputs.duration }}" | |
| # Check Test 2 | |
| if [ "${{ steps.test2.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| elif [ "${{ steps.test2.conclusion }}" == "failure" ] || [ "${{ steps.test2.outcome }}" == "failure" ]; then | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| add_duration "${{ steps.test2.outputs.duration }}" | |
| # Check Test 3 | |
| if [ "${{ steps.test3.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| elif [ "${{ steps.test3.conclusion }}" == "failure" ] || [ "${{ steps.test3.outcome }}" == "failure" ]; then | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| add_duration "${{ steps.test3.outputs.duration }}" | |
| # Check Test 4 - Architecture | |
| if [ "${{ steps.test4.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| elif [ "${{ steps.test4.conclusion }}" == "failure" ] || [ "${{ steps.test4.outcome }}" == "failure" ]; then | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| add_duration "${{ steps.test4.outputs.duration }}" | |
| # Check Test 5 - Functional | |
| if [ "${{ steps.test5.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| elif [ "${{ steps.test5.conclusion }}" == "failure" ] || [ "${{ steps.test5.outcome }}" == "failure" ]; then | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| add_duration "${{ steps.test5.outputs.duration }}" | |
| echo "passed=$PASSED" >> $GITHUB_OUTPUT | |
| echo "failed=$FAILED" >> $GITHUB_OUTPUT | |
| echo "duration=$TOTAL_DURATION" >> $GITHUB_OUTPUT | |
| # Determine overall status | |
| if [ $FAILED -eq 0 ] && [ $PASSED -gt 0 ]; then | |
| echo "overall_status=success" >> $GITHUB_OUTPUT | |
| echo "badge_status=passing" >> $GITHUB_OUTPUT | |
| else | |
| echo "overall_status=failure" >> $GITHUB_OUTPUT | |
| echo "badge_status=failing" >> $GITHUB_OUTPUT | |
| # Only exit 1 if we want to fail the job when tests fail | |
| exit 1 | |
| fi | |
| - name: Generate test results JSON | |
| if: always() | |
| run: | | |
| # Fetch the direct job URL for deep-linking | |
| JOB_ID="${{ github.job }}" | |
| # Using GH_TOKEN to find the exact job URL. | |
| # Reusable workflows are often named "JobID / JobID" or just "JobID" | |
| JOB_URL=$(GH_TOKEN=${{ github.token }} gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs --jq ".jobs[] | select(.name == \"$JOB_ID / $JOB_ID\" or .name == \"$JOB_ID\") | .html_url" | head -n 1) | |
| # Fallback if URL calculation fails | |
| if [ -z "$JOB_URL" ]; then | |
| JOB_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?check_suite_focus=true&query=job:$JOB_ID" | |
| fi | |
| mkdir -p test-results | |
| cat > test-results/nextflow.json << EOF | |
| { | |
| "schema_version": "1.0", | |
| "package": { | |
| "name": "Nextflow", | |
| "version": "${{ steps.version.outputs.version }}", | |
| "language": "REPLACE_ME", | |
| "category": "REPLACE_ME" | |
| }, | |
| "run": { | |
| "id": "${{ github.run_id }}", | |
| "url": "$JOB_URL", | |
| "timestamp": "${{ steps.metadata.outputs.timestamp }}", | |
| "status": "${{ steps.summary.outputs.overall_status }}", | |
| "runner": { | |
| "os": "ubuntu-24.04", | |
| "arch": "arm64" | |
| } | |
| }, | |
| "tests": { | |
| "passed": ${{ steps.summary.outputs.passed }}, | |
| "failed": ${{ steps.summary.outputs.failed }}, | |
| "skipped": 0, | |
| "duration_seconds": ${{ steps.summary.outputs.duration || 0 }}, | |
| "details": [ | |
| { | |
| "name": "Check nextflow binary", | |
| "status": "${{ steps.test1.outputs.status || 'skipped' }}", | |
| "duration_seconds": ${{ steps.test1.outputs.duration || 0 }} | |
| }, | |
| { | |
| "name": "Check version command", | |
| "status": "${{ steps.test2.outputs.status || 'skipped' }}", | |
| "duration_seconds": ${{ steps.test2.outputs.duration || 0 }} | |
| }, | |
| { | |
| "name": "Check help command", | |
| "status": "${{ steps.test3.outputs.status || 'skipped' }}", | |
| "duration_seconds": ${{ steps.test3.outputs.duration || 0 }} | |
| }, | |
| { | |
| "name": "Run Hello World pipeline", | |
| "status": "${{ steps.test4.outputs.status || 'skipped' }}", | |
| "duration_seconds": ${{ steps.test4.outputs.duration || 0 }} | |
| } | |
| ] | |
| }, | |
| "metadata": { | |
| "dashboard_link": "${{ steps.metadata.outputs.dashboard_link }}", | |
| "badge_status": "${{ steps.summary.outputs.badge_status }}" | |
| } | |
| } | |
| EOF | |
| echo "Generated test results:" | |
| cat test-results/nextflow.json | |
| # ============================================================ | |
| # STANDARD STEPS - Usually don't need to modify below here | |
| # ============================================================ | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nextflow-test-results | |
| path: test-results/nextflow.json | |
| retention-days: 90 | |
| - name: Create test summary | |
| if: always() | |
| run: | | |
| echo "## Nextflow Test Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Status:** ${{ steps.summary.outputs.overall_status }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Tests Passed:** ${{ steps.summary.outputs.passed }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Tests Failed:** ${{ steps.summary.outputs.failed }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Duration:** ${{ steps.summary.outputs.duration || 0 }}s" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Runner:** ubuntu-24.04 (arm64)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Test Details" >> $GITHUB_STEP_SUMMARY | |
| echo "1. Test 1 - Check nextflow binary: ${{ steps.test1.outputs.status || 'skipped' }}" >> $GITHUB_STEP_SUMMARY | |
| echo "2. Test 2 - Check version command: ${{ steps.test2.outputs.status || 'skipped' }}" >> $GITHUB_STEP_SUMMARY | |
| echo "3. Test 3 - Check help command: ${{ steps.test3.outputs.status || 'skipped' }}" >> $GITHUB_STEP_SUMMARY | |
| echo "4. Test 4 - Run Hello World pipeline: ${{ steps.test4.outputs.status || 'skipped' }}" >> $GITHUB_STEP_SUMMARY | |