Skip to content

Commit

Permalink
[AzureDevops ] fix: some fields' values (#7013)
Browse files Browse the repository at this point in the history
* fix(auzredevops): remove update_date from repos and cicd_scopes

* fix(azuredevops): fix environment field in cicd_tasks and cicd_pipelins

* fix(azuredevops): fix enviroment field in cicd_tasks and cicd_pipelines
  • Loading branch information
d4x1 authored and action_bot committed Feb 26, 2024
1 parent d8288c9 commit 46840c1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions backend/python/plugins/azuredevops/azuredevops/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ def domain_scopes(self, git_repo: GitRepository):
name=git_repo.name,
url=git_repo.url,
forked_from=git_repo.parent_repository_url,
updated_date=git_repo.updated_date,
# updated_date=git_repo.updated_date,
)
yield CicdScope(
name=git_repo.name,
description=git_repo.name,
url=git_repo.url,
updatedDate=git_repo.updated_date,
# updatedDate=git_repo.updated_date,
)

def remote_scope_groups(self, connection) -> list[RemoteScopeGroup]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ def convert(self, b: Build, ctx: Context):
type = devops.CICDType.BUILD
if ctx.scope_config.deployment_pattern and ctx.scope_config.deployment_pattern.search(b.name):
type = devops.CICDType.DEPLOYMENT
environment = devops.CICDEnvironment.TESTING
if ctx.scope_config.production_pattern and ctx.scope_config.production_pattern.search(b.name):
environment = devops.CICDEnvironment.PRODUCTION

environment = devops.CICDEnvironment.PRODUCTION
if ctx.scope_config.production_pattern is not None and ctx.scope_config.production_pattern.search(
b.name) is None:
environment = ""

if b.finish_time:
duration_sec = abs(b.finish_time.timestamp() - b.start_time.timestamp())
Expand Down
20 changes: 10 additions & 10 deletions backend/python/plugins/azuredevops/azuredevops/streams/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Iterable

from http import HTTPStatus
from typing import Iterable

import pydevlake.domain_layer.devops as devops
from azuredevops.api import AzureDevOpsAPI
from azuredevops.models import Job, Build, GitRepository
from azuredevops.streams.builds import Builds
from pydevlake import Context, Substream, DomainType
from pydevlake.api import APIException
import pydevlake.domain_layer.devops as devops


class Jobs(Substream):
Expand Down Expand Up @@ -81,12 +80,13 @@ def convert(self, j: Job, ctx: Context) -> Iterable[devops.CICDPipeline]:
type = devops.CICDType.BUILD
if ctx.scope_config.deployment_pattern and ctx.scope_config.deployment_pattern.search(j.name):
type = devops.CICDType.DEPLOYMENT
environment = devops.CICDEnvironment.TESTING
if ctx.scope_config.production_pattern and ctx.scope_config.production_pattern.search(j.name):
environment = devops.CICDEnvironment.PRODUCTION
environment = devops.CICDEnvironment.PRODUCTION
if ctx.scope_config.production_pattern is not None and ctx.scope_config.production_pattern.search(
j.name) is None:
environment = ""

if j.finish_time:
duration_sec = abs(j.finish_time.timestamp()-j.start_time.timestamp())
duration_sec = abs(j.finish_time.timestamp() - j.start_time.timestamp())
else:
duration_sec = float(0.0)

Expand All @@ -95,10 +95,10 @@ def convert(self, j: Job, ctx: Context) -> Iterable[devops.CICDPipeline]:
name=j.name,
pipeline_id=j.build_id,
status=status,
original_status = str(j.state),
original_result = str(j.result),
original_status=str(j.state),
original_result=str(j.result),
created_date=j.start_time,
started_date =j.start_time,
started_date=j.start_time,
finished_date=j.finish_time,
result=result,
type=type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def convert(self, pr: GitPullRequest, ctx):
merged_date=pr.closed_date,
closed_date=pr.closed_date,
type=pr.type,
component="", # not supported
component="", # not supported
merge_commit_sha=pr.merge_commit_sha,
head_ref=pr.source_ref_name,
base_ref=pr.target_ref_name,
Expand Down
2 changes: 1 addition & 1 deletion backend/python/pydevlake/pydevlake/domain_layer/devops.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CICDPipeline(DomainModel, table=True):
queued_duration_sec: Optional[float]

type: Optional[CICDType]
environment: Optional[str]
environment: Optional[CICDEnvironment]


class CiCDPipelineCommit(NoPKModel, table=True):
Expand Down

0 comments on commit 46840c1

Please sign in to comment.