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

[supfix/OPT-1125] to support/1.23 #374

Closed
wants to merge 6 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Analyze with SonarCloud
# You can pin the exact commit or the version.
# uses: SonarSource/sonarcloud-github-action@commithas or tag
uses: SonarSource/sonarcloud-github-action@5875562561d22a34be0c657405578705a169af6c #v1.9.1
uses: SonarSource/sonarcloud-github-action@49e6cd3b187936a73b8280d59ffd9da69df63ec9 #v2.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
Expand Down
12 changes: 11 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,15 @@ repos:
hooks:
- id: semgrep
exclude: "(.)*/tests|tests"
args: ['--config', 'p/owasp-top-ten', '--config', 'p/cwe-top-25', '--config', 'p/gitleaks', '--error', '--skip-unknown-extensions']
args: [
'--config',
'p/owasp-top-ten',
'--config',
'p/cwe-top-25',
'--config',
'p/gitleaks',
'--error',
'--skip-unknown-extensions',
'--exclude-rule=python.sqlalchemy.security.audit.avoid-sqlalchemy-text.avoid-sqlalchemy-text'
]
stages: [commit]
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
'jmespath==1.0.1',
'python-hcl2==4.3.2',
'requests==2.31.0',
'fastapi==0.99.1',
'python-multipart==0.0.6',
'fastapi==0.109.2',
'python-multipart==0.0.7',
'click==8.1.7',
'uvicorn==0.23.2',
'shapely==2.0.1',
Expand Down
2 changes: 1 addition & 1 deletion startleft/startleft/_version/local_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def choose_strategy_by_branch(branch_name: str) -> callable:
:param branch_name: The name of the branch for which the version is being calculated
:return: The callable for the version strategy calculation
"""
if branch_name == 'main' or 'release/' in branch_name:
if branch_name == 'main' or 'release/' in branch_name or 'support/' in branch_name:
return _no_local_version_strategy
else:
return _node_strategy
Expand Down
4 changes: 3 additions & 1 deletion startleft/startleft/_version/version_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ def choose_strategy_by_branch(branch_name: str, exact: bool) -> callable:
:param branch_name: The name of the branch for which the version is being calculated
:return: The callable for the version strategy calculation
"""
if branch_name == 'main' or 'release/' in branch_name or __is_tag_commit(branch_name, exact):
if branch_name == 'main' or 'release/' in branch_name or 'support/' in branch_name or __is_tag_commit(branch_name, exact):
return _tag_version_strategy
elif 'hotfix/' in branch_name:
return _patch_version_dev_commit_strategy
elif 'supfix/' in branch_name:
return _patch_version_dev_commit_strategy
elif 'bugfix' in branch_name:
return _tag_version_dev_commit_strategy
else:
Expand Down
2 changes: 1 addition & 1 deletion startleft/startleft/api/error_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ def __init__(self, status: str, error_type: str, title: str, detail: str, mes
if messages:
for message in messages:
items.append(ErrorResponseItem(message))
super().__init__(status=status, error_type=error_type, title=title, detail=detail, errors=items)
super().__init__(status=status, error_type=str(error_type), title=title, detail=detail, errors=items)
2 changes: 1 addition & 1 deletion startleft/startleft/api/fastapi_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ def get_error(error: Dict[str, Any]) -> str:


def common_response_handler(status_code: int, type_: str, title: str, detail: str, messages: List[str] = []):
error_response = ErrorResponse(error_type=type_, status=status_code, title=title, detail=detail, messages=messages)
error_response = ErrorResponse(error_type=type_, status=str(status_code), title=title, detail=detail, messages=messages)

return JSONResponse(status_code=status_code, content=jsonable_encoder(error_response))
4 changes: 4 additions & 0 deletions startleft/tests/unit/_version/test_local_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class TestLocalScheme:
('hotfix/XXX-000', '_node_strategy'),
('release/1.5.0', '_no_local_version_strategy'),
('bugfix/XXX-000', '_node_strategy'),
('support/1.19', '_no_local_version_strategy'),
('supfix/XXX-000', '_node_strategy'),
('dev', '_node_strategy'),
('feature/XXX-000', '_node_strategy'),
('UNKNOWN_BRANCH_PATTERN', '_node_strategy'),
Expand All @@ -38,6 +40,8 @@ def test_strategy_by_branch(self, branch, expected_strategy):
param(RELEASE_VERSION_BUGFIX, '', id='test_release_version_bugfix'),
# BUGFIX
param(BUGFIX_VERSION, '+g6cda015', id='test_bugfix_version'),
# SUPFIX
param(SUPFIX_VERSION, '+g6cda015', id='test_supfix_version'),
# DEV
param(DEV_RTP_VERSION, '+g17d9f68', id='test_dev_rtp_version'),
param(DEV_RP_VERSION, '+g3e49113', id='test_dev_rp_version'),
Expand Down
7 changes: 7 additions & 0 deletions startleft/tests/unit/_version/test_version_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class TestVersionScheme:
('hotfix/XXX-000', '_patch_version_dev_commit_strategy'),
('release/1.5.0', '_tag_version_strategy'),
('bugfix/XXX-000', '_tag_version_dev_commit_strategy'),
('support/1.19', '_tag_version_strategy'),
('supfix/XXX-000', '_patch_version_dev_commit_strategy'),
('dev', '_minor_version_dev_commit_strategy'),
('feature/XXX-000', '_minor_version_dev_commit_strategy'),
('UNKNOWN_BRANCH_PATTERN', '_minor_version_dev_commit_strategy'),
Expand Down Expand Up @@ -60,6 +62,11 @@ def test_detached_head(self, exact: bool, expected_strategy):
param(RELEASE_VERSION_BUGFIX, '1.6.0rc1', id='test_release_version_bugfix'),
# BUGFIX
param(BUGFIX_VERSION, '1.6.0rc1.dev1', id='test_bugfix_version'),
# SUPPORT
param(SUPPORT_VERSION_NO_SUPFIX, '1.19.0', id='test_support_version_no_supfix'),
param(SUPPORT_VERSION_SUPFIX, '1.19.1', id='test_support_version_supfix'),
# SUPFIX
param(SUPFIX_VERSION, '1.19.1.dev1', id='test_supfix_version'),
# DEV
param(DEV_RTP_VERSION, '1.7.0.dev19', id='test_dev_rtp_version'),
param(DEV_RTP_NO_DISTANCE_VERSION, '1.7.0', id='test_dev_rtp_no_distance_version'),
Expand Down
19 changes: 19 additions & 0 deletions startleft/tests/unit/_version/version_mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@
BUGFIX_VERSION = Mock(
branch='bugfix/XXX-000', tag='1.6.0rc1', distance=1, exact=False, node='g6cda015')


###########
# SUPPORT #
###########

SUPPORT_VERSION_NO_SUPFIX = Mock(
branch='support/1.19', tag='1.19.0', distance=None, exact=True, node='g05febfb'
)

SUPPORT_VERSION_SUPFIX = Mock(
branch='support/1.19', tag='1.19.1', distance=3, exact=False, node='ga1d748e'
)

##########
# SUPFIX #
##########
SUPFIX_VERSION = Mock(
branch='supfix/XXX-000', tag='1.19.0', distance=1, exact=False, node='g6cda015')

#######
# DEV #
#######
Expand Down
Loading