Repository navigation
feat(dora): filter pull requests by source branch pattern in lead time for changes - #9229
Open
chenwei791129 wants to merge 3 commits into
Open
chenwei791129 wants to merge 3 commits into
chenwei791129 wants to merge 3 commits into
Conversation
…e for changes Add a project-level prHeadRefPattern option (Go RE2 regex) to the DORA metric plugin. When set, calculateChangeLeadTime only writes project_pr_metrics rows for merged pull requests whose head_ref matches the pattern; the refs/heads/ prefix is ignored. A blank pattern keeps the current behavior. Invalid patterns fail plan generation with a BadInput error. Refs apache#9222
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a DORA project setting, Source branch pattern (
prHeadRefPattern). When it is set, only merged pull requests whose source branch (pull_requests.head_ref) matches the regex count toward Lead Time for Changes. This lets teams leave out "carrier" PRs such as release or UAT merges, which would otherwise count the same changes twice.ProjectMetricSetting.PluginOption, like linker'sprToIssueRegexpregexp.MatchString. No implicit anchors (write^(feat|fix)/); use(?i)to ignore case; a leadingrefs/heads/is stripped before matchingBadInput(HTTP 400)invalid prHeadRefPatternproject_pr_metricsis affected.pull_requestsis unchanged, so code review dashboards keep all PRsfeat(dora)task_data.go: new option plus compile/match helpers.impl.go: compile inPrepareTaskData;MakeMetricPluginPipelinePlanV200validates early and adds the pattern to thecalculateChangeLeadTimestage only when it is not empty.change_lead_time_calculator.go: skip PRs that do not match and log how many were excludedfeat(config-ui)×2settings-panel.tsx: input, description and help tooltip in the DORA blockDoes this close any open issues?
Closes #9222
Screenshots
Project → Settings, with DORA enabled and the new Source branch pattern field:
Other Information
Compatibility
impl_testis unchanged).deployJobPatternoption. Validating options on save is handled separately by fix(project): validate metric plugin options when saving a project #9228 (for issue [Bug][Project] Invalid metric plugin options are accepted on project save and only fail at the next pipeline run #9227); the two PRs do not depend on each other.calculateChangeLeadTimedeletes the project's old rows first, so no stale rows are left behind.Related issues and PRs
project_pr_metricsrow as 0 hours, so those panels read low once a pattern is set. DORA dashboards are not affectedaccountstable on a fresh database (pre-existing)Docs: apache/devlake-website#836 (draft until this PR is merged) documents the option in
docs/Metrics/LeadTimeForChanges.md, with links fromdocs/DORA.mdanddocs/Metrics/PRCycleTime.md.Tests
Automated
go build,go vet,gofmt -l,golangci-lint run ./plugins/dora/...go test ./plugins/dora/...incl. e2e (MySQL 8.4)excluded 4 of 7 merged pull requeststask_data_test.go(?i),refs/heads/prefix, emptyhead_refimpl_test.goBadInput,PrepareTaskDatadecodingtscclean; eslint shows only 2 existing prettier warnings on untouched linesManual, against a self-hosted GitLab
The same commits, backported to v1.0.3-beta15 (only import paths differ), were deployed and tested with real data. Two test repos each got 10 MRs: 9 merged, 1 left open. Every merge to
mainran a dummy production deploy job.After each pattern change I ran a Re-transform (no recollection) and checked
project_pr_metrics, the pipeline log and Grafana.^(feat|fix)/^(feat|fix|hotfix)/(?i)^(feat|fix)/feat/alpha,fix/betahotfix/epsilonFEAT/deltachore/gamma,release-uat,my-feat/zetafeat/open(not merged)excluded M of N^(feat|fix)/feat/alpha,fix/beta^(feat|fix|hotfix)/hotfix/epsilon(?i)^(feat|fix)/FEAT/delta, dropshotfix^(feat|fixinvalid prHeadRefPatternand no pipeline is created^nothing-matches/)feat/etaandchore/thetafeat/etaaddedAlso confirmed:
prHeadRefPatternonly in thecalculateChangeLeadTimestage, and leaves the key out when it is not set.pr_deploy_time.Grafana, with A set to
^(feat|fix)/:Pre-existing issues seen during testing (not caused by this PR):
Convert MR Commitsruns beforeExtract MR Commitspr_coding_timeis NULL; the next pipeline fills it in. Happens with or without a pattern, including in the control project