diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..23464064 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,69 @@ +name: ci +on: + push: + branches: + - master + pull_request: + branches: + - master + - development + +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 Python + uses: actions/setup-python@v2 + with: + python-version: '3.7' + + - name: Install dependencies + run: | + pip install -U setuptools pip + pip install -e .[cpphash,redis,uwsgi] + + - name: Run tests + run: python setup.py test + + - 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.python.coverage.reportPaths=coverage.xml + -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.python.coverage.reportPaths=coverage.xml + -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 907676c5..00000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: python - -git: - depth: false - -matrix: - include: - - python: '3.6' - after_success: - - bash sonar-scanner.sh - -services: - - redis-server - -addons: - sonarqube: true - -install: - - pip install -U setuptools pip - - pip install -e .[cpphash,redis,uwsgi] - -script: - - python setup.py test diff --git a/setup.py b/setup.py index f1ca7219..b3ed8799 100644 --- a/setup.py +++ b/setup.py @@ -10,6 +10,7 @@ 'pytest-mock>=3.5.1', 'coverage', 'pytest-cov', + 'importlib-metadata==4.2' ] INSTALL_REQUIRES = [ diff --git a/sonar-scanner.sh b/sonar-scanner.sh deleted file mode 100644 index 284a4c25..00000000 --- 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='splitio' \ - -Dsonar.projectName='python-client' \ - -Dsonar.projectKey='python-client' \ - -Dsonar.python.coverage.reportPaths='coverage.xml' \ - -Dsonar.links.ci='https://travis-ci.com/splitio/python-client' \ - -Dsonar.links.scm='https://github.com/splitio/python-client' \ - ${params} - - return $? -} - -if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - sonar_scanner \ - -Dsonar.pullrequest.provider='GitHub' \ - -Dsonar.pullrequest.github.repository='splitio/python-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