diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index 983bf3e..0000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: "2" -prepare: - fetch: - - "https://raw.githubusercontent.com/internetee/style-guide/master/ruby/.rubocop.yml" -plugins: - duplication: - enabled: true - config: - languages: - - ruby - rubocop: - enabled: true - channel: rubocop-0-62 -exclude_patterns: - - "bin/" - - "test/" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..33ac066 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: CI + +on: + push: + branches: [ master, main ] + pull_request: + branches: [ master, main ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0 + bundler-cache: true + + - name: Install dependencies + run: bundle install + + - name: Run tests with coverage + run: bundle exec rake test + env: + COVERAGE: true + SIMPLECOV: true + + - name: Install Qlty CLI + run: curl https://qlty.sh | sh + + - name: Upload coverage to Qlty + if: success() && github.event_name == 'push' + run: | + if [ -f coverage/coverage.json ]; then + QLTY_COVERAGE_TOKEN=${{ secrets.QLTY_COVERAGE_TOKEN }} qlty coverage publish coverage/coverage.json + echo "Coverage uploaded to Qlty successfully!" + else + echo "No coverage file found at coverage/coverage.json" + ls -la coverage/ || echo "Coverage directory does not exist" + fi + env: + QLTY_COVERAGE_TOKEN: ${{ secrets.QLTY_COVERAGE_TOKEN }} diff --git a/.qlty/.gitignore b/.qlty/.gitignore new file mode 100644 index 0000000..3036618 --- /dev/null +++ b/.qlty/.gitignore @@ -0,0 +1,7 @@ +* +!configs +!configs/** +!hooks +!hooks/** +!qlty.toml +!.gitignore diff --git a/.qlty/configs/.yamllint.yaml b/.qlty/configs/.yamllint.yaml new file mode 100644 index 0000000..7440066 --- /dev/null +++ b/.qlty/configs/.yamllint.yaml @@ -0,0 +1,21 @@ +extends: default + +rules: + document-start: disable + quoted-strings: + required: only-when-needed + extra-allowed: ["{|}"] + key-duplicates: {} + octal-values: + forbid-implicit-octal: true + line-length: disable + indentation: disable + new-line-at-end-of-file: disable + trailing-spaces: disable + brackets: disable + colons: disable + empty-lines: disable + comments: disable + braces: disable + comments-indentation: disable + commas: disable diff --git a/.qlty/qlty.toml b/.qlty/qlty.toml new file mode 100644 index 0000000..80084ce --- /dev/null +++ b/.qlty/qlty.toml @@ -0,0 +1,89 @@ +# This file was automatically generated by `qlty init`. +# You can modify it to suit your needs. +# We recommend you to commit this file to your repository. +# +# This configuration is used by both Qlty CLI and Qlty Cloud. +# +# Qlty CLI -- Code quality toolkit for developers +# Qlty Cloud -- Fully automated Code Health Platform +# +# Try Qlty Cloud: https://qlty.sh +# +# For a guide to configuration, visit https://qlty.sh/d/config +# Or for a full reference, visit https://qlty.sh/d/qlty-toml +config_version = "0" + +exclude_patterns = [ + "*_min.*", + "*-min.*", + "*.min.*", + "**/.yarn/**", + "**/*.d.ts", + "**/assets/**", + "**/bower_components/**", + "**/build/**", + "**/cache/**", + "**/config/**", + "**/db/**", + "**/deps/**", + "**/dist/**", + "**/extern/**", + "**/external/**", + "**/generated/**", + "**/Godeps/**", + "**/gradlew/**", + "**/mvnw/**", + "**/node_modules/**", + "**/protos/**", + "**/seed/**", + "**/target/**", + "**/templates/**", + "**/testdata/**", + "**/vendor/**", "bin/", "test/", +] + +test_patterns = [ + "**/test/**", + "**/spec/**", + "**/*.test.*", + "**/*.spec.*", + "**/*_test.*", + "**/*_spec.*", + "**/test_*.*", + "**/spec_*.*", +] + +[smells] +mode = "comment" + +[smells.boolean_logic] +threshold = 4 + +[smells.file_complexity] +threshold = 55 + +[smells.return_statements] +threshold = 4 + +[smells.nested_control_flow] +threshold = 4 + +[smells.function_parameters] +threshold = 4 + +[smells.function_complexity] +threshold = 5 + +[smells.duplication] +threshold = 22 + +[[source]] +name = "default" +default = true + +[[plugin]] +name = "rubocop" + +[[plugin.fetch]] +url = "https://raw.githubusercontent.com/internetee/style-guide/master/ruby/.rubocop-modern.yml" +path = ".rubocop-modern.yml" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 08614d2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: ruby -before_script: - - "curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter" - - "chmod +x ./cc-test-reporter" - - "./cc-test-reporter before-build" -after_script: - - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT" \ No newline at end of file diff --git a/test/client_test.rb b/test/client_test.rb index 94f5a52..dfd2718 100644 --- a/test/client_test.rb +++ b/test/client_test.rb @@ -63,7 +63,12 @@ def test_does_not_make_a_request_when_response_is_cached end def test_parses_response_with_payload - stub_request_with_payload + response_body = File.read('test/fixtures/representation_rights_response_with_payload.xml') + stub_request(:post, "https://ariregxmlv6.rik.ee/"). + with( + body: /esindus_v1/, + headers: { 'Soapaction' => '"esindus_v1"' }). + to_return(status: 200, body: response_body) client = CompanyRegister::Client.new companies = client.representation_rights(citizen_personal_code: '1234', diff --git a/upload_coverage.sh b/upload_coverage.sh new file mode 100644 index 0000000..f7432a8 --- /dev/null +++ b/upload_coverage.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Qlty coverage upload script +# Usage: ./upload_coverage.sh + +echo "Installing Qlty CLI..." +curl https://qlty.sh | sh + +echo "Running tests with coverage..." +bundle exec rake test + +echo "Uploading coverage to Qlty..." +if [ -f coverage/coverage.json ]; then + QLTY_COVERAGE_TOKEN=$QLTY_COVERAGE_TOKEN qlty coverage publish coverage/coverage.json + echo "Coverage uploaded successfully!" +else + echo "No coverage file found. Make sure SimpleCov is configured correctly." + exit 1 +fi