You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by zk...@apache.org on 2022/11/03 10:23:47 UTC

[incubator-devlake-website] branch main updated: update pr deploy time

This is an automated email from the ASF dual-hosted git repository.

zky pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake-website.git


The following commit(s) were added to refs/heads/main by this push:
     new 72d137d3d update pr deploy time
72d137d3d is described below

commit 72d137d3dc4e11b3f4c7b692eb1dba8704871119
Author: Yingchu Chen <yi...@merico.dev>
AuthorDate: Wed Nov 2 11:48:04 2022 +0800

    update pr deploy time
---
 docs/Metrics/DeployTime.md                         |  21 +++++++++++++++++++--
 docs/Metrics/LeadTimeForChanges.md                 |  19 +++++--------------
 static/img/Metrics/pr-commit-deploy.jpeg           | Bin 0 -> 269913 bytes
 .../img/Metrics/pr-commit-deployment-relation.png  | Bin 0 -> 4857 bytes
 4 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/docs/Metrics/DeployTime.md b/docs/Metrics/DeployTime.md
index d90848082..39c589ad2 100644
--- a/docs/Metrics/DeployTime.md
+++ b/docs/Metrics/DeployTime.md
@@ -16,11 +16,28 @@ The time it takes from when a PR is merged to when it is deployed.
 
 
 ## How is it calculated?
-You can define `deployment` based on your actual practice. For a full list of `deployment`'s definitions that DevLake support, please refer to [Deployment Frequency](/docs/Metrics/DeploymentFrequency.md).
+`PR deploy time` is calculated by subtracting a PR's deployed_date and merged_date. Hence, we should associate PR/MRs with deployments.
+
+Here are the detailed steps:
+
+![](/img/Metrics/pr-commit-deployment-relation.png)
+
+1. Find the [commits diff](https://devlake.apache.org/docs/Plugins/refdiff/) between two consecutive deployments by deployments' commit_sha 
+under the same scope and environment (in terms of TESTING/STAGING/PRODUCTION),
+     for example, we will get commit-2 and commit-3 by calculating commits_diff between deployment-1 and deployment-2, which means commit-2 and commit-3 are deployed by deployment-2 
+2. Connect PR/MR and commits_diff through merge_commit or pr_commit, for example, 
+we get pr-3 connected to commit-3
+3. Now we can get pr-3's deploy time by finish_time of deployment-2 minus merge_time of pr-3.
 
 <b>Data Sources Required</b>
 
-This metric relies on PR/MRs collected from GitHub or GitLab.
+This metric relies on two sources:
+1. PR/MRs collected from GitHub or GitLab by enabling "Code Review" under the Data Entities section.
+2. Deployments collected in one of the following ways::
+   - Open APIs of Jenkins, GitLab, GitHub, etc by enabling "CICD" under the Data Entities section.
+   - Webhook for general CI tools.
+   - Releases and PR/MRs from GitHub, GitLab APIs, etc.
+
 
 <b>Transformation Rules Required</b>
 
diff --git a/docs/Metrics/LeadTimeForChanges.md b/docs/Metrics/LeadTimeForChanges.md
index 0c8dfc764..f9a7038f9 100644
--- a/docs/Metrics/LeadTimeForChanges.md
+++ b/docs/Metrics/LeadTimeForChanges.md
@@ -16,21 +16,12 @@ DORA dashboard. See [live demo](https://grafana-lake.demo.devlake.io/grafana/d/q
 
 
 ## How is it calculated?
-This metric is calculated by the median cycle time of the PRs deployed in a time range. A PR's cycle time is equal to the time a PR was deployed minus the PR's first commit's authored_date.
+1. Find the deployments whose finished_date falls into the time range that users select
+2. Calculate the commits diff between each deployment by deployments' commit_sha
+3. Find the PRs mapped to the commits in step 2, now we have the relation of Deployment - Deployed_commits - Deployed_PRs.
+4. Calculate PR Deploy Time by using finish_time of deployment minus merge_time of PR
 
-![](https://i.imgur.com/edtqmRE.png)
-
-See the picture above, there were three deployments in the last month: Deploy-1, Deploy-2 and Deploy-3. Six PRs were deployed during the same period.
-
-	Median Lead Time for Changes = The median cycle time of PR-1, PR-2, PR-3, PR-4, PR-5, PR-6
-
-The way to calculate PR cycle time:
-- PR-1 cycle time = Deploy-1's finished_date - PR-1's first commit's authored_date
-- PR-2 cycle time = Deploy-2's finished_date - PR-2's first commit's authored_date
-- PR-3 cycle time = Deploy-2's finished_date - PR-3's first commit's authored_date
-- PR-4 cycle time = Deploy-3's finished_date - PR-4's first commit's authored_date
-- PR-5 cycle time = Deploy-3's finished_date - PR-5's first commit's authored_date
-- PR-6 cycle time = Deploy-3's finished_date - PR-6's first commit's authored_date
+![](/img/Metrics/pr-commit-deploy.jpeg)
 
 PR cycle time is pre-calculated when dora plugin is triggered. You can connect to DevLake's database and find it in the field `change_timespan` in [table.pull_requests](https://devlake.apache.org/docs/DataModels/DevLakeDomainLayerSchema/#pull_requests).
 
diff --git a/static/img/Metrics/pr-commit-deploy.jpeg b/static/img/Metrics/pr-commit-deploy.jpeg
new file mode 100644
index 000000000..08b19fa89
Binary files /dev/null and b/static/img/Metrics/pr-commit-deploy.jpeg differ
diff --git a/static/img/Metrics/pr-commit-deployment-relation.png b/static/img/Metrics/pr-commit-deployment-relation.png
new file mode 100644
index 000000000..1f43b073e
Binary files /dev/null and b/static/img/Metrics/pr-commit-deployment-relation.png differ