From 77677adb3c07a7c8e2dce81b8f40e27a65e110a1 Mon Sep 17 00:00:00 2001 From: Jun Aruga Date: Mon, 11 Jan 2021 17:08:52 +0100 Subject: [PATCH] Add GitHub Actions. --- .github/workflows/test.yml | 32 ++++++++++++++++++++++++++++++++ .travis_setup.sh | 13 +++++++++++-- Gemfile | 4 ++-- 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..b821af4f0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,32 @@ +name: Test +on: [push, pull_request] +jobs: + build: + name: >- + ${{ matrix.os }} ruby ${{ matrix.ruby }} ${{ matrix.db }} + # Run all the tests on the new environment as much as possible. + # https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-20.04 # focal + ruby: + - 2.7 + db: [''] + include: + - {os: ubuntu-16.04, ruby: 2.4, db: mariadb10.0} + # 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 + # https://github.com/ruby/setup-ruby + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - if: matrix.db != '' + run: echo 'DB=${{ matrix.db }}' >> $GITHUB_ENV + - run: bash .travis_setup.sh + - run: bundle exec rake diff --git a/.travis_setup.sh b/.travis_setup.sh index 6b68bdacd..66481d15e 100644 --- a/.travis_setup.sh +++ b/.travis_setup.sh @@ -2,6 +2,15 @@ set -eux +# Install system MySQL if DB is not set. +if [[ -z ${DB-} ]]; then + sudo apt-get update -qq + sudo apt-get install -qq mysql-server-8.0 mysql-client-8.0 + sudo service mysql restart + sudo service mysql status + mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''" +fi + # Install MySQL 5.5 if DB=mysql55 if [[ -n ${DB-} && x$DB =~ ^xmysql55 ]]; then sudo bash .travis_mysql55.sh @@ -19,12 +28,12 @@ fi # Install MariaDB client headers after Travis CI fix for MariaDB 10.2 broke earlier 10.x if [[ -n ${DB-} && x$DB =~ ^xmariadb10.0 ]]; then - sudo apt-get install -y -o Dpkg::Options::='--force-confnew' libmariadbclient-dev + sudo apt-get install -y -o Dpkg::Options::='--force-confnew' mariadb-server mariadb-server-10.0 libmariadb-client-lgpl-dev fi # Install MariaDB client headers after Travis CI fix for MariaDB 10.2 broke earlier 10.x if [[ -n ${DB-} && x$DB =~ ^xmariadb10.1 ]]; then - sudo apt-get install -y -o Dpkg::Options::='--force-confnew' libmariadbclient-dev + sudo apt-get install -y -o Dpkg::Options::='--force-confnew' mariadb-server mariadb-server-10.1 libmariadbclient18 fi # Install MariaDB 10.2 if DB=mariadb10.2 diff --git a/Gemfile b/Gemfile index 79b8fbc37..652734372 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ group :test do gem 'rubocop', '~> 0.50.0' end -group :benchmarks do +group :benchmarks, optional: true do gem 'activerecord', '>= 3.0' gem 'benchmark-ips' gem 'do_mysql' @@ -28,7 +28,7 @@ group :benchmarks do gem 'sequel' end -group :development do +group :development, optional: true do gem 'pry' gem 'rake-compiler-dock', '~> 0.7.0' end