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

Fix dependabot and improve GeneratePackageVersions #5579

Merged
merged 6 commits into from
May 17, 2024
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
16 changes: 15 additions & 1 deletion .github/workflows/auto_bump_test_package_versions.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: Auto bump test package versions

on:
schedule:
- cron: '0 0 * * 0' # Every Sunday at midnight
pull_request_target:
branches: [master, main]
workflow_dispatch:

jobs:
bump_package_versions:
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.pull_request.head.ref, 'dependabot/nuget/tracer/dependabot/') == true
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || startsWith(github.event.pull_request.head.ref, 'dependabot/nuget/tracer/dependabot/') == true
runs-on: windows-latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
Expand Down Expand Up @@ -42,3 +44,15 @@ jobs:
reviewers: "DataDog/apm-dotnet"
body: |
Updates the package versions for integration tests.

- name: Send Slack notification about generating failure
if: failure()
uses: slackapi/slack-github-action@v1.26.0
with:
# This data can be any valid JSON from a previous step in the GitHub Action
payload: |
{
"github_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBOOK_URL_GENERATEPACKAGEVERSIONS }}
6 changes: 6 additions & 0 deletions tracer/build/_build/Build.Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ partial class Build

var outputPath = TracerDirectory / "build" / "supported_versions.json";
await GenerateSupportMatrix.GenerateInstrumentationSupportMatrix(outputPath, distinctIntegrations);

Logger.Information("Verifying that updated dependabot file is valid...");

var tempProjectFile = TempDirectory / "dependabot_test" / "Project.csproj";
CopyFile(dependabotProj, tempProjectFile, FileExistsPolicy.Overwrite);
DotNetRestore(x => x.SetProjectFile(tempProjectFile));
});

Target GenerateSpanDocumentation => _ => _
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<RootNamespace>Datadog.Dependabot.Honeypot</RootNamespace>
</PropertyGroup>

Expand Down
21 changes: 15 additions & 6 deletions tracer/build/_build/Honeypot/DependabotFileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,25 @@ public static void UpdateVendors(AbsolutePath honeypotProject)
public static Task UpdateIntegrations(AbsolutePath honeypotProject, List<IntegrationMap> distinctIntegrations)
{
var fakeRefs = string.Empty;

foreach (var integration in distinctIntegrations)

// have to group by packages so we don't have duplicate package references
// so reverse the dependencies here
var integrationsByPackageName = distinctIntegrations
.SelectMany(integration => integration.Packages.Select(package => (integration, package)))
.GroupBy(x => x.package)
.OrderBy(x => x.Key.NugetName);

foreach (var packageNameGroup in integrationsByPackageName)
{
foreach (var package in integration.Packages)
var package = packageNameGroup.Key;
foreach (var (integration, _) in packageNameGroup.OrderBy(x => x.integration.Name))
{
fakeRefs += $@"{Environment.NewLine} <!-- Integration: {integration.Name} -->";
fakeRefs += $@"{Environment.NewLine} <!-- Assembly: {integration.AssemblyName} -->";
fakeRefs += $@"{Environment.NewLine} <!-- Latest package https://www.nuget.org/packages/{package.NugetName}/{package.LatestVersion} -->";
fakeRefs += $@"{Environment.NewLine} <PackageReference Include=""{package.NugetName}"" Version=""{package.LatestTestedVersion ?? package.LatestSupportedVersion}"" />{Environment.NewLine}";
fakeRefs += $@"{Environment.NewLine} <!-- Assembly: {integration.AssemblyName} -->";
}

fakeRefs += $@"{Environment.NewLine} <!-- Latest package https://www.nuget.org/packages/{package.NugetName}/{package.LatestVersion} -->";
fakeRefs += $@"{Environment.NewLine} <PackageReference Include=""{package.NugetName}"" Version=""{package.LatestTestedVersion ?? package.LatestSupportedVersion}"" />{Environment.NewLine}";
}

var honeypotProjTemplate = GetHoneyPotProjTemplate();
Expand Down
Loading
Loading