Skip to content

Commit 6ec77ba

Browse files
authored
Added github action (#12)
1 parent 7972f7a commit 6ec77ba

File tree

2 files changed

+71
-25
lines changed

2 files changed

+71
-25
lines changed

.github/workflows/pytest.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Pytest and Black formatting
2+
3+
on:
4+
- pull_request
5+
- push
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
name: Pytest and Black formatting
11+
12+
strategy:
13+
max-parallel: 4
14+
matrix:
15+
python-version: [3.6, 3.7, 3.8, 3.9]
16+
17+
steps:
18+
- name: Cloning repo
19+
uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install Dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install -r requirements-dev.txt
32+
33+
- name: Check Formatting
34+
run: black --check .
35+
36+
- name: Run Tests
37+
run: |
38+
pytest

example/example.py

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,57 @@
22

33
from flagsmith import Flagsmith
44

5-
api_key = input('Please provide an environment api key: ')
5+
api_key = input("Please provide an environment api key: ")
66

77
flagsmith = Flagsmith(environment_id=api_key)
88

9-
identifier = input('Please provide an example identity: ')
10-
feature_name = input('Please provide an example feature name: ')
9+
identifier = input("Please provide an example identity: ")
10+
feature_name = input("Please provide an example feature name: ")
1111

12-
print_get_flags = input('Print result of get_flags for environment? (y/n) ')
13-
if print_get_flags.lower() == 'y':
12+
print_get_flags = input("Print result of get_flags for environment? (y/n) ")
13+
if print_get_flags.lower() == "y":
1414
print(json.dumps(flagsmith.get_flags(), indent=2))
1515

16-
print_get_flags_with_identity = input('Print result of get_flags with identity? (y/n) ')
17-
if print_get_flags_with_identity.lower() == 'y':
16+
print_get_flags_with_identity = input("Print result of get_flags with identity? (y/n) ")
17+
if print_get_flags_with_identity.lower() == "y":
1818
print(json.dumps(flagsmith.get_flags(identifier), indent=2))
1919

20-
print_get_flags_for_user = input('Print result of get_flags_for_user? (y/n) ')
21-
if print_get_flags_for_user.lower() == 'y':
20+
print_get_flags_for_user = input("Print result of get_flags_for_user? (y/n) ")
21+
if print_get_flags_for_user.lower() == "y":
2222
print(json.dumps(flagsmith.get_flags_for_user(identifier), indent=2))
2323

24-
print_get_value_of_feature_for_environment = input('Print result of get_value for environment? (y/n) ')
25-
if print_get_value_of_feature_for_environment.lower() == 'y':
24+
print_get_value_of_feature_for_environment = input(
25+
"Print result of get_value for environment? (y/n) "
26+
)
27+
if print_get_value_of_feature_for_environment.lower() == "y":
2628
print(flagsmith.get_value(feature_name))
2729

28-
print_get_value_of_feature_for_environment = input('Print result of get_value for identity? (y/n) ')
29-
if print_get_value_of_feature_for_environment.lower() == 'y':
30+
print_get_value_of_feature_for_environment = input(
31+
"Print result of get_value for identity? (y/n) "
32+
)
33+
if print_get_value_of_feature_for_environment.lower() == "y":
3034
print(flagsmith.get_value(feature_name, identity=identifier))
3135

32-
print_result_of_has_feature = input('Print result of has feature? (y/n) ')
33-
if print_result_of_has_feature.lower() == 'y':
36+
print_result_of_has_feature = input("Print result of has feature? (y/n) ")
37+
if print_result_of_has_feature.lower() == "y":
3438
print(flagsmith.has_feature(feature_name))
3539

36-
print_result_of_feature_enabled_for_environment = input('Print result of feature_enabled for environment? (y/n) ')
37-
if print_result_of_feature_enabled_for_environment.lower() == 'y':
40+
print_result_of_feature_enabled_for_environment = input(
41+
"Print result of feature_enabled for environment? (y/n) "
42+
)
43+
if print_result_of_feature_enabled_for_environment.lower() == "y":
3844
print(flagsmith.feature_enabled(feature_name))
3945

40-
print_result_of_feature_enabled_for_identity = input('Print result of feature_enabled for identity? (y/n) ')
41-
if print_result_of_feature_enabled_for_identity.lower() == 'y':
46+
print_result_of_feature_enabled_for_identity = input(
47+
"Print result of feature_enabled for identity? (y/n) "
48+
)
49+
if print_result_of_feature_enabled_for_identity.lower() == "y":
4250
print(flagsmith.feature_enabled(feature_name, identity=identifier))
4351

44-
set_trait = input('Would you like to test traits? (y/n) ')
45-
if set_trait.lower() == 'y':
46-
trait_key = input('Trait key: ')
47-
trait_value = input('Trait value: ')
52+
set_trait = input("Would you like to test traits? (y/n) ")
53+
if set_trait.lower() == "y":
54+
trait_key = input("Trait key: ")
55+
trait_value = input("Trait value: ")
4856
flagsmith.set_trait(trait_key, trait_value, identifier)
49-
print('Trait set successfully')
50-
print('Result from get_trait is %s' % flagsmith.get_trait(trait_key, identifier))
57+
print("Trait set successfully")
58+
print("Result from get_trait is %s" % flagsmith.get_trait(trait_key, identifier))

0 commit comments

Comments
 (0)