Skip to content

Commit

Permalink
Merge branch 'main' into add-yamllint
Browse files Browse the repository at this point in the history
  • Loading branch information
mowies authored Jul 1, 2024
2 parents 9bc8e3c + 4c69afa commit a4bea41
Show file tree
Hide file tree
Showing 472 changed files with 1,041 additions and 1,273 deletions.
12 changes: 7 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
Fixes #.
Fixes #
Design discussion issue #

## Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:
## Merge requirement checklist

* [ ] Appropriate `CHANGELOG.md` updated for non-trivial changes
* [ ] Design discussion issue #
* [ ] Changes in public API reviewed
* [ ] [CONTRIBUTING](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/main/CONTRIBUTING.md) guidelines followed (license requirements, nullable enabled, static analysis, etc.)
* [ ] Unit tests added/updated
* [ ] Appropriate `CHANGELOG.md` files updated for non-trivial changes
* [ ] Changes in public API reviewed (if applicable)
1 change: 1 addition & 0 deletions .github/workflows/core-version-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
with:
ref: ${{ github.event.repository.default_branch }}
token: ${{ secrets[needs.automation.outputs.token-secret-name] }}

- name: Setup dotnet
uses: actions/setup-dotnet@v4

Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
-gitRepository '${{ github.repository }}' `
-component '${{ inputs.component }}' `
-version '${{ inputs.version }}' `
-requestedByUserName '${{ github.event.sender.login }}' `
-targetBranch '${{ github.ref_name }}' `
-gitUserName '${{ needs.automation.outputs.username }}' `
-gitUserEmail '${{ needs.automation.outputs.email }}'
Expand Down Expand Up @@ -166,3 +167,43 @@ jobs:
-botUserName '${{ needs.automation.outputs.username }}' `
-gitUserName '${{ needs.automation.outputs.username }}' `
-gitUserEmail '${{ needs.automation.outputs.email }}'
update-changelog-release-dates-on-prepare-pr-post-notice:
runs-on: ubuntu-latest

needs: automation

if: |
github.event_name == 'issue_comment'
&& github.event.issue.pull_request
&& github.event.issue.state == 'open'
&& github.event.comment.user.login != needs.automation.outputs.username
&& contains(github.event.comment.body, '/UpdateReleaseDates')
&& startsWith(github.event.issue.title, '[release] Prepare release ')
&& github.event.issue.pull_request.merged_at == null
&& needs.automation.outputs.enabled
env:
GH_TOKEN: ${{ secrets[needs.automation.outputs.token-secret-name] }}

steps:
- name: check out code
uses: actions/checkout@v4
with:
# Note: By default GitHub only fetches 1 commit which fails the git tag operation below
fetch-depth: 0
token: ${{ secrets[needs.automation.outputs.token-secret-name] }}

- name: Update release date
id: create-tag
shell: pwsh
run: |
Import-Module .\build\scripts\prepare-release.psm1
UpdateChangelogReleaseDatesAndPostNoticeOnPullRequest `
-gitRepository '${{ github.repository }}' `
-pullRequestNumber '${{ github.event.issue.number }}' `
-botUserName '${{ needs.automation.outputs.username }}' `
-commentUserName '${{ github.event.comment.user.login }}' `
-gitUserName '${{ needs.automation.outputs.username }}' `
-gitUserEmail '${{ needs.automation.outputs.email }}'
3 changes: 2 additions & 1 deletion build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AnalysisLevel>latest-all</AnalysisLevel>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
Expand All @@ -38,7 +39,7 @@
<MicrosoftOwinPkgVer>[4.2.2,5.0)</MicrosoftOwinPkgVer>
<MicrosoftPublicApiAnalyzersPkgVer>[3.11.0-beta1.23525.2]</MicrosoftPublicApiAnalyzersPkgVer>
<MicrosoftSourceLinkGitHubPkgVer>[8.0.0,9.0)</MicrosoftSourceLinkGitHubPkgVer>
<OpenTelemetryCoreUnstableLatestVersion>[1.9.0-beta.1]</OpenTelemetryCoreUnstableLatestVersion>
<OpenTelemetryCoreUnstableLatestVersion>[1.9.0-beta.2]</OpenTelemetryCoreUnstableLatestVersion>
<OpenTelemetryCoreLatestVersion>[1.9.0,2.0)</OpenTelemetryCoreLatestVersion>
<OpenTelemetryCoreLatestPrereleaseVersion>[1.9.0-rc.1]</OpenTelemetryCoreLatestPrereleaseVersion>
<StackExchangeRedisPkgVer>[2.1.58,3.0)</StackExchangeRedisPkgVer>
Expand Down
34 changes: 17 additions & 17 deletions build/scripts/post-release.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,25 @@ function CreateOpenTelemetryCoreLatestVersionUpdatePullRequest {
Return
}

$projectsAndDependenciesBefore = GetCoreDependenciesForProjects

$branch="release/post-core-${version}-update"

if ([string]::IsNullOrEmpty($gitUserName) -eq $false)
{
git config user.name $gitUserName
}
if ([string]::IsNullOrEmpty($gitUserEmail) -eq $false)
{
git config user.email $gitUserEmail
}

git switch --create $branch origin/$targetBranch --no-track 2>&1 | % ToString
if ($LASTEXITCODE -gt 0)
{
throw 'git switch failure'
}

$projectsAndDependenciesBefore = GetCoreDependenciesForProjects

(Get-Content build/Common.props) `
-replace "<$propertyName>.*<\/$propertyName>", "<$propertyName>$propertyVersion</$propertyName>" |
Set-Content build/Common.props
Expand All @@ -328,21 +343,6 @@ function CreateOpenTelemetryCoreLatestVersionUpdatePullRequest {
}
}

if ([string]::IsNullOrEmpty($gitUserName) -eq $false)
{
git config user.name $gitUserName
}
if ([string]::IsNullOrEmpty($gitUserEmail) -eq $false)
{
git config user.email $gitUserEmail
}

git switch --create $branch origin/$targetBranch --no-track 2>&1 | % ToString
if ($LASTEXITCODE -gt 0)
{
throw 'git switch failure'
}

git add build/Common.props 2>&1 | % ToString
if ($LASTEXITCODE -gt 0)
{
Expand Down
121 changes: 121 additions & 0 deletions build/scripts/prepare-release.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@ function CreatePullRequestToUpdateChangelogsAndPublicApis {
[Parameter(Mandatory=$true)][string]$gitRepository,
[Parameter(Mandatory=$true)][string]$component,
[Parameter(Mandatory=$true)][string]$version,
[Parameter(Mandatory=$true)][string]$requestedByUserName,
[Parameter()][string]$targetBranch="main",
[Parameter()][string]$gitUserName,
[Parameter()][string]$gitUserEmail
)

$match = [regex]::Match($version, '^(\d+\.\d+\.\d+)(?:-((?:alpha)|(?:beta)|(?:rc))\.(\d+))?$')
if ($match.Success -eq $false)
{
throw 'Input version did not match expected format'
}

$projectContent = Get-Content -Path src/$component/$component.csproj

$match = [regex]::Match($projectContent, '<MinVerTagPrefix>(.*)<\/MinVerTagPrefix>')
Expand Down Expand Up @@ -39,6 +46,8 @@ function CreatePullRequestToUpdateChangelogsAndPublicApis {
@"
Note: This PR was opened automatically by the [prepare release workflow](https://github.com/$gitRepository/actions/workflows/prepare-release.yml).
Requested by: @$requestedByUserName
## Changes
* CHANGELOG files updated for projects being released.
Expand All @@ -55,6 +64,15 @@ Note: This PR was opened automatically by the [prepare release workflow](https:/
$body += "`r`n* Public API files updated for projects being released (only performed for stable releases)."
}

$body +=
@"
## Commands
``/UpdateReleaseDates``: Use to update release dates in CHANGELOGs before merging [``approvers``, ``maintainers``]
``/CreateReleaseTag``: Use after merging to push the release tag and trigger the job to create packages and push to NuGet [``approvers``, ``maintainers``]
"@

git commit -a -m "Prepare repo to release $tag." 2>&1 | % ToString
if ($LASTEXITCODE -gt 0)
{
Expand Down Expand Up @@ -183,3 +201,106 @@ The [package workflow](https://github.com/$gitRepository/actions/workflows/publi
}

Export-ModuleMember -Function CreateReleaseTagAndPostNoticeOnPullRequest

function UpdateChangelogReleaseDatesAndPostNoticeOnPullRequest {
param(
[Parameter(Mandatory=$true)][string]$gitRepository,
[Parameter(Mandatory=$true)][string]$pullRequestNumber,
[Parameter(Mandatory=$true)][string]$botUserName,
[Parameter(Mandatory=$true)][string]$commentUserName,
[Parameter()][string]$gitUserName,
[Parameter()][string]$gitUserEmail
)

$prViewResponse = gh pr view $pullRequestNumber --json headRefName,author,title | ConvertFrom-Json

if ($prViewResponse.author.login -ne $botUserName)
{
throw 'PR author was unexpected'
}

$match = [regex]::Match($prViewResponse.title, '^\[release\] Prepare release (.*)$')
if ($match.Success -eq $false)
{
throw 'Could not parse tag from PR title'
}

$tag = $match.Groups[1].Value

$match = [regex]::Match($tag, '^(.*?-)(.*)$')
if ($match.Success -eq $false)
{
throw 'Could not parse prefix or version from tag'
}

$tagPrefix = $match.Groups[1].Value
$version = $match.Groups[2].Value

$commentUserPermission = gh api "repos/$gitRepository/collaborators/$commentUserName/permission" | ConvertFrom-Json
if ($commentUserPermission.permission -ne 'admin' -and $commentUserPermission.permission -ne 'write')
{
gh pr comment $pullRequestNumber `
--body "I'm sorry @$commentUserName but you don't have permission to update this PR. Only maintainers and approvers can update this PR."
return
}

if ([string]::IsNullOrEmpty($gitUserName) -eq $false)
{
git config user.name $gitUserName
}
if ([string]::IsNullOrEmpty($gitUserEmail) -eq $false)
{
git config user.email $gitUserEmail
}

git switch $prViewResponse.headRefName 2>&1 | % ToString
if ($LASTEXITCODE -gt 0)
{
throw 'git switch failure'
}

$updatedFiles = 0
$newHeader =
@"
## $version
Released $(Get-Date -UFormat '%Y-%b-%d')
"@

$projectDirs = Get-ChildItem -Path src/**/*.csproj | Select-String "<MinVerTagPrefix>$tagPrefix</MinVerTagPrefix>" -List | Select Path | Split-Path -Parent

foreach ($projectDir in $projectDirs)
{
$content = (Get-Content "$projectDir/CHANGELOG.md" -Raw)

$newContent = $content -replace "## $version\s*Released .*", $newHeader

if ($content -ne $newContent)
{
$updatedFiles++
Set-Content -Path "$projectDir/CHANGELOG.md" $newContent.Trim()
}
}

if ($updatedFiles -eq 0)
{
gh pr comment $pullRequestNumber --body "All of the CHANGELOG files have valid release dates."
return
}

git commit -a -m "Update CHANGELOG release dates for $tag." 2>&1 | % ToString
if ($LASTEXITCODE -gt 0)
{
throw 'git commit failure'
}

git push -u origin $prViewResponse.headRefName 2>&1 | % ToString
if ($LASTEXITCODE -gt 0)
{
throw 'git push failure'
}

gh pr comment $pullRequestNumber --body "I updated the CHANGELOG release dates."
}

Export-ModuleMember -Function UpdateChangelogReleaseDatesAndPostNoticeOnPullRequest
4 changes: 0 additions & 4 deletions examples/AspNet/Controllers/WeatherForecastController.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.Threading.Tasks;
using System.Web.Http;
using Examples.AspNet.Models;
using OpenTelemetry;
Expand Down
1 change: 0 additions & 1 deletion examples/AspNet/Global.asax.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System;
using System.Configuration;
using System.Web;
using System.Web.Http;
Expand Down
2 changes: 0 additions & 2 deletions examples/AspNet/Models/WeatherForecast.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System;

namespace Examples.AspNet.Models;

public class WeatherForecast
Expand Down
1 change: 0 additions & 1 deletion examples/AspNet/SuppressInstrumentationHttpModule.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System;
using System.Web;
using OpenTelemetry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Examples.InfluxDB</RootNamespace>
</PropertyGroup>

Expand Down
3 changes: 0 additions & 3 deletions examples/enrichment/Examples.Enrichment/MyService.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System;
using System.Collections.Generic;

namespace Examples.Enrichment;

internal sealed class MyService : IMyService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace Examples.GrpcCore.AspNetCore.Controllers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System.Threading.Tasks;
using Grpc.Core;

namespace Examples.GrpcCore.AspNetCore;
Expand Down
3 changes: 0 additions & 3 deletions examples/grpc.core/Examples.GrpcCore.AspNetCore/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace Examples.GrpcCore.AspNetCore;

public class Program
Expand Down
Loading

0 comments on commit a4bea41

Please sign in to comment.