mirror of
https://github.com/samsonjs/instapaper.git
synced 2026-03-25 08:55:49 +00:00
Setup CI with GitHub actions (#8)
This commit is contained in:
parent
3a6019cbdf
commit
1edfbecac6
11 changed files with 116 additions and 39 deletions
45
.github/workflows/ci.yml
vendored
Normal file
45
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ '**' ]
|
||||
|
||||
jobs:
|
||||
# Set the job key. The key is displayed as the job name
|
||||
# when a job name is not provided
|
||||
tests:
|
||||
strategy:
|
||||
matrix:
|
||||
ruby: [ '2.6', '2.7', '3.0' ]
|
||||
|
||||
name: Tests - Ruby ${{ matrix.ruby }}
|
||||
# Set the type of machine to run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Checks out a copy of your repository on the ubuntu-latest machine
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: vendor/bundle
|
||||
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gems-
|
||||
|
||||
- name: Set up Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby }}
|
||||
bundler-cache: true
|
||||
|
||||
- name: Bundle install
|
||||
run: |
|
||||
bundle config path vendor/bundle
|
||||
bundle install --jobs 4 --retry 3 --without development
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
bundle exec rake test
|
||||
|
||||
52
.github/workflows/linter.yml
vendored
Normal file
52
.github/workflows/linter.yml
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
---
|
||||
###########################
|
||||
###########################
|
||||
## Linter GitHub Actions ##
|
||||
###########################
|
||||
###########################
|
||||
name: Lint Code Base
|
||||
|
||||
#
|
||||
# Documentation:
|
||||
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
|
||||
#
|
||||
|
||||
#############################
|
||||
# Start the job on all push #
|
||||
#############################
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ '**' ]
|
||||
|
||||
###############
|
||||
# Set the Job #
|
||||
###############
|
||||
jobs:
|
||||
build:
|
||||
# Name the Job
|
||||
name: Lint Code Base
|
||||
# Set the agent to run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
##################
|
||||
# Load all steps #
|
||||
##################
|
||||
steps:
|
||||
##########################
|
||||
# Checkout the code base #
|
||||
##########################
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# Full git history is needed to get a proper list of changed files within `super-linter`
|
||||
fetch-depth: 0
|
||||
|
||||
################################
|
||||
# Run Linter against code base #
|
||||
################################
|
||||
- name: Lint Code Base
|
||||
uses: github/super-linter@v3
|
||||
env:
|
||||
VALIDATE_ALL_CODEBASE: false
|
||||
DEFAULT_BRANCH: main
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
@ -5,6 +5,7 @@ AllCops:
|
|||
- 'lib/**/*.rb'
|
||||
- 'spec/**/*.rb'
|
||||
DisplayCopNames: true
|
||||
NewCops: enable
|
||||
|
||||
Metrics/BlockLength:
|
||||
Max: 36
|
||||
|
|
@ -54,7 +55,10 @@ Layout/SpaceInsideHashLiteralBraces:
|
|||
Style/TrailingCommaInArguments:
|
||||
EnforcedStyleForMultiline: 'comma'
|
||||
|
||||
Style/TrailingCommaInLiteral:
|
||||
Style/TrailingCommaInArrayLiteral:
|
||||
EnforcedStyleForMultiline: 'comma'
|
||||
|
||||
Style/TrailingCommaInHashLiteral:
|
||||
EnforcedStyleForMultiline: 'comma'
|
||||
|
||||
Style/FileName:
|
||||
|
|
|
|||
25
.travis.yml
25
.travis.yml
|
|
@ -1,25 +0,0 @@
|
|||
language: ruby
|
||||
|
||||
rvm:
|
||||
- 2.6.0
|
||||
- 2.7.0
|
||||
- 3.0.0
|
||||
- jruby-9.1.7.0
|
||||
- ruby-head
|
||||
|
||||
sudo: false
|
||||
|
||||
bundler_args: --without development --retry=3 --jobs=3
|
||||
|
||||
before_install:
|
||||
- gem update --system
|
||||
- gem update bundler
|
||||
|
||||
env:
|
||||
global:
|
||||
- JRUBY_OPTS="$JRUBY_OPTS --debug"
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- rvm: ruby-head
|
||||
fast_finish: true
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
lib = File.expand_path('../lib', __FILE__)
|
||||
lib = File.expand_path('lib', __dir__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
require 'instapaper/version'
|
||||
|
||||
|
|
@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|||
spec.add_dependency 'multi_json', '~> 1'
|
||||
spec.add_dependency 'simple_oauth', '~> 0.3'
|
||||
spec.add_dependency 'virtus', '~> 1'
|
||||
spec.add_development_dependency 'bundler', '~> 1.0'
|
||||
spec.add_development_dependency 'bundler'
|
||||
spec.author = 'Steve Agalloco'
|
||||
spec.description = "Ruby Client for Instapaper's Full API"
|
||||
spec.email = 'steve.agalloco@gmail.com'
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ module Instapaper
|
|||
# @param order [Array] An array of folder_id:position pairs joined by commas.
|
||||
# @example Ordering folder_ids 100, 200, and 300
|
||||
# Instapaper.set_order(['100:1','200:2','300:3'])
|
||||
def set_order(order = []) # rubocop:disable Style/AccessorMethodName
|
||||
def set_order(order = []) # rubocop:disable Naming/AccessorMethodName
|
||||
perform_post_with_objects('/api/1.1/folders/set_order', {order: order.join(',')}, Instapaper::Folder)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ module Instapaper
|
|||
response = perform_post_with_unparsed_response('/api/1.1/oauth/access_token', x_auth_username: username, x_auth_password: password, x_auth_mode: 'client_auth')
|
||||
parsed_response = QLineParser.parse(response)
|
||||
raise Instapaper::Error::OAuthError, parsed_response['error'] if parsed_response.key?('error')
|
||||
|
||||
Instapaper::Credentials.new(parsed_response)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ module Instapaper
|
|||
attribute :delete_ids, Array[Integer]
|
||||
end
|
||||
|
||||
def each
|
||||
bookmarks.each { |bookmark| yield(bookmark) }
|
||||
def each(&block)
|
||||
bookmarks.each(&block)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ module Instapaper
|
|||
module HTTP
|
||||
class Response
|
||||
attr_reader :response, :raw_format, :path
|
||||
def initialize(response, path, raw_format = false)
|
||||
|
||||
# TODO: Change this to a keyword argument (needs a major version bump)
|
||||
def initialize(response, path, raw_format = false) # rubocop:disable Style/OptionalBooleanParameter
|
||||
@response = response
|
||||
@path = path
|
||||
@raw_format = raw_format
|
||||
|
|
@ -28,9 +30,9 @@ module Instapaper
|
|||
private
|
||||
|
||||
def parsed
|
||||
@parsed_response ||= begin
|
||||
@parsed ||= begin
|
||||
response.parse(:json)
|
||||
rescue
|
||||
rescue StandardError
|
||||
response.body
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -57,9 +57,7 @@ module Instapaper
|
|||
end
|
||||
|
||||
def coerce_hash(response)
|
||||
if response.key?('hash')
|
||||
response['instapaper_hash'] = response.delete('hash')
|
||||
end
|
||||
response['instapaper_hash'] = response.delete('hash') if response.key?('hash')
|
||||
if response.key?('bookmarks')
|
||||
response['bookmarks'] = response['bookmarks'].collect do |bookmark|
|
||||
coerce_hash(bookmark)
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ def stub_get(path)
|
|||
end
|
||||
|
||||
def fixture_path
|
||||
File.expand_path('../fixtures', __FILE__)
|
||||
File.expand_path('fixtures', __dir__)
|
||||
end
|
||||
|
||||
def fixture(file)
|
||||
File.new(fixture_path + '/' + file)
|
||||
File.new("#{fixture_path}/#{file}")
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue