All workflows test #6
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
| # Package Test Template | |
| # | |
| # This is a TEMPLATE file stored in the tests/ directory - it will not run as a workflow. | |
| # To use it: | |
| # 1. Copy this file to .github/workflows/test-<your-package>.yml | |
| # 2. Replace all EMAN2 placeholders with your package name (e.g., "Redis") | |
| # 3. Replace all eman2 placeholders with your package slug (lowercase, e.g., "redis") | |
| # 4. Update the install commands for your package | |
| # 5. Update the version detection command | |
| # 6. Add/modify/remove test steps as needed | |
| # 7. Update package metadata in the JSON generation step | |
| # 8. Uncomment the appropriate trigger(s) in the 'on:' section | |
| # | |
| # See .github/workflows/test-nginx.yml and test-envoy.yml for real examples. Template | |
| # | |
| # This is a TEMPLATE file - it will not run automatically. | |
| # To use it: | |
| # 1. Copy this file to test-<your-package>.yml | |
| # 2. Replace all EMAN2 placeholders with your package name (e.g., "Redis") | |
| # 3. Replace all eman2 placeholders with your package slug (lowercase, e.g., "redis") | |
| # 4. Update the install commands for your package | |
| # 5. Update the version detection command | |
| # 6. Add/modify/remove test steps as needed | |
| # 7. Update package metadata in the JSON generation step | |
| # 8. Uncomment the 'push:' trigger section below (remove the workflow_dispatch if desired) | |
| # | |
| # See test-nginx.yml and test-envoy.yml for real examples. | |
| name: Test EMAN2 on Arm64 | |
| # This is a TEMPLATE - it has no triggers and will not run. | |
| # When you copy this file, uncomment the appropriate triggers below: | |
| on: | |
| # workflow_dispatch: # Uncomment for manual testing | |
| workflow_call: | |
| push: | |
| branches: | |
| - main | |
| - smoke_tests | |
| paths: | |
| - 'content/opensource_packages/eman2.md' | |
| - '.github/workflows/test-eman2.yml' | |
| jobs: | |
| test-eman2: | |
| 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=eman2 >> $GITHUB_OUTPUT | |
| echo "dashboard_link=/opensource_packages/eman2 >> $GITHUB_OUTPUT | |
| # ============================================================ | |
| # CUSTOMIZE THIS: Install your package | |
| # ============================================================ | |
| - name: Install EMAN2 | |
| id: install | |
| run: | | |
| echo "Installing EMAN2..." | |
| # Example for apt packages: | |
| sudo apt-get update | |
| sudo apt-get install -y eman2 | |
| # Example for downloading binaries: | |
| # sudo curl -L -o /usr/local/bin/eman2 https://github.com/org/repo/releases/download/v1.0.0/eman2-linux-arm64 | |
| # sudo chmod +x /usr/local/bin/eman2 | |
| # Verify installation | |
| if command -v eman2 &> /dev/null; then | |
| echo "EMAN2 installed successfully" | |
| echo "install_status=success" >> $GITHUB_OUTPUT | |
| else | |
| echo "EMAN2 installation failed" | |
| echo "install_status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| # ============================================================ | |
| # CUSTOMIZE THIS: Get the package version | |
| # ============================================================ | |
| - name: Get EMAN2 version | |
| id: version | |
| run: | | |
| # Adjust this command based on how your package reports version | |
| VERSION=$(eman2 --version 2>&1 | grep -oP '[0-9.]+' | head -1 || echo "unknown") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Detected EMAN2 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 eman2 binary exists | |
| id: test1 | |
| continue-on-error: true | |
| run: | | |
| START_TIME=$(date +%s) | |
| if command -v eman2 &> /dev/null; then | |
| echo "✓ eman2 binary found" | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ eman2 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 eman2 version command | |
| id: test2 | |
| continue-on-error: true | |
| run: | | |
| START_TIME=$(date +%s) | |
| if eman2 --version 2>&1 | grep -q "version\|[0-9]"; then | |
| echo "✓ eman2 version command works" | |
| eman2 --version | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ eman2 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 eman2 help output | |
| id: test3 | |
| continue-on-error: true | |
| run: | | |
| START_TIME=$(date +%s) | |
| if eman2 --help 2>&1 | grep -qi "usage\|help\|options"; then | |
| echo "✓ eman2 help command works" | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ eman2 help command failed" | |
| echo "status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| END_TIME=$(date +%s) | |
| echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT | |
| # Add more tests as needed (test4, test5, etc.) | |
| # Examples: | |
| # - Run a simple command | |
| # - Check configuration files | |
| # - Start/stop a service | |
| # - Test basic functionality | |
| # ============================================================ | |
| # UPDATE THIS: Calculate summary based on your number of tests | |
| # Add/remove test result checks to match your tests above | |
| # ============================================================ | |
| - 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 - Functional Validation | |
| id: test5 | |
| continue-on-error: true | |
| run: | | |
| START_TIME=$(date +%s) | |
| # Basic functional check: try to run with --version or --help and check exit code | |
| if eman2 --version > /dev/null 2>&1 || eman2 --help > /dev/null 2>&1; then | |
| echo "✓ Basic functional check passed" | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ Basic functional check failed" | |
| echo "status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| END_TIME=$(date +%s) | |
| echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT | |
| - name: Calculate test summary | |
| if: always() | |
| id: summary | |
| run: | | |
| PASSED=0 | |
| FAILED=0 | |
| TOTAL_DURATION=0 | |
| # Test 1 | |
| if [ "${{ steps.test1.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| else | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test1.outputs.duration || 0 }})) | |
| # Test 2 | |
| if [ "${{ steps.test2.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| else | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test2.outputs.duration || 0 }})) | |
| # Test 3 | |
| if [ "${{ steps.test3.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| else | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test3.outputs.duration || 0 }})) | |
| # Test 4 | |
| if [ "${{ steps.test4.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| else | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test4.outputs.duration || 0 }})) | |
| # Test 5 | |
| if [ "${{ steps.test5.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| else | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test5.outputs.duration || 0 }})) | |
| # Add more tests here if you added test4, test5, etc. above | |
| echo "passed=$PASSED" >> $GITHUB_OUTPUT | |
| echo "failed=$FAILED" >> $GITHUB_OUTPUT | |
| echo "duration=$TOTAL_DURATION" >> $GITHUB_OUTPUT | |
| if [ $FAILED -eq 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 | |
| exit 1 | |
| fi | |
| # ============================================================ | |
| # UPDATE THIS: Generate JSON with your package metadata and test details | |
| # ============================================================ | |
| - name: Generate test results JSON | |
| if: always() | |
| run: | | |
| mkdir -p test-results | |
| cat > test-results/eman2.json << EOF | |
| { | |
| "schema_version": "1.0", | |
| "package": { | |
| "name": "EMAN2", | |
| "version": "${{ steps.version.outputs.version }}", | |
| "language": "Miscellaneous", | |
| "category": "Miscellaneous" | |
| }, | |
| "run": { | |
| "id": "${{ github.run_id }}", | |
| "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", | |
| "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 }}, | |
| "details": [ | |
| { | |
| "name": "Check eman2 binary exists", | |
| "status": "${{ steps.test1.outputs.status }}", | |
| "duration_seconds": ${{ steps.test1.outputs.duration || 0 }} | |
| }, | |
| { | |
| "name": "Check eman2 version command", | |
| "status": "${{ steps.test2.outputs.status }}", | |
| "duration_seconds": ${{ steps.test2.outputs.duration || 0 }} | |
| }, | |
| { | |
| "name": "Check eman2 help output", | |
| "status": "${{ steps.test3.outputs.status }}", | |
| "duration_seconds": ${{ steps.test3.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/eman2.json | |
| # ============================================================ | |
| # STANDARD STEPS - Usually don't need to modify below here | |
| # ============================================================ | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: eman2-test-results | |
| path: test-results/eman2.json | |
| retention-days: 90 | |
| - name: Commit test results to repository | |
| if: always() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/smoke_tests') | |
| run: | | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| mkdir -p data/test-results | |
| cp test-results/eman2.json data/test-results/eman2.json | |
| git add data/test-results/eman2.json | |
| if ! git diff --staged --quiet; then | |
| git commit -m "Update eman2 test results [skip ci]" | |
| # Pull with rebase and push, retry up to 5 times | |
| for i in {1..5}; do | |
| if git pull --rebase origin ${{ github.ref_name }}; then | |
| # Rebase succeeded, try to push | |
| if git push; then | |
| echo "Successfully pushed test results" | |
| break | |
| fi | |
| else | |
| # Rebase failed, likely due to conflict | |
| echo "Rebase failed, resolving conflicts..." | |
| # Accept our version of the file (the new test results) | |
| git checkout --ours data/test-results/eman2.json | |
| git add data/test-results/eman2.json | |
| # Continue the rebase | |
| git rebase --continue || true | |
| fi | |
| # Wait before retry | |
| echo "Retry attempt $i of 5..." | |
| sleep $((i * 2)) | |
| done | |
| else | |
| echo "No changes to commit" | |
| fi | |
| - name: Create test summary | |
| if: always() | |
| run: | | |
| echo "## EMAN2 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 }}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. Check eman2 binary exists: ${{ steps.test1.outputs.status }}" >> $GITHUB_STEP_SUMMARY | |
| echo "2. Check eman2 version command: ${{ steps.test2.outputs.status }}" >> $GITHUB_STEP_SUMMARY | |
| echo "3. Check eman2 help output: ${{ steps.test3.outputs.status }}" >> $GITHUB_STEP_SUMMARY | |
| echo "4. Test 4 - Architecture Verification: ${{ steps.test4.outputs.status }}" >> $GITHUB_STEP_SUMMARY | |
| echo "5. Test 5 - Functional Validation: ${{ steps.test5.outputs.status }}" >> $GITHUB_STEP_SUMMARY | |