Remove MySQL tests 5 and 6 (connection and database tests) #5
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
| # MySQL Test Workflow | |
| # Tests MySQL on ARM64 architecture | |
| # MySQL is an open-source relational database management system | |
| name: Test MySQL on Arm64 | |
| on: | |
| workflow_dispatch: | |
| workflow_call: | |
| push: | |
| branches: | |
| - main | |
| - smoke_tests | |
| paths: | |
| - 'content/opensource_packages/mysql.md' | |
| - '.github/workflows/test-mysql.yml' | |
| jobs: | |
| test-mysql: | |
| 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=mysql" >> $GITHUB_OUTPUT | |
| echo "dashboard_link=/opensource_packages/mysql" >> $GITHUB_OUTPUT | |
| # ============================================================ | |
| # Install MySQL | |
| # ============================================================ | |
| - name: Install MySQL | |
| id: install | |
| run: | | |
| echo "Installing MySQL Server..." | |
| # Update package list | |
| sudo apt-get update | |
| # Install MySQL Server (will use default Ubuntu repository) | |
| sudo DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server mysql-client | |
| # Verify installation | |
| if command -v mysql &> /dev/null && command -v mysqld &> /dev/null; then | |
| echo "MySQL installed successfully" | |
| echo "install_status=success" >> $GITHUB_OUTPUT | |
| else | |
| echo "MySQL installation failed" | |
| echo "install_status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| # ============================================================ | |
| # Get MySQL version | |
| # ============================================================ | |
| - name: Get MySQL version | |
| id: version | |
| run: | | |
| VERSION=$(mysql --version | grep -oP 'mysql\s+Ver\s+\K[0-9.]+' | head -1 || echo "unknown") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Detected MySQL version: $VERSION" | |
| # ============================================================ | |
| # MySQL Tests | |
| # ============================================================ | |
| - name: Test 1 - Check mysql client binary exists | |
| id: test1 | |
| run: | | |
| START_TIME=$(date +%s) | |
| if command -v mysql &> /dev/null; then | |
| echo "✓ mysql client binary found" | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ mysql client 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 mysqld server binary exists | |
| id: test2 | |
| run: | | |
| START_TIME=$(date +%s) | |
| if command -v mysqld &> /dev/null; then | |
| echo "✓ mysqld server binary found" | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ mysqld server 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 3 - Check MySQL version command | |
| id: test3 | |
| run: | | |
| START_TIME=$(date +%s) | |
| if mysql --version | grep -q "mysql"; then | |
| echo "✓ MySQL version command works" | |
| mysql --version | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ MySQL 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 4 - Start MySQL server | |
| id: test4 | |
| run: | | |
| START_TIME=$(date +%s) | |
| # Start MySQL service | |
| sudo systemctl start mysql | |
| # Wait for MySQL to be ready (with retries) | |
| echo "Waiting for MySQL to be ready..." | |
| MAX_RETRIES=30 | |
| RETRY_COUNT=0 | |
| while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do | |
| if sudo mysqladmin ping -u root --silent 2>/dev/null; then | |
| echo "✓ MySQL server is ready" | |
| break | |
| fi | |
| RETRY_COUNT=$((RETRY_COUNT + 1)) | |
| echo "Waiting for MySQL... ($RETRY_COUNT/$MAX_RETRIES)" | |
| sleep 1 | |
| done | |
| # Final check | |
| if sudo systemctl is-active mysql && sudo mysqladmin ping -u root --silent 2>/dev/null; then | |
| echo "✓ MySQL server started successfully and is accepting connections" | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ MySQL server failed to start or is not accepting connections" | |
| sudo systemctl status mysql || true | |
| echo "MySQL error log:" | |
| sudo tail -20 /var/log/mysql/error.log 2>/dev/null || echo "Could not read MySQL error log" | |
| echo "status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| END_TIME=$(date +%s) | |
| echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT | |
| # ============================================================ | |
| # Calculate summary | |
| # ============================================================ | |
| - 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 }})) | |
| 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 | |
| fi | |
| # ============================================================ | |
| # Generate JSON with MySQL metadata | |
| # ============================================================ | |
| - name: Generate test results JSON | |
| if: always() | |
| run: | | |
| mkdir -p test-results | |
| cat > test-results/mysql.json << EOF | |
| { | |
| "schema_version": "1.0", | |
| "package": { | |
| "name": "MySQL", | |
| "version": "${{ steps.version.outputs.version }}", | |
| "language": "c++", | |
| "category": "Database" | |
| }, | |
| "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 mysql client binary exists", | |
| "status": "${{ steps.test1.outputs.status }}", | |
| "duration_seconds": ${{ steps.test1.outputs.duration || 0 }} | |
| }, | |
| { | |
| "name": "Check mysqld server binary exists", | |
| "status": "${{ steps.test2.outputs.status }}", | |
| "duration_seconds": ${{ steps.test2.outputs.duration || 0 }} | |
| }, | |
| { | |
| "name": "Check MySQL version command", | |
| "status": "${{ steps.test3.outputs.status }}", | |
| "duration_seconds": ${{ steps.test3.outputs.duration || 0 }} | |
| }, | |
| { | |
| "name": "Start MySQL server", | |
| "status": "${{ steps.test4.outputs.status }}", | |
| "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/mysql.json | |
| # ============================================================ | |
| # STANDARD STEPS - Commit results to repository | |
| # ============================================================ | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mysql-test-results | |
| path: test-results/mysql.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/mysql.json data/test-results/mysql.json | |
| git add data/test-results/mysql.json | |
| if ! git diff --staged --quiet; then | |
| git commit -m "Update mysql 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/mysql.json | |
| git add data/test-results/mysql.json | |
| # Continue the rebase | |
| git rebase --continue || true | |
| fi | |
| # Wait before retry | |
| sleep $((i * 2)) | |
| done | |
| else | |
| echo "No changes to commit" | |
| fi |