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: Dotty Fixes #2952

Merged
merged 4 commits into from
Jan 15, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public static async Task<List<string>> UpdatePackageReferences(string csprojPath

foreach (var package in matchingPackages)
{
if (package.VersionAsVersion < versionData.NewVersionAsVersion && package.Pin)
if (package.VersionAsVersion < versionData.NewVersionAsVersion && !string.IsNullOrEmpty(versionData.IgnoreTfMs) && versionData.IgnoreTfMs.Split(",").Contains(package.TargetFramework))
{
Log.Warning($"Not updating {package.Include} for {package.TargetFramework}, it is pinned to {package.Version}. Manual verification recommended.");
Log.Warning($"Not updating {package.Include} for {package.TargetFramework}, this TFM is ignored. Manual verification recommended.");
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ public class NugetVersionData
public Version NewVersionAsVersion { get; set; }
public string Url { get; set; }
public DateTime PublishDate { get; set; }
public string IgnoreTfMs { get; }

public NugetVersionData(string packageName, string oldVersion, string newVersion, string url, DateTime publishDate)
public NugetVersionData(string packageName, string oldVersion, string newVersion, string url,
DateTime publishDate, string ignoreTfMs)
{
PackageName = packageName;
OldVersion = oldVersion;
NewVersion = newVersion;
NewVersionAsVersion = new Version(newVersion);
Url = url;
PublishDate = publishDate;
IgnoreTfMs = ignoreTfMs;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ public class PackageInfo
public bool IgnoreMajor { get; set; }
[JsonPropertyName("ignoreReason")]
public string IgnoreReason {get; set;}
[JsonPropertyName("ignoreTFMs")]
public string IgnoreTFMs { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Text.RegularExpressions;
using System.Xml.Serialization;

Expand Down Expand Up @@ -33,8 +33,5 @@ public string TargetFramework
return match.Success ? match.Value : null;
}
}

[XmlAttribute]
public bool Pin { get; set; }
}
}
19 changes: 13 additions & 6 deletions .github/workflows/scripts/nugetSlackNotifications/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static async Task CheckPackage(PackageInfo package, PackageMetadataResource meta
var previousVersionDescription = previous?.Identity.Version.ToNormalizedString() ?? "Unknown";
var latestVersionDescription = latest.Identity.Version.ToNormalizedString();
Log.Information($"Package {packageName} was updated from {previousVersionDescription} to {latestVersionDescription}.");
_newVersions.Add(new NugetVersionData(packageName, previousVersionDescription, latestVersionDescription, latest.PackageDetailsUrl.ToString(), latest.Published.Value.Date));
_newVersions.Add(new NugetVersionData(packageName, previousVersionDescription, latestVersionDescription, latest.PackageDetailsUrl.ToString(), latest.Published.Value.Date, package.IgnoreTFMs));
}
else
{
Expand Down Expand Up @@ -238,11 +238,15 @@ static async Task<string> CreateGithubPullRequestForNewVersions(IEnumerable<Proj
var tokenAuth = new Credentials(_githubToken);
ghClient.Credentials = tokenAuth;

// create a new branch
var masterReference = await ghClient.Git.Reference.Get(Owner, Repo, "heads/main");
var branchName = $"dotty/test-updates-{DateTime.Now.ToString("yyyy-MMM-dd")}";
var newBranch = new NewReference($"refs/heads/{branchName}", masterReference.Object.Sha);
await ghClient.Git.Reference.Create(Owner, Repo, newBranch);
var latestCommit = await ghClient.Git.Commit.Get(Owner, Repo, masterReference.Object.Sha);
var newBranchRef = await ghClient.Git.Reference.Create(Owner, Repo, newBranch);
Log.Information($"Successfully created {branchName} branch.");

// commit changes to the newly created branch
var latestCommit = await ghClient.Git.Commit.Get(Owner, Repo, newBranchRef.Object.Sha);
var nt = new NewTree { BaseTree = latestCommit.Tree.Sha };
foreach (var projectInfo in projectInfos)
{
Expand All @@ -255,12 +259,15 @@ static async Task<string> CreateGithubPullRequestForNewVersions(IEnumerable<Proj
Content = string.Join('\n', await File.ReadAllLinesAsync(Path.Combine(_searchRootPath, projectInfo.ProjectFile)))
});
}

var commitMessage = "test: Dotty instrumentation library updates for " + DateTime.Now.ToString("yyyy-MMM-dd");
Log.Information($"Successfully created {branchName} branch.");
var newTree = await ghClient.Git.Tree.Create(Owner, Repo, nt);
var newCommit = new NewCommit(commitMessage, newTree.Sha, newBranchRef.Object.Sha);
var commit = await ghClient.Git.Commit.Create(Owner, Repo, newCommit);
await ghClient.Git.Reference.Update(Owner, Repo, $"heads/{branchName}", new ReferenceUpdate(commit.Sha));

// create PR
var newPr = new NewPullRequest(commitMessage, branchName, "main");
newPr.Body = "Dotty updated the following for your convenience.\n\n" + updateLog + "\n\n**Don't forget to update the .NET Compatibility docs:docs: with the new versions!**\n";
newPr.Body = "Dotty updated the following for your convenience.\n\n" + updateLog + "\n\n**Don't forget to update the .NET Compatibility docs:memo: with the new versions!**\n";
var pullRequest = await ghClient.PullRequest.Create(Owner, Repo, newPr);
Log.Information($"Successfully created PR for {branchName} at {pullRequest.HtmlUrl}");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@
"packageName": "nlog.extensions.logging"
},
{
"packageName": "nservicebus"
"packageName": "nservicebus",
"ignoreTFMs": "net481",
"ignoreReason": "net481 doesn't support v9.x"
},
{
"packageName": "orcacle.manageddataaccess"
"packageName": "oracle.manageddataaccess"
},
{
"packageName": "orcacle.manageddataaccess.core"
"packageName": "oracle.manageddataaccess.core"
},
{
"packageName": "rabbitmq.client",
Expand Down
Loading