diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml deleted file mode 100644 index 7d70dd8..0000000 --- a/.buildkite/pipeline.yml +++ /dev/null @@ -1,51 +0,0 @@ -steps: - - label: ':rspec: Rails {{matrix.rails}} (Ruby {{matrix.ruby}})' - key: spec - plugins: - - docker-compose#v3.9.0: - run: app - env: - - 'RAILS_VERSION={{matrix.rails}}' - # used for names of JUnit XML files - - BUILDKITE_JOB_ID - timeout_in_minutes: 5 - command: - - './docker-entrypoint.sh' - - '.buildkite/test.sh' - env: - BYEBUG: '0' - DEBUGGER: '0' - RUBY_VERSION: '{{matrix.ruby}}' - matrix: - setup: - rails: - - '4.2' - - '5.2' - ruby: - - '2.5.8' - - '2.6.10' - adjustments: - - with: - rails: '5.2' - ruby: '2.5.8' - skip: true - - with: - rails: '4.2' - ruby: '2.6.10' - skip: true - artifact_paths: - - log/*.log - - tmp/rspec-junit-*.xml - - tmp/rspec/*.txt - - tmp/capybara/* - - tmp/screenshots/* - - - wait: ~ - continue_on_failure: true - - - label: ':junit:' - plugins: - - junit-annotate#v1.9.0: - artifacts: tmp/rspec-junit-*.xml - job-uuid-file-pattern: rspec-junit-([^.]+)\.xml - failure-format: file diff --git a/.buildkite/test.sh b/.buildkite/test.sh deleted file mode 100755 index 08e258c..0000000 --- a/.buildkite/test.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env sh -set -eu - -echo "~~~ Waiting for MySQL" -retries=5 - -until ruby -rsocket -e 'Socket.tcp(ENV["DB_HOST"], 3306).close' 2>/dev/null; do - retries="$(("$retries" - 1))" - - if [ "$retries" -eq 0 ]; then - echo "Failed to reach MySQL" >&2 - exit 1 - fi - - sleep 5 - echo "Waiting for MySQL ($retries retries left)" -done - -echo "+++ :rspec: Running specs" -mkdir -p tmp -mkdir -p log - -bin/rspec \ - --format RspecJunitFormatter \ - --out "tmp/rspec-junit-$BUILDKITE_JOB_ID.xml" \ - --format documentation diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5b4cd1c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,51 @@ +name: Test Suite + +on: + push: + workflow_dispatch: + +jobs: + spec: + name: RSpec + runs-on: ubuntu-latest + + container: + image: ruby:2.7.8 + credentials: + username: ${{ secrets.ORG_DOCKERHUB_USERNAME }} + password: ${{ secrets.ORG_DOCKERHUB_TOKEN }} + env: + DB_HOST: db + DB_USERNAME: root + + services: # versions here should match those used in docker-compose.yml + db: + image: mysql:8.0.34 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: "yes" + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + + steps: + - uses: actions/checkout@v4 + + - name: Run RSpec + shell: script -q -e -c "bash {0}" # force colour output - see https://github.com/actions/runner/issues/241 + run: | + set -euo pipefail + + ./docker-entrypoint.sh + + mkdir -p tmp + mkdir -p log + + bin/rspec + + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: "test.log" + path: log/test.log diff --git a/Gemfile b/Gemfile index acf8695..88c1871 100644 --- a/Gemfile +++ b/Gemfile @@ -2,8 +2,3 @@ source 'https://rubygems.org' # Specify your gem's dependencies in report_generator.gemspec gemspec - -rails_version = ENV['RAILS_VERSION'] -rails_version = '4.2' if !rails_version || rails_version.strip.empty? - -gem 'railties', "~> #{rails_version}" diff --git a/docker-compose.yml b/docker-compose.yml index 2e143f2..b01a2ed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: app: - image: ruby:${RUBY_VERSION:-2.5.8} + image: ruby:${RUBY_VERSION:-2.7.8} working_dir: /app command: > bash -eu -c ' @@ -18,7 +18,7 @@ services: - .:/app:cached db: - image: mysql:5.7 + image: mysql:8.0.34 environment: - MYSQL_ALLOW_EMPTY_PASSWORD=yes expose: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index fe20106..a430d43 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,16 +1,27 @@ #!/usr/bin/env sh set -eu -echo "~~~ update RubyGems and Bundler" -if [ "${RUBY_VERSION:-}" = "2.6.10" ]; then - gem install bundler -v "~> 2.4.22" - gem update --system 3.4.22 >/dev/null -else - gem install bundler -v 2.3.27 - gem update --system 3.2.3 >/dev/null -fi - -echo "~~~ bundle install" +# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#grouping-log-lines +group() { + echo "::group::${1}" +} + +endgroup() { + echo "::endgroup::" +} + +group "update RubyGems and Bundler" + +# latest supported versions for Ruby 2.x +gem install bundler -v "~> 2.4.22" +gem update --system 3.4.22 >/dev/null + +endgroup + +group "bundle install" + bundle install \ --jobs "$(getconf _NPROCESSORS_ONLN)" \ --retry 2 + +endgroup diff --git a/report_generator.gemspec b/report_generator.gemspec index 7ff3453..d47cd50 100644 --- a/report_generator.gemspec +++ b/report_generator.gemspec @@ -49,6 +49,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'dragonfly-s3_data_store', '~> 1.3' spec.add_development_dependency 'mysql2', '~> 0.5.3' spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4' spec.add_development_dependency 'rspec-rails', '~> 3.0' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5eb42dc..e135153 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,7 @@ require 'bundler/setup' require 'byebug' require 'mysql2' +require 'logger' require 'rails/all' require 'rspec/rails' require 'active_support/testing/time_helpers' @@ -30,7 +31,7 @@ Rails.application = ReportGenerator::Engine db_config = { - database: "report_generator_test#{ENV['CIRCLE_NODE_INDEX']}", + database: 'report_generator_test', adapter: 'mysql2', encoding: 'utf8mb4', pool: 5,