Skip to content

Commit 4316c75

Browse files
vitess-bot[bot]arthurschreiber
authored andcommitted
[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]>
1 parent c3adbdd commit 4316c75

File tree

95 files changed

+881
-1752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+881
-1752
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: 'Setup MySQL'
2+
description: 'Set up MySQL server for use in GitHub Actions workflows'
3+
inputs:
4+
flavor:
5+
description: 'The flavor of MySQL to use (e.g. mysql-5.7, mysql-8.0, mysql-8.4)'
6+
required: true
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Setup MySQL
11+
shell: bash
12+
run: |
13+
export DEBIAN_FRONTEND="noninteractive"
14+
sudo apt-get update
15+
16+
# Uninstall any previously installed MySQL first
17+
# sudo systemctl stop apparmor
18+
sudo DEBIAN_FRONTEND="noninteractive" apt-get remove -y --purge mysql-server mysql-client mysql-common
19+
sudo apt-get -y autoremove
20+
sudo apt-get -y autoclean
21+
# sudo deluser mysql
22+
sudo rm -rf /var/lib/mysql
23+
sudo rm -rf /etc/mysql
24+
25+
# We have to install this old version of libaio1. See also:
26+
# https://bugs.launchpad.net/ubuntu/+source/libaio/+bug/2067501
27+
wget http://mirrors.kernel.org/ubuntu/pool/main/liba/libaio/libaio1_0.3.112-13build1_amd64.deb && \
28+
sudo dpkg -i libaio1_0.3.112-13build1_amd64.deb && \
29+
rm libaio1_0.3.112-13build1_amd64.deb
30+
31+
# Get key to latest MySQL repo
32+
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A8D3785C
33+
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.35-1_all.deb
34+
35+
if [[ "${{ inputs.flavor }}" == "mysql-5.7" ]]; then
36+
# Bionic packages are still compatible for Jammy since there's no MySQL 5.7
37+
# packages for Jammy.
38+
echo mysql-apt-config mysql-apt-config/repo-codename select bionic | sudo debconf-set-selections
39+
echo mysql-apt-config mysql-apt-config/select-server select mysql-5.7 | sudo debconf-set-selections
40+
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
41+
sudo apt-get update
42+
# libtinfo5 is also needed for older MySQL 5.7 builds.
43+
curl -L -O http://mirrors.kernel.org/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb
44+
sudo dpkg -i libtinfo5_6.3-2ubuntu0.1_amd64.deb
45+
sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7* libncurses6
46+
elif [[ "${{ inputs.flavor }}" == "mysql-8.0" ]]; then
47+
echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | sudo debconf-set-selections
48+
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
49+
sudo apt-get update
50+
sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y mysql-server mysql-client
51+
elif [[ "${{ inputs.flavor }}" == "mysql-8.4" ]]; then
52+
echo mysql-apt-config mysql-apt-config/select-server select mysql-8.4-lts | sudo debconf-set-selections
53+
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
54+
sudo apt-get update
55+
sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y mysql-server mysql-client
56+
else
57+
echo "Unsupported MySQL flavor: ${{ inputs.flavor }}"
58+
exit 1
59+
fi
60+
61+
sudo service mysql stop
62+
sudo bash -c "echo '/usr/sbin/mysqld { }' > /etc/apparmor.d/usr.sbin.mysqld" # https://bugs.launchpad.net/ubuntu/+source/mariadb-10.1/+bug/1806263
63+
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
64+
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld || echo "could not remove mysqld profile"

.github/workflows/cluster_endtoend_12.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,24 @@ jobs:
8585
if: steps.changes.outputs.end_to_end == 'true'
8686
uses: ./.github/actions/tune-os
8787

