Commit 58db2929 authored by Sean McGivern's avatar Sean McGivern

Merge branch '24139-production-wildcard-for-cycle-analytics' into 'master'

Treat environments matching `production/*` as Production for Cycle Analytics

Closes #24139

See merge request !8500
parents bb02141e b7467748
......@@ -87,7 +87,7 @@ class Environment < ActiveRecord::Base
end
def update_merge_request_metrics?
self.name == "production"
(environment_type || name) == "production"
end
def first_deployment_for(commit)
......
---
title: Treat environments matching `production/*` as Production
merge_request: 8500
author:
......@@ -50,7 +50,7 @@ exception of the staging and production stages, where only data deployed to
production are measured.
Specifically, if your CI is not set up and you have not defined a `production`
[environment], then you will not have any data for those stages.
or `production/*` [environment], then you will not have any data for those stages.
Below you can see in more detail what the various stages of Cycle Analytics mean.
......@@ -61,7 +61,7 @@ Below you can see in more detail what the various stages of Cycle Analytics mean
| Code | Measures the median time between pushing a first commit (previous stage) and creating a merge request (MR) related to that commit. The key to keep the process tracked is to include the [issue closing pattern] to the description of the merge request (for example, `Closes #xxx`, where `xxx` is the number of the issue related to this merge request). If the issue closing pattern is not present in the merge request description, the MR is not considered to the measurement time of the stage. |
| Test | Measures the median time to run the entire pipeline for that project. It's related to the time GitLab CI takes to run every job for the commits pushed to that merge request defined in the previous stage. It is basically the start->finish time for all pipelines. `master` is not excluded. It does not attempt to track time for any particular stages. |
| Review | Measures the median time taken to review the merge request, between its creation and until it's merged. |
| Staging | Measures the median time between merging the merge request until the very first deployment to production. It's tracked by the [environment] set to `production` (case-sensitive, `Production` won't work) in your GitLab CI configuration. If there isn't a `production` environment, this is not tracked. |
| Staging | Measures the median time between merging the merge request until the very first deployment to production. It's tracked by the [environment] set to `production` or matching `production/*` (case-sensitive, `Production` won't work) in your GitLab CI configuration. If there isn't a production environment, this is not tracked. |
| Production| The sum of all time (medians) taken to run the entire process, from issue creation to deploying the code to production. |
---
......@@ -79,10 +79,13 @@ Here's a little explanation of how this works behind the scenes:
etc.
To sum up, anything that doesn't follow the [GitLab flow] won't be tracked at all.
So, if a merge request doesn't close an issue or an issue is not labeled with a
label present in the Issue Board or assigned a milestone or a project has no
`production` environment (for staging and production stages), the Cycle Analytics
dashboard won't present any data at all.
So, the Cycle Analytics dashboard won't present any data:
- For merge requests that do not close an issue.
- For issues not labeled with a label present in the Issue Board.
- For issues not assigned a milestone.
- For staging and production stages, if the project has no `production` or `production/*`
environment.
## Example workflow
......
......@@ -63,6 +63,23 @@ describe Environment, models: true do
end
end
describe '#update_merge_request_metrics?' do
{ 'production' => true,
'production/eu' => true,
'production/www.gitlab.com' => true,
'productioneu' => false,
'Production' => false,
'Production/eu' => false,
'test-production' => false
}.each do |name, expected_value|
it "returns #{expected_value} for #{name}" do
env = create(:environment, name: name)
expect(env.update_merge_request_metrics?).to eq(expected_value)
end
end
end
describe '#first_deployment_for' do
let(:project) { create(:project) }
let!(:deployment) { create(:deployment, environment: environment, ref: commit.parent.id) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment