Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update and set ruby version, add style and spec ci #4

Merged
merged 19 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Style Checks

on: pull_request

jobs:
changelog:
name: changelog
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Get version
id: get_version
run: |
version_file=$(find ./lib -name version.rb)
version=$(grep VERSION $version_file |cut -f 2 -d= |tr -d \'|tr -d [:space:])
echo version=$version >> $GITHUB_OUTPUT
echo version_tag=v$version >> $GITHUB_OUTPUT

- name: validate changelog exists
env:
GEM_VERSION: ${{steps.get_version.outputs.version}}
run: |
error_code=0
grep "\[${GEM_VERSION}\]" CHANGELOG.md || error_code=$?

if [ "${error_code}" -eq 1 ]; then
echo "No changelog entry found for version ${GEM_VERSION}"
exit 1
fi

rubocop:
name: runner / rubocop
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2

- name: rubocop
uses: reviewdog/action-rubocop@e70b014b8062c447d6b515ee0209f834ea93e696 #v2.5.0
with:
rubocop_version: gemfile
rubocop_extensions: rubocop-performance:gemfile rubocop-rspec:gemfile
github_token: ${{ secrets.github_token }}
filter_mode: file
fail_on_error: true
46 changes: 46 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Tests

on: pull_request

jobs:
rspec:
name: rspec tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
bundler-cache: true

- name: Run rspec tests
run: |
bundle exec rspec


- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: coverage-results
path: coverage
retention-days: 5

coverage:
needs: rspec
runs-on: ubuntu-latest
steps:
- name: Download coverage results
uses: actions/download-artifact@v3
with:
name: coverage-results
path: coverage

- name: Simplecov Report
uses: aki77/simplecov-report-action@7fd5fa551dd583dd437a11c640b2a1cf23d6cdaa # v1.5.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
failedThreshold: 100
resultPath: coverage/.last_run.json
127 changes: 125 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,125 @@
inherit_gem:
rewind-ruby-style: rubocop.yml
require:
- rubocop-performance
- rubocop-rspec

AllCops:
DisplayCopNames: true
TargetRubyVersion: 3.2
StyleGuideBaseURL: https://github.com/rewindio/ruby-style-configs/
NewCops: enable
Exclude:
- .git/**/*
- bin/**/*
- log/**/*
- tmp/**/*
- vendor/**/*

# Layout cop configuration

Layout/LineLength:
Max: 160

# Lint cop configuration

Lint/Debugger:
Enabled: true
Lint/SuppressedException:
AllowComments: true

# Metrics cop configuration

Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false

# Naming cop configuration
#Naming/FileName:
# Enabled: false
Naming/MethodParameterName:
Enabled: true
Exclude:
- spec/support/helpers.rb

Naming/BlockForwarding:
EnforcedStyle: explicit

# Minitest cop configuration

# Performance cop configuration

# Rails cop configuration

# RSpec cop configuration

RSpec/ExampleLength:
Max: 15
CountAsOne: ['array', 'heredoc', 'hash']
RSpec/MultipleExpectations:
Max: 5
# This cop does more harm than good and makes certain data-heavy classes difficult to test.
# Even Rubocop themselves disables this one.
# https://github.com/rubocop/rubocop/blob/efb1e628adfec08d2fe7875779fc16b42bde9f77/.rubocop.yml#L145
# https://stackoverflow.com/a/67149191
RSpec/MultipleMemoizedHelpers:
Enabled: false
RSpec/NestedGroups:
Max: 5
RSpec/VerifiedDoubleReference:
Enabled: false
RSpec/FilePath:
Exclude:
- spec/omni_auth/azure_devops/version_spec.rb
RSpec/SpecFilePathFormat:
Exclude:
- spec/omni_auth/azure_devops/version_spec.rb

# Style cop configuration
Style/ArgumentsForwarding:
UseAnonymousForwarding: false
Style/AsciiComments:
Enabled: false
Style/ClassAndModuleChildren:
EnforcedStyle: compact
Exclude:
- config/**/*.rb
- lib/**/*.rb
Style/DateTime:
Enabled: false
Style/Documentation:
Enabled: false
Style/FrozenStringLiteralComment:
Details: >-
Add `# frozen_string_literal: true` to the top of the file. Frozen string
literals will become the default in a future Ruby version, and we want to
make sure we're ready.
EnforcedStyle: always
SupportedStyles:
- always
- never
Style/HashEachMethods:
Enabled: true
Style/HashSyntax:
EnforcedShorthandSyntax: either
Style/HashTransformKeys:
Enabled: true
Style/HashTransformValues:
Enabled: true
Style/NumericPredicate:
Enabled: false # This is an unsafe setting which has the potential to introduce bugs because nil == 0 is false, where nil.zero? throws an exception.
Style/RedundantSelf:
Enabled: true
Style/RescueStandardError:
Enabled: false
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.2
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog

## [1.1.0]

- Update ruby version, add CI, rubocop autocorrect

## [1.0.0]

- Initial Release

## [0.1.0]
Expand Down
16 changes: 15 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
source "https://rubygems.org"
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec

group :development, :test do
gem 'bundler', '~> 2.4'
gem 'pry'
gem 'rake', '~> 13.0'
gem 'rspec', '~> 3.9.0'
gem 'rubocop'
gem 'rubocop-performance'
gem 'rubocop-rspec'
gem 'simplecov', '~> 0.22'
gem 'simplecov-console', '~> 0.9'
end
55 changes: 35 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
omniauth-azure-devops (0.1.0)
omniauth-azure-devops (1.1.0)
omniauth (>= 1, < 3)
omniauth-oauth2

Expand All @@ -20,7 +20,9 @@ GEM
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
hashie (5.0.0)
json (2.6.3)
jwt (2.7.1)
language_server-protocol (3.17.0.3)
method_source (1.0.0)
multi_xml (0.6.0)
oauth2 (2.0.9)
Expand All @@ -34,9 +36,9 @@ GEM
hashie (>= 3.4.6)
rack (>= 2.2.3)
rack-protection
omniauth-oauth2 (1.7.3)
omniauth-oauth2 (1.8.0)
oauth2 (>= 1.4, < 3)
omniauth (>= 1.9, < 3)
omniauth (~> 2.0)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
Expand All @@ -51,8 +53,6 @@ GEM
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.8.1)
rewind-ruby-style (1.0.10)
rubocop (>= 0.85, < 0.89)
rexml (3.2.6)
rspec (3.9.0)
rspec-core (~> 3.9.0)
Expand All @@ -67,17 +67,31 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.4)
rubocop (0.87.1)
rubocop (1.56.3)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 2.7.1.1)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.1.0, < 1.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.8.0)
parser (>= 2.7.1.5)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.24.0)
rubocop (~> 1.33)
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rspec (2.24.1)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
simplecov (0.22.0)
Expand All @@ -95,22 +109,23 @@ GEM
version_gem (~> 1.1, >= 1.1.1)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (1.8.0)
unicode-display_width (2.4.2)
version_gem (1.1.3)

PLATFORMS
ruby

DEPENDENCIES
bundler (= 2.0.1)
bundler (~> 2.4)
omniauth-azure-devops!
pry
rake (~> 13.0)
rewind-ruby-style
rspec (~> 3.9.0)
rubocop (~> 0.87.0)
simplecov (~> 0.19)
simplecov-console (~> 0.4)
rubocop
rubocop-performance
rubocop-rspec
simplecov (~> 0.22)
simplecov-console (~> 0.9)

BUNDLED WITH
2.0.1
2.4.19
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Omniauth
module OmniAuth
module AzureDevops
VERSION = '1.0.0'
VERSION = '1.1.0'
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require 'omniauth/strategies/oauth2'

module OmniAuth
Expand Down Expand Up @@ -37,7 +38,7 @@ def raw_info

def token_params
super.tap do |params|
params[:headers] = {'Content-Type': "application/x-www-form-urlencoded"}
params[:headers] = { 'Content-Type': 'application/x-www-form-urlencoded' }
params[:client_assertion_type] = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'
params[:client_assertion] = client.secret
params[:grant_type] = 'urn:ietf:params:oauth:grant-type:jwt-bearer'
Expand Down
Loading