88+
- name: Setup MySQL
89+
if: steps.changes.outputs.end_to_end == 'true'
90+
uses: ./.github/actions/setup-mysql
91+
with:
92+
flavor: mysql-8.0
93+
8894
- name: Get dependencies
8995
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true'
9096
timeout-minutes: 10
9197
run: |
9298
93-
# Get key to latest MySQL repo
94-
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A8D3785C
95-
# Setup MySQL 8.0
96-
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.35-1_all.deb
97-
echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | sudo debconf-set-selections
98-
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
99-
sudo apt-get -qq update
100-
101-
# We have to install this old version of libaio1 in case we end up testing with MySQL 5.7. See also:
102-
# https://bugs.launchpad.net/ubuntu/+source/libaio/+bug/2067501
103-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/liba/libaio/libaio1_0.3.112-13build1_amd64.deb
104-
sudo dpkg -i libaio1_0.3.112-13build1_amd64.deb
105-
# libtinfo5 is also needed for older MySQL 5.7 builds.
106-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb
107-
sudo dpkg -i libtinfo5_6.3-2ubuntu0.1_amd64.deb
99+
sudo apt-get -qq install -y mysql-shell
108100
109101
# Install everything else we need, and configure
110-
sudo apt-get -qq install -y mysql-server mysql-shell mysql-client make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
102+
sudo apt-get -qq install -y make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
111103
112-
sudo service mysql stop
113104
sudo service etcd stop
114-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
115-
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
105+
116106
go mod download
117107
118108
# install JUnit report formatter

.github/workflows/cluster_endtoend_13.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,24 @@ jobs:
8585
if: steps.changes.outputs.end_to_end == 'true'
8686
uses: ./.github/actions/tune-os
8787

88+
- name: Setup MySQL
89+
if: steps.changes.outputs.end_to_end == 'true'
90+
uses: ./.github/actions/setup-mysql
91+
with:
92+
flavor: mysql-8.0
93+
8894
- name: Get dependencies
8995
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true'
9096
timeout-minutes: 10
9197
run: |
9298
93-
# Get key to latest MySQL repo
94-
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A8D3785C
95-
# Setup MySQL 8.0
96-
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.35-1_all.deb
97-
echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | sudo debconf-set-selections
98-
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
99-
sudo apt-get -qq update
100-
101-
# We have to install this old version of libaio1 in case we end up testing with MySQL 5.7. See also:
102-
# https://bugs.launchpad.net/ubuntu/+source/libaio/+bug/2067501
103-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/liba/libaio/libaio1_0.3.112-13build1_amd64.deb
104-
sudo dpkg -i libaio1_0.3.112-13build1_amd64.deb
105-
# libtinfo5 is also needed for older MySQL 5.7 builds.
106-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb
107-
sudo dpkg -i libtinfo5_6.3-2ubuntu0.1_amd64.deb
99+
sudo apt-get -qq install -y mysql-shell
108100
109101
# Install everything else we need, and configure
110-
sudo apt-get -qq install -y mysql-server mysql-shell mysql-client make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
102+
sudo apt-get -qq install -y make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
111103
112-
sudo service mysql stop
113104
sudo service etcd stop
114-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
115-
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
105+
116106
go mod download
117107
118108
# install JUnit report formatter

.github/workflows/cluster_endtoend_15.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,24 @@ jobs:
8585
if: steps.changes.outputs.end_to_end == 'true'
8686
uses: ./.github/actions/tune-os
8787

