Skip to content
Closed
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
155 changes: 77 additions & 78 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -1,101 +1,100 @@
name: Github Testing
on: [push]

permissions:
contents: read
id-token: write

jobs:
bundle_audit:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
bundler-cache: true
- name: config bundler
run: |
bundle config set without 'development staging production'
bundle config set deployment 'true'
bundle env
head -n1 $(which bundle)
- name: Install bundle-audit
run: gem install bundle-audit
- name: Bundle Audit Check
run: gem exec bundle-audit check --update

test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
ruby: [ 2.7 ]
os: [ubuntu-24.04]
ruby: ['3.2.2']
runs-on: ${{ matrix.os }}
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
steps:
env:
RAILS_ENV: test
COVERAGE: true
DISABLE_SPRING: 1

- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: config bundler
run: |
bundle config set without 'development staging production'
bundle config set deployment '[secure]'
bundle env
head -n1 $(which bundle)
steps:
- uses: actions/checkout@v4

- name: Set ENV for codeclimate (pull_request)
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/$GITHUB_HEAD_REF:refs/remotes/origin/$GITHUB_HEAD_REF
echo "GIT_BRANCH=$GITHUB_HEAD_REF" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$(git rev-parse origin/$GITHUB_HEAD_REF)" >> $GITHUB_ENV
if: github.event_name == 'pull_request'
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Set ENV for codeclimate (push)
run: |
echo "GIT_BRANCH=$GITHUB_REF" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV
if: github.event_name == 'push'
- name: config bundler
run: |
bundle config set without 'development staging production'
bundle config set deployment 'true'
bundle env
head -n1 $(which bundle)

- name: Prepare CodeClimate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
curl -LSs 'https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64' >./cc-test-reporter;
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- name: Install dependencies
run: |
gem install bundler -v '>= 2.2.10'
gem install builder
gem install nokogiri -v '~> 1.11.3'
gem install savon
gem install webmock
gem install mocha
gem install minitest -v '~> 5.14'
gem install simplecov -v '<= 0.17.1'
bundle install

- name: Run Tests
env:
RAILS_ENV: test
COVERAGE: true
DISABLE_SPRING: 1
run: |
gem install bundler -v '>= 2.2.10'
gem install simplecov -v '<= 0.17.1'
gem install builder
gem install nokogiri -v '~> 1.11.3'
gem install savon
gem install webmock
gem install mocha
gem install minitest -v '~> 5.14'
bundle install
rake
- name: Save coverage
run: ./cc-test-reporter format-coverage --output coverage/codeclimate.${{ matrix.ruby }}.json
- name: Run Tests
run: rake

- uses: actions/upload-artifact@v3.1.3
with:
name: coverage-${{ matrix.ruby }}
path: coverage/codeclimate.${{ matrix.ruby }}.json
- name: Setup qlty.sh
run: |
curl -sSL https://qlty.sh/install.sh | bash
export PATH="$HOME/.qlty/bin:$PATH"
qlty --version

upload_coverage:
strategy:
matrix:
os: [ ubuntu-20.04 ]
ruby: [ '2.7' ]
runs-on: ubuntu-20.04
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CC_TEST_REPORTER_URL: https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
- name: Initialize qlty.sh
run: |
export PATH="$HOME/.qlty/bin:$PATH"
qlty init --no

needs: test
- name: Run qlty.sh analysis
run: |
export PATH="$HOME/.qlty/bin:$PATH"
qlty check

steps:
- name: Download test coverage reporter
run: curl -L $CC_TEST_REPORTER_URL > cc-test-reporter
- name: Upload coverage to qlty.sh
uses: qltysh/qlty-action/coverage@v1
with:
oidc: true
files: coverage/.resultset.json

- name: Give test coverage reporter executable permissions
run: chmod +x cc-test-reporter
- uses: actions/upload-artifact@v4
with:
name: qlty-report-${{ matrix.ruby }}
path: qlty-report.json

- uses: actions/download-artifact@v3.0.2
- uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.ruby }}
path: coverage

- name: Aggregate & upload results to Code Climate
run: |
./cc-test-reporter sum-coverage coverage/codeclimate.*.json
./cc-test-reporter upload-coverage

path: coverage/
44 changes: 44 additions & 0 deletions .qlty.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: "1.0"
languages:
- ruby

# RuboCop configuration
rubocop:
enabled: true
config_file: "https://raw.githubusercontent.com/internetee/style-guide/master/ruby/.rubocop.yml"
version: "~> 1.0"

# Duplication detection
duplication:
enabled: true
threshold: 5
languages:
- ruby

# Exclude patterns
exclude_patterns:
- "bin/"
- "test/"
- "vendor/"
- "node_modules/"
- "*.gem"

# Additional quality checks
checks:
- name: "method_length"
enabled: true
max_length: 20

- name: "class_length"
enabled: true
max_length: 150

- name: "cyclomatic_complexity"
enabled: true
max_complexity: 10

# Output configuration
output:
format: "json"
file: "qlty-report.json"
console: true
7 changes: 5 additions & 2 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
SimpleCov.start do
add_filter '/test/'
if ENV['COVERAGE']
require 'simplecov'
SimpleCov.start do
add_filter '/test/'
end
end
6 changes: 1 addition & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
if ENV['COVERAGE']
require 'simplecov'
SimpleCov.start
end

# SimpleCov is configured in .simplecov file
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'e_invoice'
require 'minitest/autorun'
Expand Down
Loading