Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI and code formatting: add isort and flake8 checks to CI pipeline #72

Merged
merged 7 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/run-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ jobs:
run: |
pipenv check

- name: Check code formatting
run: |
pipenv run flake8 src/codemagic tests

- name: Check imports sort order
run: |
pipenv run isort src/codemagic tests --check-only

- name: Static type checks with mypy
env:
MYPYPATH: stubs
Expand Down
5 changes: 5 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ pytest = "*"
pytest-cov = "*"
mdutils = "*"
pipenv = "*"
isort = "*"
flake8 = "*"
flake8-commas = "*"
flake8-quotes = "*"
pep8-naming = "*"

[packages]
pyopenssl = "~=19.0"
Expand Down
170 changes: 112 additions & 58 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[isort]
line_length=120
force_single_line=True

[flake8]
max_line_length=120
per-file-ignores =
# F401 imported but unused
__init__.py:F401
src/codemagic/apple/resources/__init__.py:F401
# N815 variable in class scope should not be mixedCase
src/codemagic/apple/resources/*.py:N815
src/codemagic/models/export_options.py:N815
6 changes: 3 additions & 3 deletions src/codemagic/__version__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = "codemagic-cli-tools"
__description__ = "CLI tools used in Codemagic builds"
__version__ = "0.4.6"
__title__ = 'codemagic-cli-tools'
__description__ = 'CLI tools used in Codemagic builds'
__version__ = '0.4.6'
__url__ = 'https://github.com/codemagic-ci-cd/cli-tools'
__licence__ = 'GNU General Public License v3.0'
3 changes: 2 additions & 1 deletion src/codemagic/apple/app_store_connect/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import jwt

from codemagic.utilities import log

from .api_session import AppStoreConnectApiSession
from .builds import Builds
from .provisioning import BundleIdCapabilities
Expand Down Expand Up @@ -86,7 +87,7 @@ def _get_jwt_payload(self) -> Dict:
return {
'iss': self._issuer_id,
'exp': self._get_timestamp(),
'aud': AppStoreConnectApiClient.JWT_AUDIENCE
'aud': AppStoreConnectApiClient.JWT_AUDIENCE,
}

def generate_auth_headers(self) -> Dict[str, str]:
Expand Down
1 change: 1 addition & 0 deletions src/codemagic/apple/app_store_connect/api_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import requests

from codemagic.utilities import log

from .api_error import AppStoreConnectApiError


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def enable(self,
if capability_settings is not None:
attributes['settings'] = capability_settings.dict()
relationships = {
'bundleId': {'data': self._get_attribute_data(bundle_id, ResourceType.BUNDLE_ID)}
'bundleId': {'data': self._get_attribute_data(bundle_id, ResourceType.BUNDLE_ID)},
}
payload = self._get_create_payload(
ResourceType.BUNDLE_ID_CAPABILITIES, attributes=attributes, relationships=relationships)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations

from dataclasses import dataclass
from typing import TYPE_CHECKING
from typing import List
from typing import Optional
from typing import TYPE_CHECKING
from typing import Type
from typing import Union

Expand Down Expand Up @@ -61,7 +61,7 @@ def create(self,
attributes['seedId'] = seed_id
response = self.client.session.post(
f'{self.client.API_URL}/bundleIds',
json=self._get_create_payload(ResourceType.BUNDLE_ID, attributes=attributes)
json=self._get_create_payload(ResourceType.BUNDLE_ID, attributes=attributes),
).json()
return BundleId(response['data'], created=True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def create(self, name: str, platform: BundleIdPlatform, udid: str) -> Device:
}
response = self.client.session.post(
f'{self.client.API_URL}/devices',
json=self._get_create_payload(ResourceType.DEVICES, attributes=attributes)
json=self._get_create_payload(ResourceType.DEVICES, attributes=attributes),
).json()
return Device(response['data'], created=True)

Expand Down
10 changes: 5 additions & 5 deletions src/codemagic/apple/app_store_connect/provisioning/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ def create(self,
devices = []
attributes = {
'name': name,
'profileType': profile_type.value
'profileType': profile_type.value,
}
relationships = {
'bundleId': {
'data': self._get_attribute_data(bundle_id, ResourceType.BUNDLE_ID)
'data': self._get_attribute_data(bundle_id, ResourceType.BUNDLE_ID),
},
'certificates': {
'data': [self._get_attribute_data(c, ResourceType.CERTIFICATES) for c in certificates]
'data': [self._get_attribute_data(c, ResourceType.CERTIFICATES) for c in certificates],
},
'devices': {
'data': [self._get_attribute_data(d, ResourceType.DEVICES) for d in devices]
}
'data': [self._get_attribute_data(d, ResourceType.DEVICES) for d in devices],
},
}
payload = self._get_create_payload(
ResourceType.PROFILES, attributes=attributes, relationships=relationships)
Expand Down
Loading