Skip to content

Commit

Permalink
feat(CI): RHICOMPL-2852 set up continuous integration
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Jun 29, 2023
1 parent e8e526f commit bfe31b1
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master
types: [opened, reopened, synchronize]
jobs:
static-analysis:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Rubocop
run: bundle exec rubocop --parallel
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Run unit tests
run: bin/rake test
- name: Upload code coverage
uses: codecov/codecov-action@v2
25 changes: 25 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release
on:
push:
branches:
- "master"
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Install dependencies
run: |
sudo apt-get install -y ruby-bundler
bundle install
- name: Configure git
run: |
git config user.name 'Update-a-Bot'
git config user.email '[email protected]'
- name: Publish gem
run: git diff --name-only HEAD~1 HEAD | grep lib/openscap_parser/version.rb && bundle exec rake release || echo "There is nothing to release"
env:
GEM_HOST_API_KEY: "${{secrets.GEM_HOST_API_KEY}}"
101 changes: 101 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
AllCops:
NewCops: enable
TargetRubyVersion: 3.1
Exclude:
- 'db/**/*'
- 'bin/**/*'
- 'bundle/**/*'
- 'config/**/*'
- 'test/fixtures/**/*'
- 'Rakefile'
- 'Gemfile'
- 'vendor/**/*'

Metrics/ClassLength:
Exclude:
- 'test/**/*'
- 'spec/**/*'

Metrics/BlockLength:
AllowedMethods: ['included', 'class_methods', 'GraphQL::ObjectType.define']
Exclude:
- 'test/**/*'
- 'spec/**/*'

Layout/LineEndStringConcatenationIndentation:
Enabled: false

Layout/MultilineMethodCallIndentation:
EnforcedStyle: aligned

Layout/EmptyLinesAroundAttributeAccessor:
Enabled: false

Layout/EmptyLineBetweenDefs:
EmptyLineBetweenClassDefs: false

Lint/AmbiguousOperatorPrecedence:
Enabled: false

Lint/EmptyBlock:
Enabled: false

Lint/SymbolConversion:
Enabled: false

Lint/ConstantDefinitionInBlock:
Enabled: false

Lint/RedundantCopDisableDirective:
Enabled: false

Lint/MissingSuper:
Enabled: false

Lint/EmptyFile:
Enabled: false

Naming/VariableNumber:
Enabled: false

Security/IoMethods:
Enabled: false

Style/FileWrite:
Enabled: false

Style/MapToHash:
Enabled: false

Style/OpenStructUse:
Enabled: false

Style/SingleArgumentDig:
Enabled: false

Style/IfUnlessModifier:
Enabled: false

Style/OptionalBooleanParameter:
Enabled: false

Style/RedundantFileExtensionInRequire:
Enabled: false

Style/GlobalStdStream:
Enabled: false

Style/SlicingWithRange:
Enabled: false

Style/RedundantBegin:
Enabled: false

Style/StringConcatenation:
Mode: conservative

Style/RedundantAssignment:
Enabled: false

Style/RedundantRegexpEscape:
Enabled: false
3 changes: 3 additions & 0 deletions openscap_parser.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "shoulda-context"
spec.add_development_dependency "pry"
spec.add_development_dependency "pry-byebug"
spec.add_development_dependency "rubocop", "~> 1.53.1"
spec.add_development_dependency "simplecov"
spec.add_development_dependency "simplecov-cobertura"
end
6 changes: 6 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
require 'shoulda-context'
require 'mocha/minitest'

require "simplecov"
SimpleCov.start

require 'simplecov-cobertura'
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter

def test(name, &block)
test_name = "test_#{name.gsub(/\s+/, '_')}".to_sym
defined = method_defined? test_name
Expand Down

0 comments on commit bfe31b1

Please sign in to comment.