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

C#: Pin integration tests to a specific .NET version. #14878

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Nov 22, 2023

This pins most of the integration tests to a specific version of .NET (not the msbuild as this for some reason fails on win2019, when pinned to this specific .NET version - but I will try and pin this when doing the .NET upgrade).

The motivation for doing this are the issues we saw when the runners we updated to also include a newer version of .NET, which caused integration test failures in main and the release branch - we would like to avoid this in the future.

We should also consider to pin the extractor to a specific version of .NET.

Please note that it is not enough to just install a specific dotnet version using the dotnet setup action.
This is from the documentation:
image

@github-actions github-actions bot added the C# label Nov 22, 2023
@michaelnebel michaelnebel force-pushed the csharp/pindotnetinintegrationtests branch from 77ad874 to 3d34bb5 Compare November 23, 2023 08:05
@michaelnebel michaelnebel added the no-change-note-required This PR does not need a change note label Nov 23, 2023
@michaelnebel michaelnebel marked this pull request as ready for review November 23, 2023 09:39
@michaelnebel michaelnebel requested a review from a team as a code owner November 23, 2023 09:39
Copy link
Member

@mbg mbg left a comment

Choose a reason for hiding this comment

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

Makes sense! Thank you for doing this and also writing up your thoughts that went into this approach in the PR description.

@@ -0,0 +1,5 @@
{
"sdk": {
"version": "7.0.102"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add "rollForward": "latestFeature", this would mean that any newer 7.0 variant would be accepted too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer that we concretely pin the version number and not even accept another version with the same feature band to avoid switching to a newer version, when it is installed on the runner. At least for .NET 7 we have around 5 different versions installed and I am uncertain that it is the same across all platforms - so I will prefer that it is completely under our control when a newer version is used even with the same feature band.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm okay with this decision as I don't fully understand the problem that we're solving. Is it that previously the latest 7.0.x version of the SDK was used, while now it's the latest 8.0.x version? (Unless we somehow force the usage of a 7.0.x variant, which this PR is doing.)

I think version 7.0.102 is the version that we're installing to the runners. The default installed variants seem to depend on the OS image. So if we were to upgrade our jobs to use 7.0.404, then we would have to update all the tests too, wouldn't we?

Copy link
Member

Choose a reason for hiding this comment

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

Answering for @michaelnebel, but I think the problem we are solving with this is the general case of what you are describing. When the GHA images get updated to a new .NET version, but we do not yet support that .NET version, then this may cause widespread test failures throughout not just the main branch, but also rc branches etc. (as we have seen with the recent .NET 8 release). Pinning the version guarantees that there's a match between the version that the tests are designed for in a given branch and the version of .NET that is used there.

I think your point about not necessarily having the right version installed, depending on the runner image, is a valid one. Perhaps we should add setup-dotnet steps with the same version, just to be sure.

For Go, we do allow the patch version to differ (i.e. we have it pinned to 1.21.x right now for any x). I think it is probably OK to similarly pin .NET to 7.0.x since we wouldn't expect patch-level releases to introduce any breaking changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tamasvajk : Yes, our CI has used the most recent installed SDK (which meant 7.0.404) until 8.0.100 was installed - then this was used by default.
The reason why I picked 7.0.102 is because that is the one we are installing on the runners as a part of setup-dotnet - so to make it consistent I picked that (I could also have forced the installation of the newer version). The .NET version has just changed gradually over time during the last year as newer versions of .NET became available on the runners.
Also, I don't think we should be to concerned whether we pick 7.0.102 or 7.0.404 for this change as the version number will change again as part of the .NET 8 update PR(s) and be pinned to a .NET 8 versions.

@@ -0,0 +1,5 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we put a single global.json file to csharp/ql/integration-tests/?

The docs say:

The .NET SDK looks for a global.json file in the current working directory (which isn't necessarily the same as the project directory) or one of its parent directories.

Copy link
Member

Choose a reason for hiding this comment

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

Seems like that would be worth trying to see if it works as expected. That would mean we'd only need to update the version in one place since we can point setup-dotnet at that file as well (see https://github.com/actions/setup-dotnet#using-the-global-json-file-input) if we choose to add an explicit step for that.

Copy link
Contributor

@tamasvajk tamasvajk Nov 24, 2023

Choose a reason for hiding this comment

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

I think our workflow generator already adds such a step: https://github.com/github/semmle-code/actions/runs/6967032126/job/18958211361#step:20:1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will try and add it directly to the integration test directory and see if it works (there might be some issues with relying on the upwards search as the integration tests are copied before executed and I don't know what happens to the content of the parent folder (the integration-tests directory itself)). There are some folders where a different .NET version is hardcoded (eg. for msbuild). Will keep it on test level.
Will also take a look at the workflow generation script and see.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will not be able to use a global.json file for all workflow descriptions. Should we put in an effort to use the global.json files in some cases? If we should do so it will be a PR in semmle-code and not anything we can do as a part of this PR.

Copy link
Member

Choose a reason for hiding this comment

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

We will not be able to use a global.json file for all workflow descriptions.

What's the reason for that? A limitation of the workflow generator or something else?

@michaelnebel michaelnebel force-pushed the csharp/pindotnetinintegrationtests branch from 3d34bb5 to d1c4e77 Compare November 27, 2023 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants