From f9a3673574833857c1998617b55d70f96bf2c089 Mon Sep 17 00:00:00 2001 From: splitadricejas Date: Tue, 21 Sep 2021 16:54:08 -0300 Subject: [PATCH 1/3] CI workflow added and Travis removed --- .github/workflows/ci.yml | 67 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 20 ------------ sonar-scanner.sh | 42 ------------------------- 3 files changed, 67 insertions(+), 62 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml delete mode 100755 sonar-scanner.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..2dbf2599c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,67 @@ +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + services: + redis: + image: redis + ports: + - 6379:6379 + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Ruby + uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6 + with: + ruby-version: 2.4 + + - name: Install dependencies + run: bundle install + + - name: Run tests + run: bundle exec rake + + - name: SonarQube Scan (Push) + if: github.event_name == 'push' + uses: SonarSource/sonarcloud-github-action@v1.5 + env: + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} + with: + projectBaseDir: . + args: > + -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} + -Dsonar.projectName=${{ github.event.repository.name }} + -Dsonar.projectKey=${{ github.event.repository.name }} + -Dsonar.exclusions='**/*_test.go,**/vendor/**,**/testdata/*' + -Dsonar.go.coverage.reportPaths=coverage.out + -Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions" + -Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}" + + - name: SonarQube Scan (Pull Request) + if: github.event_name == 'pull_request' + uses: SonarSource/sonarcloud-github-action@v1.5 + env: + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} + with: + projectBaseDir: . + args: > + -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} + -Dsonar.projectName=${{ github.event.repository.name }} + -Dsonar.projectKey=${{ github.event.repository.name }} + -Dsonar.exclusions='**/*_test.go,**/vendor/**,**/testdata/*' + -Dsonar.go.coverage.reportPaths=coverage.out + -Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions" + -Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}" + -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} + -Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} + -Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e80af11b6..000000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: ruby - -rvm: - - "2.3.6" - -services: - - redis-server - -addons: - sonarqube: true - -git: - depth: false - -before_install: - - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true - - gem install bundler -v '< 2' - -after_success: - - bash sonar-scanner.sh diff --git a/sonar-scanner.sh b/sonar-scanner.sh deleted file mode 100755 index 151e95953..000000000 --- a/sonar-scanner.sh +++ /dev/null @@ -1,42 +0,0 @@ -#/bin/bash -e - -sonar_scanner() { - local params=$@ - - sonar-scanner \ - -Dsonar.host.url='https://sonarqube.split-internal.com' \ - -Dsonar.login="$SONAR_TOKEN" \ - -Dsonar.ws.timeout='300' \ - -Dsonar.sources='lib' \ - -Dsonar.projectName='ruby-client' \ - -Dsonar.projectKey='ruby-client' \ - -Dsonar.ruby.coverage.reportPaths='coverage/.resultset.json' \ - -Dsonar.links.ci='https://travis-ci.com/splitio/ruby-client' \ - -Dsonar.links.scm='https://github.com/splitio/ruby-client' \ - ${params} - - return $? -} - -if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - sonar_scanner \ - -Dsonar.pullrequest.provider='GitHub' \ - -Dsonar.pullrequest.github.repository='splitio/ruby-client' \ - -Dsonar.pullrequest.key=$TRAVIS_PULL_REQUEST \ - -Dsonar.pullrequest.branch=$TRAVIS_PULL_REQUEST_BRANCH \ - -Dsonar.pullrequest.base=$TRAVIS_BRANCH -else - if [ "$TRAVIS_BRANCH" == 'master' ]; then - sonar_scanner \ - -Dsonar.branch.name=$TRAVIS_BRANCH - else - if [ "$TRAVIS_BRANCH" == 'development' ]; then - TARGET_BRANCH='master' - else - TARGET_BRANCH='development' - fi - sonar_scanner \ - -Dsonar.branch.name=$TRAVIS_BRANCH \ - -Dsonar.branch.target=$TARGET_BRANCH - fi -fi From c15eb306236451bfb68df55db2a57ccfead61abf Mon Sep 17 00:00:00 2001 From: splitadricejas Date: Tue, 21 Sep 2021 17:01:28 -0300 Subject: [PATCH 2/3] bundler version removed --- splitclient-rb.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/splitclient-rb.gemspec b/splitclient-rb.gemspec index a80cc0f63..f96e3d640 100644 --- a/splitclient-rb.gemspec +++ b/splitclient-rb.gemspec @@ -38,7 +38,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'allocation_stats' spec.add_development_dependency 'appraisal' - spec.add_development_dependency 'bundler', '~> 1.11' + spec.add_development_dependency 'bundler' spec.add_development_dependency 'pry' spec.add_development_dependency 'pry-nav' spec.add_development_dependency 'rake', '12.3.3' From 4622454181ec50b90ea0f52b024c0c72a5614ffc Mon Sep 17 00:00:00 2001 From: splitadricejas Date: Tue, 21 Sep 2021 17:17:20 -0300 Subject: [PATCH 3/3] sonar fix --- .github/workflows/ci.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2dbf2599c..675a85714 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,8 +42,10 @@ jobs: -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} -Dsonar.projectName=${{ github.event.repository.name }} -Dsonar.projectKey=${{ github.event.repository.name }} - -Dsonar.exclusions='**/*_test.go,**/vendor/**,**/testdata/*' - -Dsonar.go.coverage.reportPaths=coverage.out + -Dsonar.ruby.coverage.reportPaths='coverage/.resultset.json' + -Dsonar.c.file.suffixes=- + -Dsonar.cpp.file.suffixes=- + -Dsonar.objc.file.suffixes=- -Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions" -Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}" @@ -58,8 +60,10 @@ jobs: -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} -Dsonar.projectName=${{ github.event.repository.name }} -Dsonar.projectKey=${{ github.event.repository.name }} - -Dsonar.exclusions='**/*_test.go,**/vendor/**,**/testdata/*' - -Dsonar.go.coverage.reportPaths=coverage.out + -Dsonar.ruby.coverage.reportPaths='coverage/.resultset.json' + -Dsonar.c.file.suffixes=- + -Dsonar.cpp.file.suffixes=- + -Dsonar.objc.file.suffixes=- -Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions" -Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}" -Dsonar.pullrequest.key=${{ github.event.pull_request.number }}