From cdaa35a52c9049ee6764ff0df8e5ee4b7b1cd6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Fri, 29 Sep 2023 10:56:05 +0200 Subject: [PATCH 1/5] Automate script versioning --- .github/workflows/build.yml | 8 ++++++- .github/workflows/release-publish.yml | 6 ++--- .github/workflows/release.yml | 2 ++ build/Build.InstallationScripts.Steps.cs | 23 +++++++++++++++++++ build/Build.Steps.Windows.cs | 3 ++- build/Build.cs | 1 + docs/releasing.md | 2 -- docs/troubleshooting.md | 2 +- .../OpenTelemetry.DotNet.Auto.psm1.template | 2 +- .../otel-dotnet-auto-install.sh.template | 2 +- 10 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 build/Build.InstallationScripts.Steps.cs rename OpenTelemetry.DotNet.Auto.psm1 => script-templates/OpenTelemetry.DotNet.Auto.psm1.template (99%) rename otel-dotnet-auto-install.sh => script-templates/otel-dotnet-auto-install.sh.template (96%) mode change 100755 => 100644 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d247f0561c..2a32f1dffe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,7 +67,7 @@ jobs: shell: powershell run: | $log_path = "C:\ProgramData\OpenTelemetry .NET AutoInstrumentation\logs\*" - Import-Module "${PWD}/OpenTelemetry.DotNet.Auto.psm1" + Import-Module "${PWD}/bin/installation-scripts/OpenTelemetry.DotNet.Auto.psm1" [System.Environment]::SetEnvironmentVariable("OTEL_DOTNET_AUTO_INSTALL_DIR", "${PWD}/bin/tracer-home", [System.EnvironmentVariableTarget]::Machine) Register-OpenTelemetryForCurrentSession -OTelServiceName "MyServiceDisplayName" ./test/test-applications/integrations/bin/TestApplication.Smoke/Release/net7.0/TestApplication.Smoke.exe @@ -84,6 +84,12 @@ jobs: with: name: bin-${{ matrix.machine }} path: bin/tracer-home + - name: Upload installation scripts + uses: actions/upload-artifact@v3.1.3 + if: always() + with: + name: installation-scripts-${{ matrix.machine }} + path: bin/installation-scripts - name: Regenerate LibraryVersions.g.cs # Regenerate the library versions file to surface any version changes made to the packages being tested. run: ./build.cmd GenerateLibraryVersionFiles diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index b989496c4d..b0cb0b2313 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -20,7 +20,7 @@ jobs: cd testapp dotnet new console dotnet publish -f net7.0 -c Release - $module_url = "https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/OpenTelemetry.DotNet.Auto.psm1" + $module_url = "https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/OpenTelemetry.DotNet.Auto.psm1" $dl_path = Join-Path $env:temp "OpenTelemetry.DotNet.Auto.psm1" $log_path = "C:\ProgramData\OpenTelemetry .NET AutoInstrumentation\logs\*" Invoke-WebRequest -Uri $module_url -OutFile $dl_path @@ -70,7 +70,7 @@ jobs: cd testapp dotnet new console dotnet publish -f net7.0 -c Release - curl -sSfL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/otel-dotnet-auto-install.sh -O + curl -sSfL https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/otel-dotnet-auto-install.sh -O sh ./otel-dotnet-auto-install.sh test "$(ls -A "$HOME/.otel-dotnet-auto")" curl -sSfL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/instrument.sh -O @@ -96,7 +96,7 @@ jobs: cd testapp dotnet new console dotnet publish -f net7.0 -c Release - curl -sSfL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/otel-dotnet-auto-install.sh -O + curl -sSfL https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/otel-dotnet-auto-install.sh -O sh ./otel-dotnet-auto-install.sh test "$(ls -A "$HOME/.otel-dotnet-auto")" curl -sSfL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/instrument.sh -O diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 717c2608cd..ca77b7cd7e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,6 +39,8 @@ jobs: - run: cd bin-windows-2022 ; zip -qq -r ../opentelemetry-dotnet-instrumentation-windows.zip . * ; cd .. - run: cd bin-macos-11 ; zip -qq -r ../opentelemetry-dotnet-instrumentation-macos.zip . * ; cd .. - run: cd bin-nuget-packages ; zip -qq -r ../opentelemetry-dotnet-instrumentation-nuget-packages.zip . * ; cd .. + - run: cp installation-scripts-windows-2022/splunk-otel-dotnet-install.sh ./splunk-otel-dotnet-install.sh + - run: cp installation-scripts-windows-2022/Splunk.OTel.DotNet.psm1 ./Splunk.OTel.DotNet.psm1 - name: Create Release run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --draft ./*.zip ./otel-dotnet-auto-install.sh ./OpenTelemetry.DotNet.Auto.psm1 env: diff --git a/build/Build.InstallationScripts.Steps.cs b/build/Build.InstallationScripts.Steps.cs new file mode 100644 index 0000000000..2e76ab1bc0 --- /dev/null +++ b/build/Build.InstallationScripts.Steps.cs @@ -0,0 +1,23 @@ +using Nuke.Common; +using Nuke.Common.IO; + +partial class Build +{ + AbsolutePath InstallationScriptsDirectory => OutputDirectory / "installation-scripts"; + + Target BuildInstallationScripts => _ => _ + .After(Clean) + .After(CreateRequiredDirectories) + .Executes(() => + { + var scriptTemplates = RootDirectory / "script-templates"; + var templateFiles = scriptTemplates.GetFiles(); + foreach (var templateFile in templateFiles) + { + var scriptFile = InstallationScriptsDirectory / templateFile.Name.Replace(".template", ""); + FileSystemTasks.CopyFile(templateFile, scriptFile); + scriptFile.UpdateText(x => + x.Replace("{{VERSION}}", VersionHelper.GetVersion())); + } + }); +} diff --git a/build/Build.Steps.Windows.cs b/build/Build.Steps.Windows.cs index aa4d2f9c48..a69757ba52 100644 --- a/build/Build.Steps.Windows.cs +++ b/build/Build.Steps.Windows.cs @@ -114,6 +114,7 @@ partial class Build Target PublishIisTestApplications => _ => _ .Unlisted() .After(CompileManagedTests) + .After(BuildInstallationScripts) .OnlyWhenStatic(() => IsWin && (Containers == ContainersWindows || Containers == ContainersWindowsOnly)) .Executes(() => { @@ -135,7 +136,7 @@ partial class Build void BuildDockerImage(Project project) { const string moduleName = "OpenTelemetry.DotNet.Auto.psm1"; - var sourceModulePath = Solution.Directory / moduleName; + var sourceModulePath = InstallationScriptsDirectory / moduleName; var localBinDirectory = project.Directory / "bin"; var localTracerZip = localBinDirectory / "tracer.zip"; diff --git a/build/Build.cs b/build/Build.cs index 278fe138a7..08a4df6426 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -100,6 +100,7 @@ void DeleteReparsePoints(string path) .After(Clean) .After(Restore) .DependsOn(CreateRequiredDirectories) + .DependsOn(BuildInstallationScripts) .DependsOn(GenerateNetFxTransientDependencies) .DependsOn(CompileManagedSrc) .DependsOn(PublishManagedProfiler) diff --git a/docs/releasing.md b/docs/releasing.md index 6371d42fd7..320f64b15b 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -6,8 +6,6 @@ 1. Update the version in the following files: - - [`OpenTelemetry.DotNet.Auto.psm1`](../OpenTelemetry.DotNet.Auto.psm1) - - [`otel-dotnet-auto-install.sh`](../otel-dotnet-auto-install.sh) - [`docs/README.md`](./README.md) 1. Update the [CHANGELOG.md](../CHANGELOG.md) with the new release. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 5078977ba8..2dff4ccc30 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -187,7 +187,7 @@ different versions of some assemblies also shipped in the `netfx` folder. If you are having problems in one of the scenarios above run again the `Install-OpenTelemetryCore` command from the -[PowerShell installation module](../OpenTelemetry.DotNet.Auto.psm1) +[PowerShell installation module](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/latest/download/OpenTelemetry.DotNet.Auto.psm1) to ensure that the required GAC installations are updated. For more information about the GAC usage by the automatic instrumentation, diff --git a/OpenTelemetry.DotNet.Auto.psm1 b/script-templates/OpenTelemetry.DotNet.Auto.psm1.template similarity index 99% rename from OpenTelemetry.DotNet.Auto.psm1 rename to script-templates/OpenTelemetry.DotNet.Auto.psm1.template index c5904de5ae..d56c377027 100644 --- a/OpenTelemetry.DotNet.Auto.psm1 +++ b/script-templates/OpenTelemetry.DotNet.Auto.psm1.template @@ -222,7 +222,7 @@ function Install-OpenTelemetryCore() { [string]$LocalPath ) - $version = "v1.0.2" + $version = "v{{VERSION}}" $installDir = Get-CLIInstallDir-From-InstallDir $InstallDir $archivePath = $null $deleteArchive = $true diff --git a/otel-dotnet-auto-install.sh b/script-templates/otel-dotnet-auto-install.sh.template old mode 100755 new mode 100644 similarity index 96% rename from otel-dotnet-auto-install.sh rename to script-templates/otel-dotnet-auto-install.sh.template index 5d0a779996..4c8b5530e4 --- a/otel-dotnet-auto-install.sh +++ b/script-templates/otel-dotnet-auto-install.sh.template @@ -31,7 +31,7 @@ esac test -z "$OTEL_DOTNET_AUTO_HOME" && OTEL_DOTNET_AUTO_HOME="$HOME/.otel-dotnet-auto" test -z "$TMPDIR" && TMPDIR="$(mktemp -d)" -test -z "$VERSION" && VERSION="v1.0.2" +test -z "$VERSION" && VERSION="v{{VERSION}}" RELEASES_URL="https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases" ARCHIVE="opentelemetry-dotnet-instrumentation-$OS_TYPE.zip" From 1e9aa18d24e23c979d3afcc6845bd3d2a032d9dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Fri, 29 Sep 2023 11:02:13 +0200 Subject: [PATCH 2/5] remove link from troubleshooting to avoid changes while creating release --- docs/troubleshooting.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 2dff4ccc30..78a81f4836 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -186,9 +186,9 @@ of assemblies loaded as domain-neutral. different versions of some assemblies also shipped in the `netfx` folder. If you are having problems in one of the scenarios above run again the -`Install-OpenTelemetryCore` command from the -[PowerShell installation module](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/latest/download/OpenTelemetry.DotNet.Auto.psm1) -to ensure that the required GAC installations are updated. +`Install-OpenTelemetryCore` command from the PowerShell installation module +`OpenTelemetry.DotNet.Auto.psm1` to ensure that the required GAC installations +are updated. For more information about the GAC usage by the automatic instrumentation, see [here](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/issues/1906#issuecomment-1376292814). From 57b3dd7892463dc9de3cf9958d098abf85e09c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Fri, 29 Sep 2023 11:13:32 +0200 Subject: [PATCH 3/5] fix readme.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index ee5daa20fb..6b6c07b32f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -183,7 +183,7 @@ chmod +x $HOME/.otel-dotnet-auto/instrument.sh OTEL_SERVICE_NAME=myapp OTEL_RESOURCE_ATTRIBUTES=deployment.environment=staging,service.version=1.0.0 ./MyNetApp ``` -[otel-dotnet-auto-install.sh](../otel-dotnet-auto-install.sh) script +`otel-dotnet-auto-install.sh` script uses environment variables as parameters: | Parameter | Description | Required | Default value | From 6ff8ca016660b433b2bd683aa7fda5c032b65780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Fri, 29 Sep 2023 11:43:54 +0200 Subject: [PATCH 4/5] fix files names --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ca77b7cd7e..79d1a02161 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,8 +39,8 @@ jobs: - run: cd bin-windows-2022 ; zip -qq -r ../opentelemetry-dotnet-instrumentation-windows.zip . * ; cd .. - run: cd bin-macos-11 ; zip -qq -r ../opentelemetry-dotnet-instrumentation-macos.zip . * ; cd .. - run: cd bin-nuget-packages ; zip -qq -r ../opentelemetry-dotnet-instrumentation-nuget-packages.zip . * ; cd .. - - run: cp installation-scripts-windows-2022/splunk-otel-dotnet-install.sh ./splunk-otel-dotnet-install.sh - - run: cp installation-scripts-windows-2022/Splunk.OTel.DotNet.psm1 ./Splunk.OTel.DotNet.psm1 + - run: cp installation-scripts-windows-2022/otel-dotnet-auto-install.sh ./otel-dotnet-auto-install.sh + - run: cp installation-scripts-windows-2022/OpenTelemetry.DotNet.Auto.psm1 ./OpenTelemetry.DotNet.Auto.psm1 - name: Create Release run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --draft ./*.zip ./otel-dotnet-auto-install.sh ./OpenTelemetry.DotNet.Auto.psm1 env: From ace24537b72d9849a347379198d65d325c6234d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Fri, 29 Sep 2023 12:20:38 +0200 Subject: [PATCH 5/5] Fix IIs tests --- build/Build.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/build/Build.cs b/build/Build.cs index 08a4df6426..74b16d1408 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -122,6 +122,7 @@ void DeleteReparsePoints(string path) .Description("Builds the managed unit / integration tests and runs them") .After(Clean, BuildTracer) .DependsOn(CreateRequiredDirectories) + .DependsOn(BuildInstallationScripts) .DependsOn(GenerateLibraryVersionFiles) .DependsOn(CompileManagedTests) .DependsOn(CompileMocks)