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

feat: allow repos to be ignored by dep graph integrator #1364

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tjsilver
Copy link
Contributor

@tjsilver tjsilver commented Dec 23, 2024

What does this change?

  • Adds a property to config for repos to be ignored by dependency graph integrator, by language (Scala or Kotlin).
  • Adds a function to test a repo to see if it's in the ignored list.
  • Adds a test for this function.

Why?

There is at least one edge case where a repo contains a dependency graph integrator language, but that doesn't use sbt (it contains just one Scala file which is used in a script). We would like to allow teams to exclude these repos from the integrator so that it doesn't repeatedly raise PRs on those repos.

How has it been verified?

  • Tested locally

@tjsilver tjsilver requested review from a team as code owners December 23, 2024 16:22
Copy link
Contributor

@adamnfish adamnfish left a comment

Choose a reason for hiding this comment

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

Some questions about the test layout, but all looks great to me!

): boolean {
const isIgnored = ignoredRepos[language].includes(repoName);
if (isIgnored) {
logger.log({
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, great log message. This will save us confusion in the future, no doubt!

@@ -178,6 +187,16 @@ describe('When getting suitable events to send to SNS', () => {

expect(result).toEqual(expected);
});
test('return empty array when an ignored Scala repo is found with without an existing workflow', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to bring the definitions for this test nearer the test body? Especially the ignoredRepo const, which I think is only used here! I really like it when tests have the setup, invocation, and assertion together, as much as possible. Where there's shared setup, we can keep that as close as possible to its use by doing that inside a describe block that only contains the tests that use it.

In this case, could we inline the ignore definitions from the top of the file here? No worries if this suggestion doesn't meet the existing style conventions!

@@ -144,6 +149,7 @@ describe('When getting suitable events to send to SNS', () => {
[repoWithTargetLanguage(fullName)],
[repository(fullName)],
[repoWithoutWorkflow(fullName)],
ignoredRepos,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason to pass ignoredRepos here (rather than e.g. empty object)? Like the comment below, this couples these tests to the definitions more than a hundred lines away, even though they don't actually interact.

No worries if this is for consistency 👍

@@ -178,6 +187,16 @@ describe('When getting suitable events to send to SNS', () => {

expect(result).toEqual(expected);
});
test('return empty array when an ignored Scala repo is found with without an existing workflow', () => {
Copy link
Contributor

@adamnfish adamnfish Dec 23, 2024

Choose a reason for hiding this comment

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

It's a minor point, but we aren't checking that filtering works on an array of repos that partially matches the filter - it's all or nothing at the moment. Is that worth adding? And if so, as dicsussed in the other comment, is it worth adding in a describe block that surrounds that test and this 'return empty array ... ' one so that the shared test setup of ignored repos is right here alongside its users?

describe('when repositories are ignored', () => {
  const ignoredRepo = 'guardian/ignore-me';
  const ignoredRepos = {
	Scala: ['ignore-me'],
	Kotlin: [],
  };

  test('return empty array when an ignored Scala repo is found with without an existing workflow', () => {
    // ...
  });

  test('excludes ignored repositories from the result', () => {
    // ... check the partial filter result here
  });
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Also I noticed while making this example that this test name might want a look?:

return empty array when an ignored Scala repo is found with without an existing workflow

@tjsilver tjsilver marked this pull request as draft December 23, 2024 17:11
@@ -58,6 +59,11 @@ export interface Config extends PrismaConfig {
*/
dependencyGraphIntegratorTopic: string;

/**
* A list of repos to be excluded by the dependency graph integrator, by language.
Copy link
Member

Choose a reason for hiding this comment

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

Worth explicitly saying this is a repository's short name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants