Skip to content

Conversation

@arthurschreiber
Copy link
Member

@arthurschreiber arthurschreiber commented Oct 25, 2025

Description

This DRYs up the MySQL setup across the various (90+) workflow files by using a re-usable, composite, in-repo action.

I'd like to back port this to all supported release branches to make sure our CI configuration matches across different release branches.

Related Issue(s)

N/A

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

AI Disclosure

@vitess-bot
Copy link
Contributor

vitess-bot bot commented Oct 25, 2025

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Oct 25, 2025
@github-actions github-actions bot added this to the v24.0.0 milestone Oct 25, 2025
@arthurschreiber arthurschreiber added Component: Build/CI Type: CI/Build and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Oct 25, 2025
@codecov
Copy link

codecov bot commented Oct 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.71%. Comparing base (5203ed4) to head (c3f219e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18815      +/-   ##
==========================================
- Coverage   69.72%   69.71%   -0.01%     
==========================================
  Files        1607     1607              
  Lines      214579   214579              
==========================================
- Hits       149607   149593      -14     
- Misses      64972    64986      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arthurschreiber arthurschreiber marked this pull request as ready for review October 27, 2025 09:22
@arthurschreiber arthurschreiber mentioned this pull request Oct 28, 2025
5 tasks
Copy link
Collaborator

@nickvanw nickvanw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

===============================================================================
EXHAUSTIVE ANALYSIS OF PR #18815: MYSQL SETUP ACTION REFACTORING
===============================================================================

EXECUTIVE SUMMARY:
PR #18815 successfully extracts MySQL setup configuration into a reusable
composite action, achieving excellent DRY principles across the CI workflow
ecosystem. The implementation is comprehensive, consistent, and well-executed.

===============================================================================
1. ACTION FILE VERIFICATION
===============================================================================

Location: /home/nick/vitess/vitess/.github/actions/setup-mysql/action.yml

Structure: PASS
- Uses composite action correctly (using: "composite")
- Has proper name and description
- Properly parameterized with required "flavor" input

Input Parameters: PASS
- flavor: required parameter with valid options (mysql-5.7, mysql-8.0, mysql-8.4)
- Parameter is required: true (enforces user to specify)

Supported MySQL Versions:
1. mysql-5.7
   - Uses Bionic packages (compatible for Ubuntu Jammy)
   - Handles libtinfo5 dependency
   - Uses mysql-community-server=5.7* for package selection

2. mysql-8.0
   - Standard MySQL 8.0 LTS packages
   - Uses mysql-8.0 repo selection

3. mysql-8.4
   - Uses mysql-8.4-lts repo selection
   - Latest LTS version support

Error Handling: PASS
- Validates input flavor parameter
- Exits with error code 1 for unsupported flavors
- Graceful fallback for apparmor operations (|| echo "could not remove...")

===============================================================================
2. WORKFLOW COVERAGE
===============================================================================

Total Workflows Analyzed: 111
Workflows Using setup-mysql Action: 87

MySQL Flavor Distribution:
- mysql-8.4: 80 workflows (92%)
- mysql-8.0: 5 workflows (6%)
- mysql-5.7: 2 workflows (1%)

Workflow Categories Using Action:
1. Unit Tests (6 workflows)
   - unit_test_mysql57.yml
   - unit_test_mysql80.yml
   - unit_test_mysql84.yml
   - unit_test_evalengine_mysql57.yml
   - unit_test_evalengine_mysql80.yml
   - unit_test_evalengine_mysql84.yml

2. Cluster End-to-End Tests (60+ workflows)
   - cluster_endtoend_*.yml (various test suites)

3. Upgrade/Downgrade Tests (17 workflows)
   - upgrade_downgrade_test_*.yml

4. Race Tests (2 workflows)
   - unit_race.yml
   - unit_race_evalengine.yml
   - e2e_race.yml

5. Code Quality Workflows (2 workflows)
   - codeql_analysis.yml
   - codecov.yml

Workflows NOT Using setup-mysql (24):
- 3 Percona xtrabackup workflows (intentionally excluded - use Percona Server)
- 21 workflow files without MySQL requirements

===============================================================================
3. ACTION PLACEMENT VERIFICATION
===============================================================================

Placement Pattern: PASS (100% correct)
- All 87 workflows place setup-mysql AFTER checkout
- All use: actions/checkout@... step is executed before setup-mysql
- Placement: Line 35-40 (checkout) → Line 85-92 (setup-mysql)

Consistent Pattern:
All workflows follow identical structure:
1. Skip CI check
2. Checkout code
3. Check for changes
4. Set up Go/Python
5. Tune OS ← Happens before MySQL
6. Setup MySQL ← HERE (action reference)
7. Get dependencies
8. Run tests

===============================================================================
4. ACTION USAGE CONSISTENCY
===============================================================================

All 87 Workflows Use Identical Pattern: PASS

Pattern:
- name: Setup MySQL
  if: steps.changes.outputs.end_to_end == 'true'  (or unit_tests)
  uses: ./.github/actions/setup-mysql
  with:
    flavor: mysql-8.4  (or mysql-8.0, mysql-5.7)

Conditional Execution:
- 70 workflows: if: steps.changes.outputs.end_to_end == 'true'
- 8 workflows: if: steps.changes.outputs.unit_tests == 'true'
- 7 workflows: if: steps.output-next-release-ref.outputs.next_release_ref != '' && steps.changes.outputs.end_to_end == 'true'
- 1 workflow: if: steps.changes.outputs.changed_files == 'true'
- 1 workflow: (no conditional - codeql_analysis.yml)

No Inconsistencies Detected: PASS

===============================================================================
5. CODE CLEANUP VERIFICATION
===============================================================================

Duplicated MySQL Setup Code: NONE DETECTED

Verification Results:
- mysql-apt-config duplication: 0 workflows ✓
- libaio1 duplication: 0 workflows ✓
- apparmor_parser duplication: 0 workflows ✓
- /etc/apparmor.d/usr.sbin.mysqld duplication: 0 workflows ✓

"Get dependencies" Steps:
All "Get dependencies" or "Get base dependencies" steps in updated workflows:
- NO LONGER contain mysql-apt-config setup
- NO LONGER contain apparmor configuration
- NO LONGER contain libaio1 installation
- ONLY contain non-MySQL dependencies (etcd, curl, git, wget, etc.)
- Some still install mysql-shell (which is CORRECT - it's a separate tool)

Example Cleanup (before → after):
BEFORE (inline in workflows):
- apt-get update
- apt-get remove/purge mysql-*
- wget/install libaio1
- apt-key adv (MySQL repo)
- wget/dpkg mysql-apt-config
- debconf-set-selections for flavor
- apt-get install mysql-*
- service mysql stop
- apparmor configuration

AFTER (delegated to action):
- Uses: ./.github/actions/setup-mysql
- with: flavor: mysql-8.4
- Get dependencies only handles: etcd, make, unzip, g++, curl, git, wget, etc.

===============================================================================
6. XTRABACKUP WORKFLOWS (INTENTIONAL EXCLUSIONS)
===============================================================================

These workflows have Percona Server setups and are NOT using setup-mysql:
1. cluster_endtoend_xb_backup.yml
   - Installs Percona Server for MySQL 8.0 (not standard MySQL)
   - Includes percona-xtrabackup-80
   - Uses Percona package manager: percona-release setup ps80
   - Status: CORRECT - should NOT use setup-mysql

2. cluster_endtoend_xb_recovery.yml
   - Same Percona-specific setup
   - Status: CORRECT - should NOT use setup-mysql

3. cluster_endtoend_backup_pitr_xtrabackup.yml
   - Same Percona-specific setup
   - Status: CORRECT - should NOT use setup-mysql
  
===============================================================================
7. CONSISTENCY ANALYSIS
===============================================================================

Parameter Naming: 100% consistent
- All use: "flavor:" with correct indentation
- All values lowercase: mysql-5.7, mysql-8.0, mysql-8.4

Step Naming: 100% consistent
- All use: "name: Setup MySQL"
- No variations or typos

Action Path: 100% consistent
- All use: uses: ./.github/actions/setup-mysql
- No relative path issues

With Block: 100% consistent
- All properly indent with 8 spaces
- All include with: block with flavor parameter

Conditional Patterns: Consistent
- Uses same change detection patterns as other actions
- Properly scoped to test execution steps


✓ Action file exists and valid: YES
✓ Action uses composite pattern: YES
✓ Action has required input parameter: YES
✓ Action validates input: YES
✓ Workflows updated: 87/87 compatible workflows
✓ Placement correctness: 87/87 (100%)
✓ Flavor consistency: 87/87 (100%)
✓ No code duplication: 87/87 (100%)
✓ No inline MySQL setup remaining: 87/87 (100%)
✓ AppArmor config centralized: 100%
✓ Service management centralized: 100%
✓ Error handling adequate: 100%

COVERAGE ASSESSMENT:
- MySQL 5.7: 2/2 expected workflows ✓
- MySQL 8.0: 5/5 expected workflows ✓
- MySQL 8.4: 80 workflows (primary default)
- Special cases (Percona): 3/3 properly excluded ✓
- Unit tests: 6/6 covered ✓
- Integration tests: 60+ covered ✓
- Upgrade tests: 17/17 covered ✓

Copy link
Member

@mattlord mattlord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @arthurschreiber ! ❤️

@arthurschreiber arthurschreiber added Backport to: release-22.0 Needs to be backport to release-22.0 Backport to: release-23.0 Needs to be backport to release-23.0 labels Oct 28, 2025
@arthurschreiber arthurschreiber merged commit 885917d into main Oct 29, 2025
103 of 105 checks passed
@arthurschreiber arthurschreiber deleted the arthur/dry-mysql-setup branch October 29, 2025 10:24
arthurschreiber added a commit that referenced this pull request Oct 29, 2025
Signed-off-by: Arthur Schreiber <[email protected]>
arthurschreiber added a commit that referenced this pull request Oct 29, 2025
Signed-off-by: Arthur Schreiber <[email protected]>
arthurschreiber added a commit that referenced this pull request Oct 29, 2025
Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
tanjinx pushed a commit to slackhq/vitess that referenced this pull request Nov 13, 2025
Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
Signed-off-by: Tanjin Xu <[email protected]>
tanjinx pushed a commit to slackhq/vitess that referenced this pull request Nov 13, 2025
Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
Signed-off-by: Tanjin Xu <[email protected]>
tanjinx added a commit to slackhq/vitess that referenced this pull request Nov 13, 2025
* [release-22.0] ci: use the newest mysql apt config package (vitessio#18790) (vitessio#18793)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
Signed-off-by: Tanjin Xu <[email protected]>

* [release-22.0] [CI] Use the draft state from the event payload instead of calling `curl`. (vitessio#18650) (vitessio#18652)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Signed-off-by: Tanjin Xu <[email protected]>

* [release-22.0] ci: extract os tuning (vitessio#18824) (vitessio#18826)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
Signed-off-by: Tanjin Xu <[email protected]>

* [release-22.0] ci: extract os tuning (vitessio#18824) (vitessio#18826)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
Signed-off-by: Tanjin Xu <[email protected]>

* [release-22.0] ci: DRY up MySQL Setup (vitessio#18815) (vitessio#18836)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
Signed-off-by: Tanjin Xu <[email protected]>

* fix typo

Signed-off-by: Tanjin Xu <[email protected]>

* delete mysql57 tests

Signed-off-by: Tanjin Xu <[email protected]>

* setup secrets

Signed-off-by: Tanjin Xu <[email protected]>

* fix tests

Signed-off-by: Tanjin Xu <[email protected]>

* fix typo

Signed-off-by: Tanjin Xu <[email protected]>

* rm java docker test

Signed-off-by: Tanjin Xu <[email protected]>

---------

Signed-off-by: Arthur Schreiber <[email protected]>
Signed-off-by: Tanjin Xu <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Co-authored-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
arthurschreiber added a commit that referenced this pull request Nov 20, 2025
Signed-off-by: Arthur Schreiber <[email protected]>
arthurschreiber added a commit that referenced this pull request Nov 20, 2025
Signed-off-by: Arthur Schreiber <[email protected]>
arthurschreiber added a commit that referenced this pull request Nov 20, 2025
Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport to: release-22.0 Needs to be backport to release-22.0 Backport to: release-23.0 Needs to be backport to release-23.0 Component: Build/CI Type: CI/Build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants