diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index fa6a47f..49eb21f 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -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/ diff --git a/.qlty.yml b/.qlty.yml new file mode 100644 index 0000000..5305ab8 --- /dev/null +++ b/.qlty.yml @@ -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 diff --git a/.simplecov b/.simplecov index 7b9150e..232133e 100644 --- a/.simplecov +++ b/.simplecov @@ -1,3 +1,6 @@ -SimpleCov.start do - add_filter '/test/' +if ENV['COVERAGE'] + require 'simplecov' + SimpleCov.start do + add_filter '/test/' + end end \ No newline at end of file diff --git a/test/test_helper.rb b/test/test_helper.rb index e6c27d4..cc5b0e1 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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'