Skip to content

Commit

Permalink
* added ignoreTFMs config for packageInfo
Browse files Browse the repository at this point in the history
* fixed bug in creating new PR, probably related to OctoKit major version bump
  • Loading branch information
tippmar-nr committed Jan 15, 2025
1 parent c951f3a commit 9c13a94
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
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; }
}
}
10 changes: 5 additions & 5 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 @@ -242,11 +242,11 @@ static async Task<string> CreateGithubPullRequestForNewVersions(IEnumerable<Proj
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 newBranchRef = await ghClient.Git.Reference.Create(Owner, Repo, newBranch);
Log.Information($"Successfully created {branchName} branch.");

// commit changes to the branch
var latestCommit = await ghClient.Git.Commit.Get(Owner, Repo, masterReference.Object.Sha);
// 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 @@ -261,7 +261,7 @@ static async Task<string> CreateGithubPullRequestForNewVersions(IEnumerable<Proj
}
var commitMessage = "test: Dotty instrumentation library updates for " + DateTime.Now.ToString("yyyy-MMM-dd");
var newTree = await ghClient.Git.Tree.Create(Owner, Repo, nt);
var newCommit = new NewCommit(commitMessage, newTree.Sha, masterReference.Object.Sha);
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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@
"packageName": "nlog.extensions.logging"
},
{
"packageName": "nservicebus"
"packageName": "nservicebus",
"ignoreTFMs": "net481",
"ignoreReason": "net481 doesn't support v9.x"
},
{
"packageName": "oracle.manageddataaccess"
Expand Down

0 comments on commit 9c13a94

Please sign in to comment.