Skip to content
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

Update automatic labelling #2494

Open
wants to merge 1 commit into
base: master
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
10 changes: 7 additions & 3 deletions .github/labeller.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
labels:
- name: "ci"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: "ci"
- name: "build"

allFilesIn: "(dockerfiles\/ci\/.*|.circleci\/.*|.github\/.*|.gitlab\/.*|benchmark\/.*|github-actions-helpers\/.*|docker-compose.yml)"
stopIfMatch: true

- name: "area:asm"
title: "^\\[?(?i)ASM"

- name: "area:asm"
allFilesIn: "(appsec\/.*|docker-compose.yml|.*\/.circleci\/.*)"
allFilesIn: "(appsec\/.*|docker-compose.yml|.circleci\/.*)"
Copy link
Collaborator

@bwoebi bwoebi Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we also match docker-compose & .circleci here (and below) if it's already stopIfMatch for ci?


- name: "profiling"
title: "^.*\\(profiler\\)"
Expand All @@ -12,7 +16,7 @@ labels:
title: "^.*\\(profiling\\)"

- name: "profiling"
allFilesIn: "(profiling\/.*|docker-compose.yml|.*\/.circleci\/.*)"
allFilesIn: "(profiling\/.*|docker-compose.yml|.circleci\/.*)"

- name: "tracing"
title: "^\\[?(?i)tracer"
Expand All @@ -21,4 +25,4 @@ labels:
title: "^\\[?(?i)tracing"

- name: "tracing"
allFilesIn: "(.*\/ext\/.*|.*\/src\/.*|.*\/tests\/.*|.*\/zend_abstract_interface\/.*|docker-compose.yml|.*\/.circleci\/.*)"
allFilesIn: "(ext\/.*|src\/.*|tests\/.*|zend_abstract_interface\/.*|docker-compose.yml|.circleci\/.*)"
10 changes: 9 additions & 1 deletion github-actions-helpers/Build.Github.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ async Task HideCommentsInPullRequest(int prNumber, string prefix)
// Fixes an issue (ambiguous argument) when we do git diff in the Action.
GitTasks.Git("fetch origin master:master", logOutput: false);
var changedFiles = GitTasks.Git("diff --name-only master").Select(f => f.Text);

var config = GetLabellerConfiguration();
Console.WriteLine($"Checking labels for PR {PullRequestNumber}");

Expand Down Expand Up @@ -319,16 +320,22 @@ HashSet<String> ComputeLabels(LabbelerConfiguration config, string prTitle, IEnu
{
Console.WriteLine("Yes it does. Adding label " + label.Name);
updatedLabels.Add(label.Name);
if (label.StopIfMatch) {
break;
}
}
}
else if (!string.IsNullOrEmpty(label.AllFilesIn))
{
Console.WriteLine("Checking if changed files are all located in:" + label.AllFilesIn);
var regex = new Regex(label.AllFilesIn, RegexOptions.Compiled);
if(!changedFiles.Any(x => !regex.IsMatch(x)))
if(changedFiles.All(x => regex.IsMatch(x)))
{
Console.WriteLine("Yes they do. Adding label " + label.Name);
updatedLabels.Add(label.Name);
if (label.StopIfMatch) {
break;
}
}
}
}
Expand Down Expand Up @@ -419,6 +426,7 @@ public class Label
public string Name { get; set; }
public string Title { get; set; }
public string AllFilesIn { get; set; }
public bool StopIfMatch { get; set; }
}
}
}
Loading