зеркало из https://github.com/github/vitess-gh.git
138 строки
5.5 KiB
Smarty
138 строки
5.5 KiB
Smarty
name: {{.Name}}
|
|
on: [push, pull_request]
|
|
concurrency:
|
|
group: format('{0}-{1}', ${{"{{"}} github.ref {{"}}"}}, '{{.Name}}')
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
- name: Check if workflow needs to be skipped
|
|
id: skip-workflow
|
|
run: |
|
|
skip='false'
|
|
if [[ "{{"${{github.event.pull_request}}"}}" == "" ]] && [[ "{{"${{github.ref}}"}}" != "refs/heads/main" ]] && [[ ! "{{"${{github.ref}}"}}" =~ ^refs/heads/release-[0-9]+\.[0-9]$ ]] && [[ ! "{{"${{github.ref}}"}}" =~ "refs/tags/.*" ]]; then
|
|
skip='true'
|
|
fi
|
|
echo Skip ${skip}
|
|
echo "skip-workflow=${skip}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Check out code
|
|
if: steps.skip-workflow.outputs.skip-workflow == 'false'
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Check for changes in relevant files
|
|
if: steps.skip-workflow.outputs.skip-workflow == 'false'
|
|
uses: frouioui/paths-filter@main
|
|
id: changes
|
|
with:
|
|
token: ''
|
|
filters: |
|
|
unit_tests:
|
|
- 'go/**'
|
|
- 'test.go'
|
|
- 'Makefile'
|
|
- 'build.env'
|
|
- 'go.sum'
|
|
- 'go.mod'
|
|
- 'proto/*.proto'
|
|
- 'tools/**'
|
|
- 'config/**'
|
|
- 'bootstrap.sh'
|
|
- '.github/workflows/{{.FileName}}'
|
|
|
|
- name: Set up Go
|
|
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true'
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: 1.18.9
|
|
|
|
- name: Tune the OS
|
|
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true'
|
|
run: |
|
|
echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
|
|
# Increase the asynchronous non-blocking I/O. More information at https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_use_native_aio
|
|
echo "fs.aio-max-nr = 1048576" | sudo tee -a /etc/sysctl.conf
|
|
sudo sysctl -p /etc/sysctl.conf
|
|
|
|
- name: Get dependencies
|
|
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true'
|
|
run: |
|
|
export DEBIAN_FRONTEND="noninteractive"
|
|
sudo apt-get update
|
|
|
|
# Uninstall any previously installed MySQL first
|
|
sudo systemctl stop apparmor
|
|
sudo DEBIAN_FRONTEND="noninteractive" apt-get remove -y --purge mysql-server mysql-client mysql-common
|
|
sudo apt-get -y autoremove
|
|
sudo apt-get -y autoclean
|
|
sudo deluser mysql
|
|
sudo rm -rf /var/lib/mysql
|
|
sudo rm -rf /etc/mysql
|
|
|
|
{{if (eq .Platform "mysql57")}}
|
|
# Get key to latest MySQL repo
|
|
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29
|
|
|
|
# mysql57
|
|
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.14-1_all.deb
|
|
# Bionic packages are still compatible for Focal since there's no MySQL 5.7
|
|
# packages for Focal.
|
|
echo mysql-apt-config mysql-apt-config/repo-codename select bionic | sudo debconf-set-selections
|
|
echo mysql-apt-config mysql-apt-config/select-server select mysql-5.7 | sudo debconf-set-selections
|
|
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
|
|
sudo apt-get update
|
|
sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7*
|
|
|
|
{{end}}
|
|
|
|
{{if (eq .Platform "mysql80")}}
|
|
# Get key to latest MySQL repo
|
|
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29
|
|
|
|
# mysql80
|
|
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.20-1_all.deb
|
|
echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | sudo debconf-set-selections
|
|
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
|
|
sudo apt-get update
|
|
sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y mysql-server mysql-client
|
|
|
|
{{end}}
|
|
|
|
{{if (eq .Platform "mariadb103")}}
|
|
|
|
# mariadb103
|
|
sudo apt-get install -y software-properties-common
|
|
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
|
|
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirror.rackspace.com/mariadb/repo/10.3/ubuntu bionic main'
|
|
sudo apt update
|
|
sudo DEBIAN_FRONTEND="noninteractive" apt install -y mariadb-server
|
|
|
|
{{end}}
|
|
|
|
sudo apt-get install -y make unzip g++ curl git wget ant openjdk-11-jdk eatmydata
|
|
sudo service mysql stop
|
|
sudo bash -c "echo '/usr/sbin/mysqld { }' > /etc/apparmor.d/usr.sbin.mysqld" # https://bugs.launchpad.net/ubuntu/+source/mariadb-10.1/+bug/1806263
|
|
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
|
|
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld || echo "could not remove mysqld profile"
|
|
|
|
mkdir -p dist bin
|
|
curl -L https://github.com/coreos/etcd/releases/download/v3.3.10/etcd-v3.3.10-linux-amd64.tar.gz | tar -zxC dist
|
|
mv dist/etcd-v3.3.10-linux-amd64/{etcd,etcdctl} bin/
|
|
|
|
go mod download
|
|
go install golang.org/x/tools/cmd/goimports@latest
|
|
|
|
- name: Run make tools
|
|
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true'
|
|
run: |
|
|
make tools
|
|
|
|
- name: Run test
|
|
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true'
|
|
timeout-minutes: 30
|
|
run: |
|
|
eatmydata -- make unit_test
|