From 20c656087833d84f839317e3e506c779a9c6dc00 Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov Date: Thu, 28 Mar 2024 11:45:07 +0200 Subject: [PATCH] Update the gem to work with ruby 3.3 and switch to github actions Fix `File.exists?` error -> `File.exist?` is now used --- .circleci/config.yml | 86 ---------------------------- .github/workflows/build-and-test.yml | 38 ++++++++++++ .github/workflows/publish-gem.yml | 28 +++++++++ README.md | 3 +- hellgrid.gemspec | 1 - lib/hellgrid/cli.rb | 2 +- lib/hellgrid/version.rb | 2 +- spec/spec_helper.rb | 3 - 8 files changed, 69 insertions(+), 94 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/build-and-test.yml create mode 100644 .github/workflows/publish-gem.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index c13dc6f..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,86 +0,0 @@ -version: 2 - -defaults: &defaults - working_directory: ~/hellgrid - docker: - - image: ruby:2.5-alpine - environment: - BUNDLE_APP_CONFIG: ~/hellgrid/.bundle - BUNDLE_PATH: ~/hellgrid/vendor/bundle - BUNDLE_JOBS: 4 - BUNDLE_RETRY: 3 - -jobs: - test: - <<: *defaults - steps: - - &install_packages - run: apk --no-cache add curl git openssh-client make gcc libc-dev - - checkout - - &restore_gems - restore_cache: - key: hellgrid-{{ checksum "hellgrid.gemspec" }} - - &bundle_install - run: | - bundle config --local path "$BUNDLE_PATH" - bundle check || bundle install - - &cache_gems - save_cache: - key: hellgrid-{{ checksum "hellgrid.gemspec" }} - paths: - - vendor/bundle - - run: - name: Setup Code Climate test-reporter - command: | - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - chmod +x ./cc-test-reporter - - run: - command: | - ./cc-test-reporter before-build - bundle exec rspec spec --format progress - ./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $? - - run: - name: Make sure that the gem runs when installed - command: | - set -e - gem build 'hellgrid.gemspec' - gem install $(ls -t1 hellgrid-*.gem | head -1) - cd ~ && hellgrid - push-to-rubygems: - <<: *defaults - steps: - - *install_packages - - checkout - - *restore_gems - - *bundle_install - - *cache_gems - - run: - name: Build the gem - command: gem build $CIRCLE_PROJECT_REPONAME.gemspec - - deploy: - name: Publish to RubyGems - command: | - mkdir ~/.gem - echo ":rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials - chmod 0600 ~/.gem/credentials - gem push $CIRCLE_PROJECT_REPONAME-$(echo $CIRCLE_TAG | sed -e 's/v//').gem - -workflows: - version: 2 - test-n-deploy: - jobs: - - test: - filters: - tags: - only: /.*/ - branches: - only: /.*/ - - push-to-rubygems: - context: org-global - requires: - - test - filters: - tags: - only: /^v\d.+/ - branches: - ignore: /.*/ diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..667eb55 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,38 @@ +name: Build & Test +run-name: Build & Test - ${{ github.ref_name }} + +on: + push: + branches: [ master ] + pull_request: + +jobs: + version-check: + runs-on: ubuntu-latest + if: "!contains(github.ref, 'master')" + steps: + - name: Checkout commit + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Gem versioned correctly + shell: sh + run: | + CHANGED=$(git diff origin/master HEAD --name-only | grep 'lib/hellgrid') || exit 0 + [[ -z "$CHANGED" ]] || (echo "$CHANGED" | grep 'version.rb') || exit 1 + + build-and-test: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3 + bundler-cache: true + + - name: Run tests + run: bundle exec rspec diff --git a/.github/workflows/publish-gem.yml b/.github/workflows/publish-gem.yml new file mode 100644 index 0000000..61f49e9 --- /dev/null +++ b/.github/workflows/publish-gem.yml @@ -0,0 +1,28 @@ +name: Deploy to RubyGems +run-name: ${{ github.actor }} is publishing a new version + +on: + release: + types: [published] + +jobs: + publish-gem: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + + - name: Build gem + run: gem build hellgrid.gemspec + + - name: Publish gem + env: + GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} + run: | + gem push hellgrid-*.gem diff --git a/README.md b/README.md index 310c2d1..4ac59ff 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ Utility which will output a table containing gem versions used across your projects. -[![Build Status`](https://circleci.com/gh/FundingCircle/hellgrid.svg?style=svg)](https://circleci.com/gh/FundingCircle/hellgrid) -[![Maintainability](https://api.codeclimate.com/v1/badges/13deecf7ca1f69197cbe/maintainability)](https://codeclimate.com/github/FundingCircle/hellgrid/maintainability) +[![Build & Test](https://github.com/FundingCircle/hellgrid/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/FundingCircle/hellgrid/actions/workflows/build-and-test.yml) ## Install diff --git a/hellgrid.gemspec b/hellgrid.gemspec index a5d169a..dcbaec9 100644 --- a/hellgrid.gemspec +++ b/hellgrid.gemspec @@ -22,5 +22,4 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'bundler', '>= 1.11.0', '< 3' s.add_development_dependency 'rspec', '~> 3.8.0' - s.add_development_dependency 'simplecov', '~> 0.16.0' end diff --git a/lib/hellgrid/cli.rb b/lib/hellgrid/cli.rb index 2c2ef21..28a1409 100644 --- a/lib/hellgrid/cli.rb +++ b/lib/hellgrid/cli.rb @@ -18,7 +18,7 @@ def start matrix = Hellgrid::Matrix.new Find.find(folder) do |path| - if File.directory?(path) && File.exists?(File.join(path, 'Gemfile.lock')) + if File.directory?(path) && File.exist?(File.join(path, 'Gemfile.lock')) matrix.add_project(Hellgrid::Project.new(folder, path)) Find.prune unless recursive_search end diff --git a/lib/hellgrid/version.rb b/lib/hellgrid/version.rb index a773199..59068fe 100644 --- a/lib/hellgrid/version.rb +++ b/lib/hellgrid/version.rb @@ -1,3 +1,3 @@ module Hellgrid - VERSION = '0.3.5' + VERSION = '0.4.0' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 076a169..4bd07a8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,3 @@ -require 'simplecov' -SimpleCov.start - require 'fileutils' require 'hellgrid' require 'hellgrid/project'