From 2d20d2eccd3c23027da47513ac11fc44d7698a31 Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Sun, 26 Feb 2023 16:53:39 +0100 Subject: [PATCH 1/5] add coverage report via Code Climate --- .github/workflows/ci.yml | 9 ++++++++- Gemfile | 2 -- spec/spec_helper.rb | 14 +++++++++----- video_info.gemspec | 1 + 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ea33d50..cbe37442 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,14 @@ jobs: with: ruby-version: ${{ matrix.ruby }} bundler-cache: true - - run: bundle exec rspec + - name: Run tests + run: bundle exec rspec + - name: Publish code coverage + uses: paambaati/codeclimate-action@v3.2.0 + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + with: + coverageLocations: ${{ github.workspace }}/coverage/coverage.json:simplecov linter: runs-on: ubuntu-latest steps: diff --git a/Gemfile b/Gemfile index 6a574704..c80ee369 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,3 @@ source "http://rubygems.org" gemspec - -gem "coveralls", require: false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e1b8482b..85ed2865 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,13 +1,17 @@ +require "simplecov" +require "simplecov_json_formatter" + +SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::JSONFormatter +]) +SimpleCov.start + require "rspec" require "rspec/its" require "video_info" require "vcr" -if ENV["CI"] - require "coveralls" - Coveralls.wear! -end - VCR.configure do |config| config.cassette_library_dir = "spec/fixtures/vcr_cassettes" config.default_cassette_options = { diff --git a/video_info.gemspec b/video_info.gemspec index 16102f63..28f59497 100644 --- a/video_info.gemspec +++ b/video_info.gemspec @@ -24,6 +24,7 @@ Gem::Specification.new do |s| s.add_development_dependency "rake", ">= 12.3.3" s.add_development_dependency "rspec", "~> 3.4" s.add_development_dependency "rspec-its", "~> 1.2" + s.add_development_dependency "simplecov", "~> 0.22" s.add_development_dependency "standard", "~> 1.23" s.add_development_dependency "vcr", "~> 6.1" s.add_development_dependency "webmock", "~> 3.7" From c2e7421fd2ef8212312d68ccf792988281ccfd2a Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Sun, 26 Feb 2023 19:34:36 +0100 Subject: [PATCH 2/5] [docs] update Code Climate badges --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d5466fa3..8be787ea 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![Gem Version](https://badge.fury.io/rb/video_info.svg)](http://badge.fury.io/rb/video_info) [![CI](https://github.com/thibaudgg/video_info/actions/workflows/ci.yml/badge.svg)](https://github.com/thibaudgg/video_info/actions/workflows/ci.yml) -[![Code Climate](https://codeclimate.com/github/thibaudgg/video_info.svg)](https://codeclimate.com/github/thibaudgg/video_info) -[![Coverage Status](https://coveralls.io/repos/thibaudgg/video_info/badge.svg?branch=master)](https://coveralls.io/r/thibaudgg/video_info) +[![Maintainability](https://api.codeclimate.com/v1/badges/1f03474bdb81e735002c/maintainability)](https://codeclimate.com/github/thibaudgg/video_info/maintainability) +[![Test Coverage](https://api.codeclimate.com/v1/badges/1f03474bdb81e735002c/test_coverage)](https://codeclimate.com/github/thibaudgg/video_info/test_coverage) [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard) Simple Ruby Gem to get video info from Dailymotion, Vimeo, Wistia and YouTube (with playlist). From 7a52bc1055e12979df8e4820afec060682fb9265 Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Sun, 26 Feb 2023 19:45:32 +0100 Subject: [PATCH 3/5] [coverage] use JSON formatter in CI and HTML in local --- spec/spec_helper.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 85ed2865..bfc8e9f6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,10 +1,11 @@ require "simplecov" -require "simplecov_json_formatter" -SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([ - SimpleCov::Formatter::HTMLFormatter, +SimpleCov.formatter = if ENV["CI"] + require "simplecov_json_formatter" SimpleCov::Formatter::JSONFormatter -]) +else + SimpleCov::Formatter::HTMLFormatter +end SimpleCov.start require "rspec" From 115ec212483f8ed3186268502f7d99aff863407c Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Sun, 26 Feb 2023 20:06:10 +0100 Subject: [PATCH 4/5] optimize CI runs: avoid running twice when pushing new commits in open pull requests --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbe37442..ec5f4211 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,10 @@ name: CI -on: [push, pull_request] +on: + push: + branches: [master] + pull_request: + branches: [master] permissions: checks: write From 4fa6b27877ccdf447fea394c7e1e9e2d0d139846 Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Sun, 26 Feb 2023 20:17:16 +0100 Subject: [PATCH 5/5] [docs] minor enhancements in the API keys section (skip ci) --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8be787ea..8d242785 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,10 @@ Youtube and Vimeo have recently updated their APIs to require API keys. Scrapers has been implemented for both Youtube and Vimeo. However, the Youtube scraper can only get the date the video was posted, while the API is able to get the date and the exact time the video was posted. You may also wish to use the API to protect against potential HTML changes that could break the scrapers. -To get a Youtube API key, [follow the instructions here](https://developers.google.com/youtube/registering_an_application) +**How to get these API keys** -After generating a Youtube API key it is necessary to enable the YouTube Data API for the project which your API key was generated [enable Youtube Data API here](https://console.developers.google.com/apis/library/youtube.googleapis.com) - -To get a Vimeo API key, [follow the instructions here](https://developer.vimeo.com/api/start) +- To get a Youtube API key, [follow the instructions here](https://developers.google.com/youtube/registering_an_application). After generating a Youtube API key it is necessary to enable the YouTube Data API for the project which your API key was generated [enable Youtube Data API here](https://console.developers.google.com/apis/library/youtube.googleapis.com). +- To get a Vimeo API key, [follow the instructions here](https://developer.vimeo.com/api/start). To set the API keys, do the following: