diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..2492d31b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,79 @@ +name: CI +on: + push: + branches: + - master + tags: + - v[0-9]+.[0-9]+.[0-9]+* + pull_request: + branches: + - master +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1 + - name: Install dependencies + run: bundle install + - name: Build + run: gem build *.gemspec + - name: 'Upload Artifact' + uses: actions/upload-artifact@v3 + with: + name: gems + path: '*.gem' + test: + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + ruby-version: ['2.6', '2.7', '3.0', '3.1'] + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Ruby latest + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1 + - name: Install dependencies + run: bundle install + - name: Run tests and collect coverage + run: bundle exec rake + - name: Upload coverage to Codecov + if: ${{ matrix.ruby-version == 3.1 }} + uses: codecov/codecov-action@v3 + with: + files: ${{ github.workspace }}/coverage/coverage.xml + publish: + name: Publish + if: startsWith(github.ref, 'refs/tags/v') + needs: [build, test] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: sudo apt-get install -y oathtool + - name: Download all workflow run artifacts + uses: actions/download-artifact@v3 + with: + name: gems + path: gems + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1 + - name: Publish gems to Rubygems + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + printf -- "---\n:rubygems_api_key: ${GEM_API_KEY}\n" > $HOME/.gem/credentials + gem push gems/*.gem + env: + GEM_API_KEY: ${{secrets.GEM_API_KEY}} diff --git a/razorpay-ruby.gemspec b/razorpay-ruby.gemspec index ce2a214f..d13f9dee 100644 --- a/razorpay-ruby.gemspec +++ b/razorpay-ruby.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'httparty', '~> 0.14' - spec.add_development_dependency 'coveralls', '~> 0.8' + spec.add_development_dependency 'coveralls_reborn', '~> 0.8' spec.add_development_dependency 'minitest', '~> 5.11' spec.add_development_dependency 'rake', '~> 12.0' @@ -27,6 +27,7 @@ Gem::Specification.new do |spec| # rubocop is only run in the latest ruby build # so we use the latest version and don't switch to a # older version for 1.9.3 + spec.add_development_dependency 'simplecov-cobertura' spec.add_development_dependency 'rubocop', '~> 0.49' spec.add_development_dependency 'webmock', '~> 3.0' else diff --git a/test/test_helper.rb b/test/test_helper.rb index e81a10da..e5c32ee7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,8 +3,10 @@ require 'minitest/autorun' require 'webmock/minitest' require 'razorpay' +require 'simplecov-cobertura' Coveralls.wear! if ENV['CI'] +SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter def fixture_file(filename) return '' if filename == ''