From 8700250fcc3c9498366cbee598cf51e329e450ec Mon Sep 17 00:00:00 2001 From: Mauro Sanz <51236193+sanzmauro@users.noreply.github.com> Date: Tue, 21 Mar 2023 17:58:40 -0300 Subject: [PATCH 1/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a511fd1..4cb29b16 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Split Python SDK -[![Build Status](https://api.travis-ci.com/splitio/python-client.svg?branch=master)](https://api.travis-ci.com/splitio/python-client) +![Build Status](https://github.com/splitio/python-client/actions/workflows/ci.yml/badge.svg?branch=master) ## Overview This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via a Split feature flag to manage your complete customer experience. From dab126d46f6f00e4083f9864c7d3f70d04c6c633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Daniel=20Fad=C3=B3n?= Date: Tue, 4 Apr 2023 12:28:44 -0300 Subject: [PATCH 2/6] Fix Sonarqube --- .github/workflows/ci.yml | 25 ++++++++++++------------- .gitignore | 5 ++++- CONTRIBUTORS-GUIDE.md | 2 +- README.md | 4 ++-- doc/source/flask_support.rst | 2 +- doc/source/index.rst | 1 - sonar-project.properties | 9 +++++++++ 7 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 sonar-project.properties diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f89f6a26..9f0a0f88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ on: push: branches: - master + - development pull_request: branches: - master @@ -10,6 +11,7 @@ on: jobs: test: + name: test runs-on: ubuntu-20.04 services: redis: @@ -29,41 +31,38 @@ jobs: - name: Install dependencies run: | - pip install -U setuptools pip + pip install -U setuptools pip wheel pip install -e .[cpphash,redis,uwsgi] - name: Run tests run: python setup.py test + - name: Set VERSION env + run: echo "VERSION=$(cat splitio/version.py | grep "__version__" | awk -F\' '{print $2}')" >> $GITHUB_ENV + - name: SonarQube Scan (Push) if: github.event_name == 'push' - uses: SonarSource/sonarcloud-github-action@v1.5 + uses: SonarSource/sonarcloud-github-action@v1.9 env: SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_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.projectVersion=${{ env.VERSION }} - name: SonarQube Scan (Pull Request) if: github.event_name == 'pull_request' - uses: SonarSource/sonarcloud-github-action@v1.5 + uses: SonarSource/sonarcloud-github-action@v1.9 env: SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_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.projectVersion=${{ env.VERSION }} -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/.gitignore b/.gitignore index 31959c04..d2f290a3 100644 --- a/.gitignore +++ b/.gitignore @@ -72,4 +72,7 @@ target/ # vim backup files *.swp -.DS_Store \ No newline at end of file +.DS_Store + +# Sonarqube +.scannerwork diff --git a/CONTRIBUTORS-GUIDE.md b/CONTRIBUTORS-GUIDE.md index 11483a32..befff911 100644 --- a/CONTRIBUTORS-GUIDE.md +++ b/CONTRIBUTORS-GUIDE.md @@ -28,4 +28,4 @@ To run test you need to execute the following commands: # Contact -If you have any other questions or need to contact us directly in a private manner send us a note at sdks@split.io. \ No newline at end of file +If you have any other questions or need to contact us directly in a private manner send us a note at sdks@split.io. diff --git a/README.md b/README.md index 4cb29b16..272b5148 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Split Python SDK +# Split Python SDK ![Build Status](https://github.com/splitio/python-client/actions/workflows/ci.yml/badge.svg?branch=master) ## Overview @@ -23,7 +23,7 @@ try: factory.block_until_ready(5) # wait up to 5 seconds split = factory.client() treatment = split.get_treatment('CUSTOMER_ID', 'SPLIT_NAME') - if treatment == "on": + if treatment == "on": # insert code here to show on treatment elif treatment == "off": # insert code here to show off treatment diff --git a/doc/source/flask_support.rst b/doc/source/flask_support.rst index 7e1abf74..9ed4b8b8 100644 --- a/doc/source/flask_support.rst +++ b/doc/source/flask_support.rst @@ -37,4 +37,4 @@ This example assumes that the Split.io configuration is save in a file called `` When using the Redis client the update scripts need to be run periodically, otherwise there won't be any data available to the client. -As mentioned before, if the API key is set to ``'localhost'`` a localhost environment client is generated and no connections to Split.io are made as everything is read from ``.split`` file (you can read about this feature in the Localhost Environment section of the :doc:`/introduction`.) \ No newline at end of file +As mentioned before, if the API key is set to ``'localhost'`` a localhost environment client is generated and no connections to Split.io are made as everything is read from ``.split`` file (you can read about this feature in the Localhost Environment section of the :doc:`/introduction`.) diff --git a/doc/source/index.rst b/doc/source/index.rst index 8a61310b..249d74eb 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -20,4 +20,3 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` * :ref:`search` - diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..13f5e984 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,9 @@ +sonar.projectName=python-client +sonar.projectKey=python-client +sonar.python.version=3.6 +sonar.sources=splitio +sonar.tests=tests +sonar.text.excluded.file.suffixes=.csv +sonar.python.coverage.reportPaths=coverage.xml +sonar.links.ci=https://github.com/splitio/python-client +sonar.links.scm=https://github.com/splitio/python-client/actions From 512e7a99eb33e6d62bb1bbeeba3429848bf0b520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Daniel=20Fad=C3=B3n?= Date: Tue, 4 Apr 2023 12:28:57 -0300 Subject: [PATCH 3/6] Fix Sonarqube --- .github/pull_request_template.md | 2 +- .github/workflows/update-license-year.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 1b64b3e5..95efd4c7 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -4,4 +4,4 @@ ## How do we test the changes introduced in this PR? -## Extra Notes \ No newline at end of file +## Extra Notes diff --git a/.github/workflows/update-license-year.yml b/.github/workflows/update-license-year.yml index 989caf52..33245da6 100644 --- a/.github/workflows/update-license-year.yml +++ b/.github/workflows/update-license-year.yml @@ -16,10 +16,10 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 - + - name: Set Current year run: "echo CURRENT=$(date +%Y) >> $GITHUB_ENV" - + - name: Set Previous Year run: "echo PREVIOUS=$(($CURRENT-1)) >> $GITHUB_ENV" From 1fdaa54ac0de7852da44a28f7100d0fc0465d2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Daniel=20Fad=C3=B3n?= Date: Tue, 4 Apr 2023 12:32:29 -0300 Subject: [PATCH 4/6] Setup concurrency --- .github/workflows/ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f0a0f88..bf71a6cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,9 +9,13 @@ on: - master - development +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + jobs: test: - name: test + name: Test runs-on: ubuntu-20.04 services: redis: @@ -24,7 +28,7 @@ jobs: with: fetch-depth: 0 - - name: Set up Python + - name: Setup Python uses: actions/setup-python@v3 with: python-version: '3.6' From d854133874cf92c3407855fcfcf69d3e0e0f94a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Daniel=20Fad=C3=B3n?= Date: Tue, 4 Apr 2023 13:07:51 -0300 Subject: [PATCH 5/6] Add coverage config --- .coveragerc | 30 ++++++++++++++++++++++++++++++ sonar-project.properties | 1 + 2 files changed, 31 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..ed142a01 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,30 @@ +[run] +include = + splitio/*.py +omit = + tests/* + */__init__.py +branch = true + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain about missing debug-only code: + def __repr__ + if self\.debug + + # Don't complain if tests don't hit defensive assertion code: + raise AssertionError + raise NotImplementedError + + # Don't complain if non-runnable code isn't run: + if 0: + if __name__ == .__main__.: + +precision = 2 + +[xml] +directory = coverage.xml diff --git a/sonar-project.properties b/sonar-project.properties index 13f5e984..009f4fd7 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -5,5 +5,6 @@ sonar.sources=splitio sonar.tests=tests sonar.text.excluded.file.suffixes=.csv sonar.python.coverage.reportPaths=coverage.xml +sonar.coverage.exclusions=**/__init__.py sonar.links.ci=https://github.com/splitio/python-client sonar.links.scm=https://github.com/splitio/python-client/actions From 14d83c64aa9544708025d55ce7dd03e6114f1091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Daniel=20Fad=C3=B3n?= Date: Tue, 4 Apr 2023 13:23:04 -0300 Subject: [PATCH 6/6] Use relative paths in coverage --- .coveragerc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.coveragerc b/.coveragerc index ed142a01..c6294d30 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,10 +1,14 @@ [run] -include = - splitio/*.py +source = + splitio/ + omit = tests/* */__init__.py -branch = true + +branch = True + +relative_files = True [report] # Regexes for lines to exclude from consideration @@ -25,6 +29,3 @@ exclude_lines = if __name__ == .__main__.: precision = 2 - -[xml] -directory = coverage.xml