Skip to content

Commit 292a586

Browse files
authored
Merge pull request #21 from splitio/CLI-52823-1
Fix SonarQube scanning
2 parents 4abb15b + 56baa07 commit 292a586

File tree

14 files changed

+90
-81
lines changed

14 files changed

+90
-81
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[run]
22
source =
3-
splitio/
3+
split_openfeature_provider/
44

55
omit =
66
tests/*

.github/workflows/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @splitio/sdk
1+
* @splitio/sdk

.github/workflows/ci.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: ci
2+
23
on:
34
push:
45
branches:
@@ -16,58 +17,54 @@ concurrency:
1617
jobs:
1718
test:
1819
name: Test
19-
runs-on: ubuntu-22.04
20+
runs-on: ubuntu-24.04
2021
steps:
2122
- name: Checkout code
22-
uses: actions/checkout@v3
23+
uses: actions/checkout@v5
2324
with:
2425
fetch-depth: 0
2526

2627
- name: Setup Python
27-
uses: actions/setup-python@v3
28+
uses: actions/setup-python@v6
2829
with:
2930
python-version: '3.9.13'
3031

3132
- name: Install dependencies
3233
run: |
33-
sudo apt update
34-
sudo apt-get install -y libkrb5-dev
35-
pip install -U setuptools pip wheel
36-
pip install -e .[cpphash,redis,uwsgi]
37-
pip install pytest --quiet
38-
pip install mock
39-
pip install pytest-asyncio
40-
pip install -r requirements.txt
34+
pip install -U setuptools pip wheel
35+
pip install -e .
36+
pip install -r requirements-dev.txt
4137
42-
- name: Run tests
43-
run: cd tests; pytest -v
38+
- name: Run tests with coverage
39+
working-directory: tests
40+
run: pytest -v --cov=split_openfeature_provider --cov-report=xml:../coverage.xml
4441

4542
- name: Set VERSION env
4643
run: echo "VERSION=$(cat setup.py | grep "version=" | cut -d'"' -f2)" >> $GITHUB_ENV
4744

4845
- name: SonarQube Scan (Push)
4946
if: github.event_name == 'push'
50-
uses: SonarSource/sonarcloud-github-action@v1.9
47+
uses: SonarSource/sonarqube-scan-action@v6
5148
env:
5249
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
5350
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5451
with:
5552
projectBaseDir: .
5653
args: >
57-
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
54+
-Dsonar.host.url=${{ vars.SONARQUBE_HOST }}
5855
-Dsonar.projectVersion=${{ env.VERSION }}
5956
6057
- name: SonarQube Scan (Pull Request)
6158
if: github.event_name == 'pull_request'
62-
uses: SonarSource/sonarcloud-github-action@v1.9
59+
uses: SonarSource/sonarqube-scan-action@v6
6360
env:
6461
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
6562
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6663
with:
6764
projectBaseDir: .
6865
args: >
69-
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
66+
-Dsonar.host.url=${{ vars.SONARQUBE_HOST }}
7067
-Dsonar.projectVersion=${{ env.VERSION }}
7168
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
7269
-Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }}
73-
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}
70+
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ dmypy.json
132132
.idea/
133133

134134
# Other
135-
.DS_Store
135+
.DS_Store

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: check-json
7+
- id: check-yaml
8+
- id: end-of-file-fixer
9+
- id: trailing-whitespace

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This SDK is compatible with Python 3.9 and higher.
1111

1212
This package replaces the previous `split-openfeature-provider` Python provider in [Pypi](https://pypi.org/project/split-openfeature-provider/).
1313

14-
### Pip Installation
14+
### Pip Installation
1515
```python
1616
pip install split-openfeature-provider==1.0.0
1717
```
@@ -57,12 +57,12 @@ client = api.get_client("CLIENT_NAME")
5757
context = EvaluationContext(targeting_key="TARGETING_KEY")
5858
value = client.get_boolean_value("FLAG_NAME", False, context)
5959
```
60-
If the same targeting key is used repeatedly, the evaluation context may be set at the client level
60+
If the same targeting key is used repeatedly, the evaluation context may be set at the client level
6161
```python
6262
context = EvaluationContext(targeting_key="TARGETING_KEY")
6363
client.context = context
6464
```
65-
or at the OpenFeatureAPI level
65+
or at the OpenFeatureAPI level
6666
```python
6767
context = EvaluationContext(targeting_key="TARGETING_KEY")
6868
api.set_evaluation_context(context)
@@ -137,7 +137,7 @@ await provider._split_client_wrapper._factory.destroy()
137137
```
138138

139139
## Submitting issues
140-
140+
141141
The Split team monitors all issues submitted to this [issue tracker](https://github.com/splitio/split-openfeature-provider-python/issues). We encourage you to use this issue tracker to submit any bug reports, feedback, and feature enhancements. We'll do our best to respond in a timely manner.
142142

143143
## Contributing
@@ -147,13 +147,13 @@ Please see [Contributors Guide](CONTRIBUTORS-GUIDE.md) to find all you need to s
147147
Licensed under the Apache License, Version 2.0. See: [Apache License](http://www.apache.org/licenses/).
148148

149149
## About Split
150-
150+
151151
Split is the leading Feature Delivery Platform for engineering teams that want to confidently deploy features as fast as they can develop them. Split’s fine-grained management, real-time monitoring, and data-driven experimentation ensure that new features will improve the customer experience without breaking or degrading performance. Companies like Twilio, Salesforce, GoDaddy and WePay trust Split to power their feature delivery.
152-
152+
153153
To learn more about Split, contact [email protected], or get started with feature flags for free at https://www.split.io/signup.
154-
154+
155155
Split has built and maintains SDKs for:
156-
156+
157157
* Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
158158
* Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
159159
* Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
@@ -164,10 +164,9 @@ Split has built and maintains SDKs for:
164164
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
165165
* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
166166
* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
167-
167+
168168
For a comprehensive list of open source projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20).
169-
169+
170170
**Learn more about Split:**
171-
172-
Visit [split.io/product](https://www.split.io/product) for an overview of Split, or visit our documentation at [help.split.io](http://help.split.io) for more detailed information.
173171

172+
Visit [split.io/product](https://www.split.io/product) for an overview of Split, or visit our documentation at [help.split.io](http://help.split.io) for more detailed information.

requirements-dev.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-r requirements.txt
2+
mock>=5.0.0
3+
pytest-asyncio>=0.21.0
4+
pytest-cov>=4.0.0
5+
pytest>=7.0.0

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
openfeature_sdk==0.8.3
2-
splitio_client[cpphash,asyncio]==10.5.1
2+
splitio_client[cpphash,asyncio]==10.5.1
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
from split_openfeature_provider.split_provider import SplitProvider, SplitProviderAsync
22
from split_openfeature_provider.split_client_wrapper import SplitClientWrapper
3-

split_openfeature_provider/split_client_wrapper.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
_LOGGER = logging.getLogger(__name__)
66

77
class SplitClientWrapper():
8-
8+
99
def __init__(self, initial_context):
1010
self.sdk_ready = False
1111
self.split_client = None
12-
12+
1313
if not self._validate_context(initial_context):
14-
raise AttributeError()
14+
raise AttributeError()
1515

1616
self._api_key = initial_context.get("SdkKey")
1717
self._config = {}
1818
if initial_context.get("ConfigOptions") != None:
1919
self._config = initial_context.get("ConfigOptions")
20-
20+
2121
self._ready_block_time = 10
2222
if initial_context.get("ReadyBlockTime") != None:
2323
self._ready_block_time = initial_context.get("ReadyBlockTime")
@@ -32,66 +32,66 @@ def __init__(self, initial_context):
3232
self.split_client = initial_context.get("SplitClient")
3333
self._factory = self.split_client._factory
3434
return
35-
35+
3636
try:
3737
self._factory = get_factory(self._api_key, config=self._config)
3838
self._factory.block_until_ready(self._ready_block_time)
3939
self.sdk_ready = True
4040
except TimeoutException:
4141
_LOGGER.debug("Split SDK timed out")
42-
42+
4343
self.split_client = self._factory.client()
44-
44+
4545
async def create(self):
4646
if self._initial_context.get("SplitClient") != None:
4747
self.split_client = self._initial_context.get("SplitClient")
4848
self._factory = self.split_client._factory
4949
return
50-
50+
5151
try:
5252
self._factory = await get_factory_async(self._api_key, config=self._config)
5353
await self._factory.block_until_ready(self._ready_block_time)
5454
self.sdk_ready = True
5555
except TimeoutException:
5656
_LOGGER.debug("Split SDK timed out")
57-
57+
5858
self.split_client = self._factory.client()
59-
59+
6060
def is_sdk_ready(self):
6161
if self.sdk_ready:
6262
return True
63-
63+
6464
try:
6565
self._factory.block_until_ready(0.1)
6666
self.sdk_ready = True
6767
except TimeoutException:
6868
_LOGGER.debug("Split SDK timed out")
69-
69+
7070
return self.sdk_ready
7171

7272
def destroy(self, destroy_event=None):
7373
self._factory.destroy(destroy_event)
7474

7575
async def destroy_async(self):
7676
await self._factory.destroy()
77-
77+
7878
async def is_sdk_ready_async(self):
7979
if self.sdk_ready:
8080
return True
81-
81+
8282
try:
8383
await self._factory.block_until_ready(0.1)
8484
self.sdk_ready = True
8585
except TimeoutException:
8686
_LOGGER.debug("Split SDK timed out")
87-
87+
8888
return self.sdk_ready
89-
89+
9090
def _validate_context(self, initial_context):
9191
if initial_context != None and not isinstance(initial_context, dict):
9292
_LOGGER.error("SplitClientWrapper: initial_context must be of type `dict`")
9393
return False
94-
94+
9595
if initial_context.get("SplitClient") == None and initial_context.get("SdkKey") == None:
9696
_LOGGER.error("SplitClientWrapper: initial_context must contain keys `SplitClient` or `SdkKey`")
9797
return False
@@ -103,5 +103,5 @@ def _validate_context(self, initial_context):
103103
if initial_context.get("ConfigOptions") != None and not isinstance(initial_context.get("ConfigOptions"), dict):
104104
_LOGGER.error("SplitClientWrapper: key `ConfigOptions` must be of type `dict`")
105105
return False
106-
107-
return True
106+
107+
return True

0 commit comments

Comments
 (0)