Skip to content

Commit

Permalink
GitHub Actions: Add CentOS/Fedora cases.
Browse files Browse the repository at this point in the history
* Migrate CentOS case in Travis to GitHub Actions.
* Add Fedora cases as allow failure.
  • Loading branch information
junaruga committed Feb 23, 2021
1 parent 0ee2053 commit 23a7f39
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 31 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.bundle
Gemfile.lock
spec/configuration.yml
spec/my.cnf
tmp
vendor
32 changes: 32 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Test Linux distributions with a container not on GitHub Actions.
name: Container
on: [push, pull_request]
jobs:
build:
name: >-
${{ matrix.distro }} ${{ matrix.image }}
runs-on: ubuntu-20.04 # focal
continue-on-error: ${{ matrix.allow-failure }}
strategy:
matrix:
include:
- {distro: centos, image: 'centos:7', allow-failure: false}
# Fedora latest stable version
# Allow failure due to the following test failures.
# https://github.com/brianmario/mysql2/issues/965
- {distro: fedora, image: 'fedora:latest', allow-failure: true}
# Fedora development version
# Allow failure due to the following test failures.
# https://github.com/brianmario/mysql2/issues/1152
- {distro: fedora, image: 'fedora:rawhide', allow-failure: true}
# On the fail-fast: true, it cancels all in-progress jobs
# if any matrix job fails unlike Travis fast_finish.
fail-fast: false
steps:
- uses: actions/checkout@v2
- run: docker build -t mysql2 -f .travis_Dockerfile_${{ matrix.distro }} --build-arg IMAGE=${{ matrix.image }} .
# Add the "--cap-add=... --security-opt seccomp=..." options
# as a temporary workaround to avoid the following issue
# on the Fedora >= 34 containers.
# https://bugzilla.redhat.com/show_bug.cgi?id=1900021
- run: docker run --add-host=mysql2gem.example.com:127.0.0.1 -t --cap-add=SYS_PTRACE --security-opt seccomp=unconfined mysql2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Ubuntu
on: [push, pull_request]
jobs:
build:
Expand Down
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
sudo: required
dist: trusty
services: docker
language: ruby
bundler_args: --without benchmarks development
# Pin Rubygems to a working version. Sometimes it breaks upstream. Update now and then.
Expand Down Expand Up @@ -56,11 +55,6 @@ matrix:
addons:
hosts:
- mysql2gem.example.com
- rvm: 2.4
env: DOCKER=centos
before_install: true
install: docker build -t mysql2 -f .travis_Dockerfile_centos .
script: docker run --add-host=mysql2gem.example.com:127.0.0.1 -t mysql2
fast_finish: true
allow_failures:
- os: osx
Expand Down
24 changes: 13 additions & 11 deletions .travis_Dockerfile_centos
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
FROM centos:7
ARG IMAGE=centos:7
FROM ${IMAGE}

WORKDIR /build
COPY . .

RUN yum -y update
RUN yum -y install epel-release
RUN cat /etc/redhat-release
RUN yum -yq update
RUN yum -yq install epel-release
# The options are to install faster.
RUN yum -y install \
RUN yum -yq install \
--setopt=deltarpm=0 \
--setopt=install_weak_deps=false \
--setopt=tsflags=nodocs \
mariadb-server \
mariadb-devel \
ruby-devel \
git \
gcc \
gcc-c++ \
make
RUN gem install --no-document "rubygems-update:~>2.7" && update_rubygems
git \
make \
mariadb-devel \
mariadb-server \
ruby-devel
RUN gem install --no-document "rubygems-update:~>2.7" && update_rubygems > /dev/null
RUN gem install --no-document "bundler:~>1.17"

CMD sh .travis_centos.sh
CMD bash .travis_container.sh
25 changes: 25 additions & 0 deletions .travis_Dockerfile_fedora
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ARG IMAGE=fedora:latest
FROM ${IMAGE}

WORKDIR /build
COPY . .

RUN cat /etc/fedora-release
RUN dnf -yq update
# The options are to install faster.
RUN dnf -yq install \
--setopt=deltarpm=0 \
--setopt=install_weak_deps=false \
--setopt=tsflags=nodocs \
gcc \
git \
gcc-c++ \
make \
mariadb-connector-c-devel \
mariadb-server \
redhat-rpm-config \
ruby-devel \
rubygem-bigdecimal \
rubygem-bundler

CMD bash .travis_container.sh
8 changes: 3 additions & 5 deletions .travis_centos.sh → .travis_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

set -eux

# Start mysqld service.
sh .travis_setup_centos.sh

ruby -v
bundle install --path vendor/bundle --without benchmarks development

# USER environment value is not set as a default in the container environment.
export USER=root
# Start mysqld service.
bash .travis_setup_container.sh

bundle exec rake
8 changes: 2 additions & 6 deletions .travis_setup_centos.sh → .travis_setup_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ set -eux

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

# mysql_install_db uses wrong path for resolveip
# https://jira.mariadb.org/browse/MDEV-18563
# https://travis-ci.org/brianmario/mysql2/jobs/615263124#L2840
ln -s "$(command -v resolveip)" /usr/libexec/resolveip

mysql_install_db \
--log-error="${MYSQL_TEST_LOG}"
/usr/libexec/mysqld \
--user=root \
--user="$(id -un)" \
--log-error="${MYSQL_TEST_LOG}" \
--ssl &
sleep 3
cat ${MYSQL_TEST_LOG}

/usr/libexec/mysqld --version
mysql -u root -e 'CREATE DATABASE IF NOT EXISTS test'
8 changes: 6 additions & 2 deletions tasks/rspec.rake
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@ rescue LoadError
puts "rspec, or one of its dependencies, is not available. Install it with: sudo gem install rspec"
end

# Get the value from `id` command as the environment variable USER is
# not defined in a container.
user_name = ENV['USER'] || `id -un`.rstrip

file 'spec/configuration.yml' => 'spec/configuration.yml.example' do |task|
CLEAN.exclude task.name
src_path = File.expand_path("../../#{task.prerequisites.first}", __FILE__)
dst_path = File.expand_path("../../#{task.name}", __FILE__)

File.open(dst_path, 'w') do |dst_file|
File.open(src_path).each_line do |line|
dst_file.write line.gsub(/LOCALUSERNAME/, ENV['USER'])
dst_file.write line.gsub(/LOCALUSERNAME/, user_name)
end
end
end
Expand All @@ -49,7 +53,7 @@ file 'spec/my.cnf' => 'spec/my.cnf.example' do |task|

File.open(dst_path, 'w') do |dst_file|
File.open(src_path).each_line do |line|
dst_file.write line.gsub(/LOCALUSERNAME/, ENV['USER'])
dst_file.write line.gsub(/LOCALUSERNAME/, user_name)
end
end
end
Expand Down

0 comments on commit 23a7f39

Please sign in to comment.