Skip to content

add stackadapt issue lead time #10

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
118 changes: 118 additions & 0 deletions .github/workflows/build-push-ecr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name: DevLake Build and Push to ECR
run-name: DevLake build and push to ECR by @${{ github.actor }}

on:
workflow_dispatch:
push:
branches:
- master
- andy/dx-85

permissions:
id-token: write # Required for JWT
contents: read # Required for checkout

env:
LATEST_TAG: v1.0.2-beta4
COMMIT_TAG: ${{ github.sha }}
AWS_REGION: us-east-1
IAM_ROLE_ARN: arn:aws:iam::130726505375:role/github-actions-ecr
ECR: 130726505375.dkr.ecr.us-east-1.amazonaws.com
IMAGE_NAME_SERVER: devlake-server
IMAGE_NAME_CONFIG_UI: devlake-config-ui

jobs:
build-and-push-server:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@83b7061638ee4956cf7545a6f7efe594e5ad0247 #v3.5.1

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
with:
role-to-assume: ${{ env.IAM_ROLE_ARN }}
role-session-name: github-action-devlake-server-build
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: ${{ env.ECR }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c

- name: Build and push container image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: ./backend
push: true
file: ./backend/Dockerfile
tags: |
${{ env.ECR }}/${{ env.IMAGE_NAME_SERVER }}:${{ env.LATEST_TAG }}
${{ env.ECR }}/${{ env.IMAGE_NAME_SERVER }}:${{ env.COMMIT_TAG }}
platforms: linux/amd64,linux/arm64
build-args: |
TAG=${{ github.ref_name }}
SHA=${{ github.sha }}

build-and-push-config-ui:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@83b7061638ee4956cf7545a6f7efe594e5ad0247 #v3.5.1

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
with:
role-to-assume: ${{ env.IAM_ROLE_ARN }}
role-session-name: github-action-devlake-config-ui-build
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: ${{ env.ECR }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c

- name: Build and push container image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: ./config-ui
push: true
file: ./config-ui/Dockerfile
tags: |
${{ env.ECR }}/${{ env.IMAGE_NAME_CONFIG_UI }}:${{ env.LATEST_TAG }}
${{ env.ECR }}/${{ env.IMAGE_NAME_CONFIG_UI }}:${{ env.COMMIT_TAG }}
platforms: linux/amd64,linux/arm64
build-args: |
TAG=${{ github.ref_name }}
SHA=${{ github.sha }}
2 changes: 2 additions & 0 deletions backend/plugins/dora/impl/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func (p Dora) SubTaskMetas() []plugin.SubTaskMeta {
tasks.EnrichPrevSuccessDeploymentCommitMeta,
tasks.EnrichTaskEnvMeta,
tasks.CalculateChangeLeadTimeMeta,
tasks.CalculateIssueLeadTimeMeta,
tasks.IssuesToIncidentsMeta,
tasks.ConnectIncidentToDeploymentMeta,
}
Expand Down Expand Up @@ -160,6 +161,7 @@ func (p Dora) MakeMetricPluginPipelinePlanV200(projectName string, options json.
},
Subtasks: []string{
"calculateChangeLeadTime",
"calculateIssueLeadTime",
tasks.IssuesToIncidentsMeta.Name,
"ConnectIncidentToDeployment",
},
Expand Down
38 changes: 38 additions & 0 deletions backend/plugins/dora/models/issue_lead_time_metric.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package models

import (
"time"
)

// IssueLeadTimeMetric tracks lead time for issues from in-progress to done
type IssueLeadTimeMetric struct {
ProjectName string `json:"projectName" gorm:"primaryKey;type:varchar(255)"`
IssueId string `json:"issueId" gorm:"primaryKey;type:varchar(255)"`
InProgressDate *time.Time `json:"InProgressDate"`
DoneDate *time.Time `json:"DoneDate"`

// Lead time in minutes from first 'In Progress' to first 'Done'
InProgressToDoneMinutes *int64 `json:"inProgressToDoneMinutes"`
}

// TableName specifies the database table name
func (IssueLeadTimeMetric) TableName() string {
return "_tool_dora_issue_lead_time_metrics"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package migrationscripts

import (
"time"

"github.com/apache/incubator-devlake/core/context"
"github.com/apache/incubator-devlake/core/errors"
)

// Define the actual table structure directly in the migration script
type issueLeadTimeMetric struct {
ProjectName string `gorm:"primaryKey;type:varchar(255)"`
IssueId string `gorm:"primaryKey;type:varchar(255)"`
InProgressDate *time.Time
DoneDate *time.Time
InProgressToDoneMinutes *int64
}

// TableName specifies the table name
func (issueLeadTimeMetric) TableName() string {
return "_tool_dora_issue_lead_time_metrics"
}

type addIssueLeadTimeMetricsTable struct{}

func (script *addIssueLeadTimeMetricsTable) Up(baseRes context.BasicRes) errors.Error {
db := baseRes.GetDal()
// Use our directly defined model instead of importing from models
return db.AutoMigrate(&issueLeadTimeMetric{})
}

func (*addIssueLeadTimeMetricsTable) Version() uint64 {
return 2025042401
}

func (*addIssueLeadTimeMetricsTable) Name() string {
return "dora add _tool_dora_issue_lead_time_metrics table"
}
1 change: 1 addition & 0 deletions backend/plugins/dora/models/migrationscripts/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ func All() []plugin.MigrationScript {
new(addDoraBenchmark),
new(fixDoraBenchmarkMetric),
new(adddoraBenchmark2023),
new(addIssueLeadTimeMetricsTable),
}
}
6 changes: 3 additions & 3 deletions backend/plugins/dora/tasks/deployment_commits_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ func GenerateDeploymentCommits(taskCtx plugin.SubTaskContext) errors.Error {
noneSkippedResult,
),
}
if data.Options.ScopeId != nil {
clauses = append(clauses, dal.Where(`p.cicd_scope_id = ?`, data.Options.ScopeId))
if data.ScopeId != "" {
clauses = append(clauses, dal.Where(`p.cicd_scope_id = ?`, data.ScopeId))
// Clear previous results from the project
deleteSql := `DELETE FROM cicd_deployment_commits WHERE cicd_scope_id = ? and subtask_name = ?;`
err := db.Exec(deleteSql, data.Options.ScopeId, DORAGenerateDeploymentCommits)
err := db.Exec(deleteSql, data.ScopeId, DORAGenerateDeploymentCommits)
if err != nil {
return errors.Default.Wrap(err, "error deleting previous cicd_deployment_commits")
}
Expand Down
6 changes: 3 additions & 3 deletions backend/plugins/dora/tasks/deployment_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ func GenerateDeployment(taskCtx plugin.SubTaskContext) errors.Error {
noneSkippedResult,
),
}
if data.Options.ScopeId != nil {
if data.ScopeId != "" {
clauses = append(clauses,
dal.Where("p.cicd_scope_id = ?", data.Options.ScopeId),
dal.Where("p.cicd_scope_id = ?", data.ScopeId),
)
// Clear previous results from the cicd_scope_id
deleteSql := `DELETE FROM cicd_deployments WHERE cicd_scope_id = ? and subtask_name = ?;`
err := db.Exec(deleteSql, data.Options.ScopeId, DORAGenerateDeployment)
err := db.Exec(deleteSql, data.ScopeId, DORAGenerateDeployment)
if err != nil {
return errors.Default.Wrap(err, "error deleting previous deployments")
}
Expand Down
Loading
Loading