From c30c747e3f55fbf435fe1ebbf58b4ab9f60a2718 Mon Sep 17 00:00:00 2001 From: Rob Paskin Date: Wed, 5 Feb 2025 14:32:19 +0000 Subject: [PATCH 1/6] Update Ruby & MySQL versions to 'current' Versions match what we're currently running. --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2c039bc..f3a1ed4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: app: - image: ruby:${RUBY_VERSION:-2.6.10} + 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: From d8033fec887317cda58bb8578aecd2e006e83cba Mon Sep 17 00:00:00 2001 From: Rob Paskin Date: Wed, 5 Feb 2025 15:34:46 +0000 Subject: [PATCH 2/6] Fix error in spec_helper > uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger --- spec/spec_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a74a278..dfe7f98 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 'csv2db' require_relative '../app/models/concerns/csv2db/import' From abbb8b329a1dda2b0a95f900c563382c7dc2014f Mon Sep 17 00:00:00 2001 From: Rob Paskin Date: Wed, 5 Feb 2025 14:32:59 +0000 Subject: [PATCH 3/6] Add GH workflow for CI We use containers (rather than `setup-ruby`) since that's more representative of the environment in which we use the gem, even though it's presumably slower. Changes from Buildkite: - Use Docker healthcheck rather than waiting ourselves - Inline test script steps in workflows, rather than having a separate script (since we don't have the wait-for-MySQL part anymore) - Add GitHub-Actions-specific output grouping - Don't collect test failures via JUnit (it's overkill for the amount of tests we have). --- .github/workflows/ci.yml | 51 ++++++++++++++++++++++++++++++++++++++++ docker-entrypoint.sh | 20 ++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml 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/docker-entrypoint.sh b/docker-entrypoint.sh index e6f0441..a430d43 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,11 +1,27 @@ #!/usr/bin/env sh set -eu -echo "~~~ update RubyGems and Bundler" +# 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 -echo "~~~ bundle install" +endgroup + +group "bundle install" + bundle install \ --jobs "$(getconf _NPROCESSORS_ONLN)" \ --retry 2 + +endgroup From 8fbd168a28e211b7f6c53de533bb49d1364f1e9d Mon Sep 17 00:00:00 2001 From: Rob Paskin Date: Wed, 5 Feb 2025 16:11:09 +0000 Subject: [PATCH 4/6] Remove Buildkite files Superseded by GitHub Actions workflow. --- .buildkite/pipeline.yml | 32 -------------------------------- .buildkite/test.sh | 26 -------------------------- 2 files changed, 58 deletions(-) delete mode 100644 .buildkite/pipeline.yml delete mode 100755 .buildkite/test.sh diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml deleted file mode 100644 index 8775da4..0000000 --- a/.buildkite/pipeline.yml +++ /dev/null @@ -1,32 +0,0 @@ -steps: - - label: ':rspec:' - key: spec - plugins: - - docker-compose#v3.9.0: - run: app - env: - # used for names of JUnit XML files - - BUILDKITE_JOB_ID - timeout_in_minutes: 5 - commands: - - './docker-entrypoint.sh' - - '.buildkite/test.sh' - env: - BYEBUG: '0' - DEBUGGER: '0' - 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 From 94535973716f1662eb920b698f7f69dc0884e430 Mon Sep 17 00:00:00 2001 From: Rob Paskin Date: Wed, 5 Feb 2025 16:34:00 +0000 Subject: [PATCH 5/6] Remove no-longer-needed development gem --- csv2db.gemspec | 1 - 1 file changed, 1 deletion(-) diff --git a/csv2db.gemspec b/csv2db.gemspec index a2df913..49124ab 100644 --- a/csv2db.gemspec +++ b/csv2db.gemspec @@ -45,5 +45,4 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'mysql2', '~> 0.5.3' spec.add_development_dependency 'rake', '~> 12.3.3' spec.add_development_dependency 'rspec', '~> 3.0' - spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4' end From 0667089eaf42f2d783fe43c1c5652a04d5d8484c Mon Sep 17 00:00:00 2001 From: Rob Paskin Date: Wed, 5 Feb 2025 16:44:36 +0000 Subject: [PATCH 6/6] Remove obsolete reference to CircleCI --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dfe7f98..27530a3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -22,7 +22,7 @@ end db_config = { - database: "csv2db_test#{ENV['CIRCLE_NODE_INDEX']}", + database: 'csv2db_test', adapter: 'mysql2', encoding: 'utf8mb4', pool: 5,