Skip to content

Commit

Permalink
Initial gem files
Browse files Browse the repository at this point in the history
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
  • Loading branch information
kostyanf14 committed Feb 22, 2023
1 parent 12a21df commit 2ec5630
Show file tree
Hide file tree
Showing 36 changed files with 648 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 5
37 changes: 37 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'ruby' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
26 changes: 26 additions & 0 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: RSpec

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
rspec:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Ruby 2.7.6
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.6
bundler-cache: true

- name: Install dependencies
run: bundle install

- name: RuboCop run
run: bundle exec rspec
36 changes: 36 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: RuboCop

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Ruby 2.7.6
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.6
bundler-cache: true

- name: Install dependencies
run: bundle install

- name: RuboCop run
run: |
bash -c "
bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
[[ $? -ne 2 ]]
"
- name: Upload Sarif output
uses: github/codeql-action/upload-sarif@v2
if: success() || failure()
with:
sarif_file: rubocop.sarif
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/.bundle/
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/

# Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/

# rspec failure tracking
.rspec_status
3 changes: 3 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--format documentation
--color
--require spec_helper
17 changes: 17 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require:
- rubocop-performance
- rubocop-rake
- rubocop-rspec

AllCops:
NewCops: enable
TargetRubyVersion: 2.7.0
Exclude:
- 'vendor/**/*'
- '.git/**/*'

Metrics/MethodLength:
Max: 20

Naming/InclusiveLanguage:
Enabled: True
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## [Unreleased]

## [0.1.0] - 2023-02-22

- Initial release
16 changes: 16 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in triggers_check.gemspec
gemspec

group :development do
gem 'code-scanning-rubocop'
gem 'rake'
gem 'rspec'
gem 'rubocop'
gem 'rubocop-performance'
gem 'rubocop-rake'
gem 'rubocop-rspec'
end
73 changes: 73 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
PATH
remote: .
specs:
triggers_check (0.1.0)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
code-scanning-rubocop (0.6.1)
rubocop (~> 1.0)
diff-lcs (1.5.0)
json (2.6.3)
parallel (1.22.1)
parser (3.2.1.0)
ast (~> 2.4.1)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.7.0)
rexml (3.2.5)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.1)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.45.1)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.24.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.26.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.17.1)
rubocop (~> 1.41)
rubocop-performance (1.16.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.18.1)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
ruby-progressbar (1.11.0)
unicode-display_width (2.4.2)

PLATFORMS
x86_64-linux

DEPENDENCIES
code-scanning-rubocop
rake
rspec
rubocop
rubocop-performance
rubocop-rake
rubocop-rspec
triggers_check!

BUNDLED WITH
2.2.33
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# TriggersCheck

The gem that provides the ability to check whether the testing process should be started

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'triggers_check'
```

And then execute:

$ bundle install

Or install it yourself as:

$ gem install triggers_check

## Usage

### Initialization options

| Parameter | Descriptions |
| --------- | ------------ |
| :work_directory | The directory where the source code is located
| :test_objects | The list of objects that are expected to run tests
| :diff_file | The file with PR difference (default: #{work_directory}/diff.txt)
| :triggers_file | The file with the list of includes/excludes for each test object (default: #{work_directory}/triggers.yml)
| :logger | The ruby logger object for logging (default: disabled)

### Examples

See examples in corresponding directory

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/triggers_check.
12 changes: 12 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

require 'rubocop/rake_task'

RuboCop::RakeTask.new

task default: %i[spec rubocop]
15 changes: 15 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'triggers_check'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require 'irb'
IRB.start(__FILE__)
8 changes: 8 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install

# Do any other automated setup that you need to do here
2 changes: 2 additions & 0 deletions example/diff.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/drv/a.cpp
src/drv/b.cpp
11 changes: 11 additions & 0 deletions example/example.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require "logger"
require 'triggers_check'
logger = Logger.new(STDOUT)
logger.level = Logger::DEBUG

[ 'drv', 'driver' ].each do |object|
checker = TriggersCheck::Checker.new('.', [ object ], logger: logger)
puts "Test object: #{object} -> #{checker.trigger?}"
end
17 changes: 17 additions & 0 deletions example/triggers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"driver":
include:
- src/drv/
exclude:
- src/drv/license
"driver2":
include:
- src/drv2/
exclude:
- src/drv2/srv/
- src/drv2/license
"*":
include:
- /
- src/tools/
exclude:
- license
Loading

0 comments on commit 2ec5630

Please sign in to comment.