Skip to content
代码片段 群组 项目
提交 217cf364 编辑于 作者: Jose Ivan Vargas's avatar Jose Ivan Vargas
浏览文件

Merge branch '362518-remove-shared-runner-usage-from-analytics' into 'master'

Remove shared runner usage tab from analytics

See merge request gitlab-org/gitlab!94978
No related branches found
No related tags found
无相关合并请求
......@@ -7,7 +7,6 @@ import ChangeFailureRateCharts from 'ee/dora/components/change_failure_rate_char
import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/url_utility';
import API from '~/api';
import ReleaseStatsCard from './release_stats_card.vue';
import SharedRunnersUsage from './shared_runner_usage.vue';
export default {
name: 'CiCdAnalyticsApp',
......@@ -20,7 +19,6 @@ export default {
LeadTimeCharts,
TimeToRestoreServiceCharts,
ChangeFailureRateCharts,
SharedRunnersUsage,
},
releaseStatisticsTabEvent: 'g_analytics_ci_cd_release_statistics',
deploymentFrequencyTabEvent: 'g_analytics_ci_cd_deployment_frequency',
......@@ -130,9 +128,6 @@ export default {
<change-failure-rate-charts />
</gl-tab>
</template>
<gl-tab :title="s__('CICDAnalytics|Shared runner usage')">
<shared-runners-usage />
</gl-tab>
<template v-if="canViewGroupUsageQuotaBoolean" #tabs-end>
<gl-link :href="pipelineGroupUsageQuotaPath" class="gl-align-self-center gl-ml-auto">{{
__('View group pipeline usage quota')
......
<script>
import { GlIcon, GlPopover } from '@gitlab/ui';
import { GlAreaChart } from '@gitlab/ui/dist/charts';
import { formatDate } from '~/lib/utils/datetime_utility';
import { TYPE_GROUP } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils';
import { s__, __ } from '~/locale';
import { formatWithUtc } from '../constants';
import getCiMinutesUsageByNamespace from '../graphql/ci_minutes.query.graphql';
const timeFormatter = (val) => val;
export default {
components: {
GlIcon,
GlPopover,
GlAreaChart,
},
i18n: {
sharedRunnersUsage: s__('CICDAnalytics|Shared Runners Usage'),
xAxisLabel: __('Month'),
yAxisLabel: __('Minutes'),
seriesName: s__('CICDAnalytics|Shared runner pipeline minute duration by month'),
},
popoverOptions: {
triggers: 'hover',
placement: 'top',
content: s__(
'CICDAnalytics|Shared runner usage is the total runtime of all jobs that ran on shared runners',
),
title: s__('CICDAnalytics|What is shared runner usage?'),
},
inject: ['groupId'],
data() {
return {
ciMinutesUsage: [],
};
},
apollo: {
ciMinutesUsage: {
query: getCiMinutesUsageByNamespace,
variables() {
return {
namespaceId: convertToGraphQLId(TYPE_GROUP, this.groupId),
};
},
update(res) {
return res?.ciMinutesUsage?.nodes;
},
},
},
computed: {
chartOptions() {
return {
xAxis: {
name: this.$options.i18n.xAxisLabel,
type: 'category',
},
yAxis: {
name: this.$options.i18n.yAxisLabel,
axisLabel: {
formatter: timeFormatter,
},
},
};
},
minutesUsageDataByMonth() {
return this.ciMinutesUsage
.slice()
.sort((a, b) => {
return new Date(a.monthIso8601) - new Date(b.monthIso8601);
})
.map((cur) => [
formatDate(cur.monthIso8601, 'mmm yyyy', formatWithUtc),
parseFloat((cur.sharedRunnersDuration / 60).toFixed(2)),
]);
},
isDataEmpty() {
return this.minutesUsageDataByMonth.length === 0;
},
chartData() {
return [
{
data: this.minutesUsageDataByMonth,
name: this.$options.i18n.seriesName,
},
];
},
},
};
</script>
<template>
<div class="gl-mt-4">
<div class="gl-display-flex gl-align-items-center gl-mb-4">
<div class="gl-display-flex">
<h3 class="gl-mr-2 gl-my-0">{{ $options.i18n.sharedRunnersUsage }}</h3>
</div>
<div id="shared-runner-message-popover-container" class="gl-display-flex">
<span id="shared-runner-question">
<gl-icon class="gl-text-blue-500" name="question-o" />
</span>
<gl-popover
target="shared-runner-question"
container="shared-runner-message-popover-container"
v-bind="$options.popoverOptions"
/>
</div>
</div>
<gl-area-chart
v-if="!isDataEmpty"
:data="chartData"
:option="chartOptions"
:width="0"
responsive
/>
</div>
</template>
......@@ -3,7 +3,6 @@ import { merge } from 'lodash';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import CiCdAnalyticsApp from 'ee/analytics/group_ci_cd_analytics/components/app.vue';
import ReleaseStatsCard from 'ee/analytics/group_ci_cd_analytics/components/release_stats_card.vue';
import SharedRunnersUsage from 'ee/analytics/group_ci_cd_analytics/components/shared_runner_usage.vue';
import DeploymentFrequencyCharts from 'ee/dora/components/deployment_frequency_charts.vue';
import LeadTimeCharts from 'ee/dora/components/lead_time_charts.vue';
import TimeToRestoreServiceCharts from 'ee/dora/components/time_to_restore_service_charts.vue';
......@@ -58,7 +57,6 @@ describe('ee/analytics/group_ci_cd_analytics/components/app.vue', () => {
'Lead time',
'Time to restore service',
'Change failure rate',
'Shared runner usage',
].forEach((tabName, index) => {
expect(findGlTabAtIndex(index).attributes('title')).toBe(tabName);
});
......@@ -97,10 +95,6 @@ describe('ee/analytics/group_ci_cd_analytics/components/app.vue', () => {
expect(wrapper.findComponent(ReleaseStatsCard).exists()).toBe(true);
});
it('renders the shared runner usage component', () => {
expect(wrapper.findComponent(SharedRunnersUsage).exists()).toBe(true);
});
it('does not render the DORA chart components', () => {
expect(wrapper.findComponent(DeploymentFrequencyCharts).exists()).toBe(false);
expect(wrapper.findComponent(LeadTimeCharts).exists()).toBe(false);
......
......@@ -11,36 +11,3 @@ export const groupReleaseStatsQueryResponse = {
},
},
};
export const ciMinutesUsageNamespace = {
data: {
ciMinutesUsage: {
nodes: [
{
month: 'December',
monthIso8601: '2021-12-01',
sharedRunnersDuration: 110,
__typename: 'CiMinutesNamespaceMonthlyUsage',
},
{
month: 'November',
monthIso8601: '2021-11-01',
sharedRunnersDuration: 95,
__typename: 'CiMinutesNamespaceMonthlyUsage',
},
{
month: 'October',
monthIso8601: '2021-10-01',
sharedRunnersDuration: 85,
__typename: 'CiMinutesNamespaceMonthlyUsage',
},
{
month: 'September',
monthIso8601: '2021-09-01',
sharedRunnersDuration: 85,
__typename: 'CiMinutesNamespaceMonthlyUsage',
},
],
},
},
};
import timezoneMock from 'timezone-mock';
import { GlAreaChart } from '@gitlab/ui/dist/charts';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import VueApollo from 'vue-apollo';
import SharedRunnerUsage from 'ee/analytics/group_ci_cd_analytics/components/shared_runner_usage.vue';
import getCiMinutesUsageByNamespace from 'ee/analytics/group_ci_cd_analytics/graphql/ci_minutes.query.graphql';
import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
import { ciMinutesUsageNamespace } from './mock_data';
const localVue = createLocalVue();
localVue.use(VueApollo);
describe('Shared runner usage tab', () => {
let wrapper;
const createComponent = ({ isLoading = false, options } = {}) => {
const mockApolloLoading = {
mocks: {
$apollo: {
queries: {
ciMinutesUsage: {
loading: isLoading,
},
},
},
},
};
const mock = options?.apolloProvider ? {} : mockApolloLoading;
wrapper = shallowMount(SharedRunnerUsage, {
provide: {
groupId: '1',
},
...mock,
...options,
});
};
const createComponentWithApollo = () => {
const ciMinutesMock = jest.fn().mockResolvedValue(ciMinutesUsageNamespace);
const handlers = [[getCiMinutesUsageByNamespace, ciMinutesMock]];
const apolloProvider = createMockApollo(handlers);
createComponent({
options: {
localVue,
apolloProvider,
},
});
};
afterEach(() => {
wrapper.destroy();
});
const findAreaChart = () => wrapper.findComponent(GlAreaChart);
describe('when the data has successfully loaded', () => {
beforeEach(async () => {
createComponentWithApollo();
await waitForPromises();
});
it('should display the chart', () => {
expect(findAreaChart().exists()).toBe(true);
});
it('should contain a responsive attribute for the area chart', () => {
expect(findAreaChart().attributes('responsive')).toBeDefined();
});
});
describe('when the component is loading data', () => {
beforeEach(() => {
createComponent({ isLoading: true });
});
it('should not display the chart', () => {
expect(findAreaChart().exists()).toBe(false);
});
});
describe.each`
timezone
${'Europe/London'}
${'US/Pacific'}
`('when viewing in timezone', ({ timezone }) => {
describe(timezone, () => {
beforeEach(async () => {
timezoneMock.register(timezone);
createComponentWithApollo();
await waitForPromises();
});
afterEach(() => {
timezoneMock.unregister();
});
it('has the right start month', () => {
expect(findAreaChart().props('data')[0].data[0][0]).toEqual('Sep 2021');
});
});
});
});
......@@ -7111,21 +7111,12 @@ msgstr ""
msgid "CICDAnalytics|Releases"
msgstr ""
 
msgid "CICDAnalytics|Shared Runners Usage"
msgstr ""
msgid "CICDAnalytics|Shared runner duration is the total runtime of all jobs that ran on shared runners"
msgstr ""
 
msgid "CICDAnalytics|Shared runner pipeline minute duration by month"
msgstr ""
 
msgid "CICDAnalytics|Shared runner usage"
msgstr ""
msgid "CICDAnalytics|Shared runner usage is the total runtime of all jobs that ran on shared runners"
msgstr ""
msgid "CICDAnalytics|Something went wrong while fetching release statistics"
msgstr ""
 
......@@ -7135,9 +7126,6 @@ msgstr ""
msgid "CICDAnalytics|What is shared runner duration?"
msgstr ""
 
msgid "CICDAnalytics|What is shared runner usage?"
msgstr ""
msgid "CICD|Add a %{base_domain_link_start}base domain%{link_end} to your %{kubernetes_cluster_link_start}Kubernetes cluster%{link_end} for your deployment strategy to work."
msgstr ""
 
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册