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

[CI] Enumerate test projects at build time for PR validation #7842

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

Conversation

radical
Copy link
Member

@radical radical commented Mar 1, 2025

No description provided.

@@ -0,0 +1,43 @@
<Project DefaultTargets="GenerateTestProjectsJsonForGithubActions">
Copy link
Member

Choose a reason for hiding this comment

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

I think I would much rather have this expressed in yaml and than in msbuild.

Copy link
Member Author

Choose a reason for hiding this comment

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

Having it in msbuild allows us to control at the .csproj level whether to skip the tests, though that might not be a common scenario.

I was trying to do all this in yaml, but generating the json for the matrix was a pain. But I do have the code simplified now, so that json is simpler too, and we can try yaml.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm keeping it in msbuild though means that we are sharing the same rules for helix, and for gh actions, which would keep that consistent.

Copy link
Member

Choose a reason for hiding this comment

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

I hear you, but, copilot is kinda crap at writing msbuild and it's amazing at writing yaml. When I look at our csproj files wrapping shell commands its quite unmaintainable. This yaml file is long but very clean and really easy to understand. Maybe this is a fine middle ground but it feels really messy to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

By "shell commands" do you mean the json being emitted to the file? I should be able to get that out of this project, then it would just be evaluating all the msbuild projects to find the ones that should be built.

The alternative would be to pick up the test projects with globbing, and keeping an exclude list in the yaml.

Copy link
Member

Choose a reason for hiding this comment

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

My bias is David's, an exclude list in the yaml sounds good. I like simple. (If we don't care about Helix)

Copy link
Member

Choose a reason for hiding this comment

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

I don't have a strong opinion here, but this would have helped me avoid breaking the build last week when I added Aspire.Cli.

I know that the Azure SDK uses this to great effect to enable more elaborate integration testing scenarios.

One thing where this matrix generation capability would be useful is in running the same set of tests across both Docker AND Podman container runtimes pretty easily.

But I don't have a strong opinion.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should dynamically generate the list, I am just having a hard time having that logic be in msbuild 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to stick with msbuild because:

  • one way to control which tests get skipped by helix/gh-actions, OS, and docker/podman .
  • All the build context is in msbuild, for deciding when to skip some tests.

For example, PR validation would catch a case where you should disable some test, but a change in the yaml won't cause the same test to get skipped on helix. And it would trigger a pipeline failure, then an issue being opened, and then the whole thing being fixed.

BUT if we really want it in yaml, then I can make that change too :)

Copy link
Member

@davidfowl davidfowl Mar 4, 2025

Choose a reason for hiding this comment

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

Agree msbuild > python (well only in .NET land). I wouldn't mind if we could move off helix altogether 😄

@radical radical mentioned this pull request Mar 3, 2025
5 tasks
Copy link
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

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

LGTM. Don't have a strong opinion on MSBuild - but trust your judgement on the engineering system side.

@radical radical added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Mar 3, 2025
@radical
Copy link
Member Author

radical commented Mar 3, 2025

Taking a hybrid route:

  1. Get the list of projects from msbuild
  2. Build the matrix json for github actions (not needed for helix at all) to the yaml

@radical radical force-pushed the enumerate-tests-prs branch 2 times, most recently from 2e81eb9 to 1414c25 Compare March 4, 2025 02:00
- Move core steps to run the tests to a new reusable workflow
  `run-tests.yml`
- Generate the list of test projects using the new
  `tests/Shared/GetTestProjects.proj`
- Generate the test matrix json using `generate_test_matrix_json.py`
  and write it to `$GITHUB_OUTPUT`

- Adjust `tests.yml` to essentially use `run-tests.yml` to run the test
  matrix generated above

- Also, introduce a new property to control running tests on github
  actions `$(RunTestsOnGithubActions)`.
@radical radical force-pushed the enumerate-tests-prs branch from 1414c25 to 2519b38 Compare March 4, 2025 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants