Skip to content

Commit d4bb730

Browse files
authored
GitHub Actions: Add CentOS/Fedora cases. (#1168)
* Migrate CentOS case in Travis to GitHub Actions. * Add Fedora cases as allow failure.
1 parent 0ee2053 commit d4bb730

9 files changed

+89
-31
lines changed

.dockerignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.bundle
2+
Gemfile.lock
3+
spec/configuration.yml
4+
spec/my.cnf
5+
tmp
6+
vendor

.github/workflows/container.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Test Linux distributions which do not exist on GitHub Actions
2+
# by the containers.
3+
name: Container
4+
on: [push, pull_request]
5+
jobs:
6+
build:
7+
name: >-
8+
${{ matrix.distro }} ${{ matrix.image }}
9+
runs-on: ubuntu-20.04 # focal
10+
continue-on-error: ${{ matrix.allow-failure }}
11+
strategy:
12+
matrix:
13+
include:
14+
- {distro: centos, image: 'centos:7', allow-failure: false}
15+
# Fedora latest stable version
16+
# Allow failure due to the following test failures.
17+
# https://github.com/brianmario/mysql2/issues/965
18+
- {distro: fedora, image: 'fedora:latest', allow-failure: true}
19+
# Fedora development version
20+
# Allow failure due to the following test failures.
21+
# https://github.com/brianmario/mysql2/issues/1152
22+
- {distro: fedora, image: 'fedora:rawhide', allow-failure: true}
23+
# On the fail-fast: true, it cancels all in-progress jobs
24+
# if any matrix job fails unlike Travis fast_finish.
25+
fail-fast: false
26+
steps:
27+
- uses: actions/checkout@v2
28+
- run: docker build -t mysql2 -f .travis_Dockerfile_${{ matrix.distro }} --build-arg IMAGE=${{ matrix.image }} .
29+
# Add the "--cap-add=... --security-opt seccomp=..." options
30+
# as a temporary workaround to avoid the following issue
31+
# in the Fedora >= 34 containers.
32+
# https://bugzilla.redhat.com/show_bug.cgi?id=1900021
33+
- run: docker run --add-host=mysql2gem.example.com:127.0.0.1 -t --cap-add=SYS_PTRACE --security-opt seccomp=unconfined mysql2

.github/workflows/test.yml .github/workflows/ubuntu.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test
1+
name: Ubuntu
22
on: [push, pull_request]
33
jobs:
44
build:

.travis.yml

-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
sudo: required
22
dist: trusty
3-
services: docker
43
language: ruby
54
bundler_args: --without benchmarks development
65
# Pin Rubygems to a working version. Sometimes it breaks upstream. Update now and then.
@@ -56,11 +55,6 @@ matrix:
5655
addons:
5756
hosts:
5857
- mysql2gem.example.com
59-
- rvm: 2.4
60-
env: DOCKER=centos
61-
before_install: true
62-
install: docker build -t mysql2 -f .travis_Dockerfile_centos .
63-
script: docker run --add-host=mysql2gem.example.com:127.0.0.1 -t mysql2
6458
fast_finish: true
6559
allow_failures:
6660
- os: osx

.travis_Dockerfile_centos

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
FROM centos:7
1+
ARG IMAGE=centos:7
2+
FROM ${IMAGE}
23

34
WORKDIR /build
45
COPY . .
56

6-
RUN yum -y update
7-
RUN yum -y install epel-release
7+
RUN cat /etc/redhat-release
8+
RUN yum -yq update
9+
RUN yum -yq install epel-release
810
# The options are to install faster.
9-
RUN yum -y install \
11+
RUN yum -yq install \
1012
--setopt=deltarpm=0 \
1113
--setopt=install_weak_deps=false \
1214
--setopt=tsflags=nodocs \
13-
mariadb-server \
14-
mariadb-devel \
15-
ruby-devel \
16-
git \
1715
gcc \
1816
gcc-c++ \
19-
make
20-
RUN gem install --no-document "rubygems-update:~>2.7" && update_rubygems
17+
git \
18+
make \
19+
mariadb-devel \
20+
mariadb-server \
21+
ruby-devel
22+
RUN gem install --no-document "rubygems-update:~>2.7" && update_rubygems > /dev/null
2123
RUN gem install --no-document "bundler:~>1.17"
2224

23-
CMD sh .travis_centos.sh
25+
CMD bash .travis_container.sh

.travis_Dockerfile_fedora

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
ARG IMAGE=fedora:latest
2+
FROM ${IMAGE}
3+
4+
WORKDIR /build
5+
COPY . .
6+
7+
RUN cat /etc/fedora-release
8+
RUN dnf -yq update
9+
# The options are to install faster.
10+
RUN dnf -yq install \
11+
--setopt=deltarpm=0 \
12+
--setopt=install_weak_deps=false \
13+
--setopt=tsflags=nodocs \
14+
gcc \
15+
gcc-c++ \
16+
git \
17+
make \
18+
mariadb-connector-c-devel \
19+
mariadb-server \
20+
redhat-rpm-config \
21+
ruby-devel \
22+
rubygem-bigdecimal \
23+
rubygem-bundler
24+
25+
CMD bash .travis_container.sh

.travis_centos.sh .travis_container.sh

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
set -eux
44

5-
# Start mysqld service.
6-
sh .travis_setup_centos.sh
7-
5+
ruby -v
86
bundle install --path vendor/bundle --without benchmarks development
97

10-
# USER environment value is not set as a default in the container environment.
11-
export USER=root
8+
# Start mysqld service.
9+
bash .travis_setup_container.sh
1210

1311
bundle exec rake

.travis_setup_centos.sh .travis_setup_container.sh

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@ set -eux
44

55
MYSQL_TEST_LOG="$(pwd)/mysql.log"
66

7-
# mysql_install_db uses wrong path for resolveip
8-
# https://jira.mariadb.org/browse/MDEV-18563
9-
# https://travis-ci.org/brianmario/mysql2/jobs/615263124#L2840
10-
ln -s "$(command -v resolveip)" /usr/libexec/resolveip
11-
127
mysql_install_db \
138
--log-error="${MYSQL_TEST_LOG}"
149
/usr/libexec/mysqld \
15-
--user=root \
10+
--user="$(id -un)" \
1611
--log-error="${MYSQL_TEST_LOG}" \
1712
--ssl &
1813
sleep 3
1914
cat ${MYSQL_TEST_LOG}
2015

16+
/usr/libexec/mysqld --version
2117
mysql -u root -e 'CREATE DATABASE IF NOT EXISTS test'

tasks/rspec.rake

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ rescue LoadError
3030
puts "rspec, or one of its dependencies, is not available. Install it with: sudo gem install rspec"
3131
end
3232

33+
# Get the value from `id` command as the environment variable USER is
34+
# not defined in a container.
35+
user_name = ENV['USER'] || `id -un`.rstrip
36+
3337
file 'spec/configuration.yml' => 'spec/configuration.yml.example' do |task|
3438
CLEAN.exclude task.name
3539
src_path = File.expand_path("../../#{task.prerequisites.first}", __FILE__)
3640
dst_path = File.expand_path("../../#{task.name}", __FILE__)
3741

3842
File.open(dst_path, 'w') do |dst_file|
3943
File.open(src_path).each_line do |line|
40-
dst_file.write line.gsub(/LOCALUSERNAME/, ENV['USER'])
44+
dst_file.write line.gsub(/LOCALUSERNAME/, user_name)
4145
end
4246
end
4347
end
@@ -49,7 +53,7 @@ file 'spec/my.cnf' => 'spec/my.cnf.example' do |task|
4953

5054
File.open(dst_path, 'w') do |dst_file|
5155
File.open(src_path).each_line do |line|
52-
dst_file.write line.gsub(/LOCALUSERNAME/, ENV['USER'])
56+
dst_file.write line.gsub(/LOCALUSERNAME/, user_name)
5357
end
5458
end
5559
end

0 commit comments

Comments
 (0)