88+
- name: Setup MySQL
89+
if: steps.changes.outputs.end_to_end == 'true'
90+
uses: ./.github/actions/setup-mysql
91+
with:
92+
flavor: mysql-8.0
93+
8894
- name: Get dependencies
8995
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true'
9096
timeout-minutes: 10
9197
run: |
9298
93-
# Get key to latest MySQL repo
94-
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A8D3785C
95-
# Setup MySQL 8.0
96-
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.35-1_all.deb
97-
echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | sudo debconf-set-selections
98-
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
99-
sudo apt-get -qq update
100-
101-
# We have to install this old version of libaio1 in case we end up testing with MySQL 5.7. See also:
102-
# https://bugs.launchpad.net/ubuntu/+source/libaio/+bug/2067501
103-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/liba/libaio/libaio1_0.3.112-13build1_amd64.deb
104-
sudo dpkg -i libaio1_0.3.112-13build1_amd64.deb
105-
# libtinfo5 is also needed for older MySQL 5.7 builds.
106-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb
107-
sudo dpkg -i libtinfo5_6.3-2ubuntu0.1_amd64.deb
99+
sudo apt-get -qq install -y mysql-shell
108100
109101
# Install everything else we need, and configure
110-
sudo apt-get -qq install -y mysql-server mysql-shell mysql-client make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
102+
sudo apt-get -qq install -y make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
111103
112-
sudo service mysql stop
113104
sudo service etcd stop
114-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
115-
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
105+
116106
go mod download
117107
118108
# install JUnit report formatter

.github/workflows/cluster_endtoend_18.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,24 @@ jobs:
8585
if: steps.changes.outputs.end_to_end == 'true'
8686
uses: ./.github/actions/tune-os
8787

88+
- name: Setup MySQL
89+
if: steps.changes.outputs.end_to_end == 'true'
90+
uses: ./.github/actions/setup-mysql
91+
with:
92+
flavor: mysql-8.0
93+
8894
- name: Get dependencies
8995
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true'
9096
timeout-minutes: 10
9197
run: |
9298
93-
# Get key to latest MySQL repo
94-
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A8D3785C
95-
# Setup MySQL 8.0
96-
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.35-1_all.deb
97-
echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | sudo debconf-set-selections
98-
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
99-
sudo apt-get -qq update
100-
101-
# We have to install this old version of libaio1 in case we end up testing with MySQL 5.7. See also:
102-
# https://bugs.launchpad.net/ubuntu/+source/libaio/+bug/2067501
103-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/liba/libaio/libaio1_0.3.112-13build1_amd64.deb
104-
sudo dpkg -i libaio1_0.3.112-13build1_amd64.deb
105-
# libtinfo5 is also needed for older MySQL 5.7 builds.
106-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb
107-
sudo dpkg -i libtinfo5_6.3-2ubuntu0.1_amd64.deb
99+
sudo apt-get -qq install -y mysql-shell
108100
109101
# Install everything else we need, and configure
110-
sudo apt-get -qq install -y mysql-server mysql-shell mysql-client make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
102+
sudo apt-get -qq install -y make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
111103
112-
sudo service mysql stop
113104
sudo service etcd stop
114-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
115-
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
105+
116106
go mod download
117107
118108
# install JUnit report formatter

.github/workflows/cluster_endtoend_21.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,24 @@ jobs:
8585
if: steps.changes.outputs.end_to_end == 'true'
8686
uses: ./.github/actions/tune-os
8787

88+
- name: Setup MySQL
89+
if: steps.changes.outputs.end_to_end == 'true'
90+
uses: ./.github/actions/setup-mysql
91+
with:
92+
flavor: mysql-8.0
93+
8894
- name: Get dependencies
8995
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true'
9096
timeout-minutes: 10
9197
run: |
9298
93-
# Get key to latest MySQL repo
94-
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A8D3785C
95-
# Setup MySQL 8.0
96-
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.35-1_all.deb
97-
echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | sudo debconf-set-selections
98-
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
99-
sudo apt-get -qq update
100-
101-
# We have to install this old version of libaio1 in case we end up testing with MySQL 5.7. See also:
102-
# https://bugs.launchpad.net/ubuntu/+source/libaio/+bug/2067501
103-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/liba/libaio/libaio1_0.3.112-13build1_amd64.deb
104-
sudo dpkg -i libaio1_0.3.112-13build1_amd64.deb
105-
# libtinfo5 is also needed for older MySQL 5.7 builds.
106-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb
107-
sudo dpkg -i libtinfo5_6.3-2ubuntu0.1_amd64.deb
99+
sudo apt-get -qq install -y mysql-shell
108100
109101
# Install everything else we need, and configure
110-
sudo apt-get -qq install -y mysql-server mysql-shell mysql-client make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
102+
sudo apt-get -qq install -y make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
111103
112-
sudo service mysql stop
113104
sudo service etcd stop
114-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
115-
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
105+
116106
go mod download
117107
118108
# install JUnit report formatter

.github/workflows/cluster_endtoend_backup_pitr.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,24 @@ jobs:
8585
if: steps.changes.outputs.end_to_end == 'true'
8686
uses: ./.github/actions/tune-os
8787

88+
- name: Setup MySQL
89+
if: steps.changes.outputs.end_to_end == 'true'
90+
uses: ./.github/actions/setup-mysql
91+
with:
92+
flavor: mysql-8.0
93+
8894
- name: Get dependencies
8995
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true'
9096
timeout-minutes: 10
9197
run: |
9298
93-
# Get key to latest MySQL repo
94-
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A8D3785C
95-
# Setup MySQL 8.0
96-
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.35-1_all.deb
97-
echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | sudo debconf-set-selections
98-
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
99-
sudo apt-get -qq update
100-
101-
# We have to install this old version of libaio1 in case we end up testing with MySQL 5.7. See also:
102-
# https://bugs.launchpad.net/ubuntu/+source/libaio/+bug/2067501
103-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/liba/libaio/libaio1_0.3.112-13build1_amd64.deb
104-
sudo dpkg -i libaio1_0.3.112-13build1_amd64.deb
105-
# libtinfo5 is also needed for older MySQL 5.7 builds.
106-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb
107-
sudo dpkg -i libtinfo5_6.3-2ubuntu0.1_amd64.deb
99+
sudo apt-get -qq install -y mysql-shell
108100
109101
# Install everything else we need, and configure
110-
sudo apt-get -qq install -y mysql-server mysql-shell mysql-client make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
102+
sudo apt-get -qq install -y make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
111103
112-
sudo service mysql stop
113104
sudo service etcd stop
114-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
115-
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
105+
116106
go mod download
117107
118108
# install JUnit report formatter

.github/workflows/cluster_endtoend_backup_pitr_mysqlshell.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,24 @@ jobs:
8585
if: steps.changes.outputs.end_to_end == 'true'
8686
uses: ./.github/actions/tune-os
8787

88+
- name: Setup MySQL
89+
if: steps.changes.outputs.end_to_end == 'true'
90+
uses: ./.github/actions/setup-mysql
91+
with:
92+
flavor: mysql-8.0
93+
8894
- name: Get dependencies
8995
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true'
9096
timeout-minutes: 10
9197
run: |
9298
93-
# Get key to latest MySQL repo
94-
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A8D3785C
95-
# Setup MySQL 8.0
96-
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.35-1_all.deb
97-
echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | sudo debconf-set-selections
98-
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
99-
sudo apt-get -qq update
100-
101-
# We have to install this old version of libaio1 in case we end up testing with MySQL 5.7. See also:
102-
# https://bugs.launchpad.net/ubuntu/+source/libaio/+bug/2067501
103-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/liba/libaio/libaio1_0.3.112-13build1_amd64.deb
104-
sudo dpkg -i libaio1_0.3.112-13build1_amd64.deb
105-
# libtinfo5 is also needed for older MySQL 5.7 builds.
106-
curl -L -O http://mirrors.kernel.org/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb
107-
sudo dpkg -i libtinfo5_6.3-2ubuntu0.1_amd64.deb
99+
sudo apt-get -qq install -y mysql-shell
108100
109101
# Install everything else we need, and configure
110-
sudo apt-get -qq install -y mysql-server mysql-shell mysql-client make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
102+
sudo apt-get -qq install -y make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6
111103
112-
sudo service mysql stop
113104
sudo service etcd stop
114-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
115-
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
105+
116106
go mod download
117107
118108
# install JUnit report formatter

0 commit comments

Comments
 (0)