Skip to content

Use Microsoft.Build.Utilities.Core per doc recommendation (#2642) #2

Use Microsoft.Build.Utilities.Core per doc recommendation (#2642)

Use Microsoft.Build.Utilities.Core per doc recommendation (#2642) #2

Workflow file for this run

name: ci
on:
push:
branches: [ main ]
pull_request:
merge_group:
workflow_dispatch:
env:
NUGET_PACKAGES: ${{ github.workspace }}/packages
DOTNET_CLI_TELEMETRY_OPTOUT: 1
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- machine: windows-2022
log-dir: "/c/ProgramData/OpenTelemetry .NET AutoInstrumentation/logs"
- machine: ubuntu-20.04
log-dir: "/var/log/opentelemetry/dotnet"
- machine: macos-11
log-dir: "/var/log/opentelemetry/dotnet"
runs-on: ${{ matrix.machine }}
steps:
- uses: actions/checkout@v3.5.3
- uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: |
6.0.408
7.0.302
- name: Check for NuGet packages cache
uses: actions/cache@v3.3.1
id: nuget-cache
with:
key: ${{ hashFiles('**/Directory.packages.props', './build/LibraryVersions.g.cs', '**/packages.config' ) }}
path: ${{ env.NUGET_PACKAGES }}
- if: ${{ steps.nuget-cache.outputs.cache-hit != 'true' }}
name: Restore NuGet packages
continue-on-error: false
run: ./build.cmd Restore
- if: ${{ steps.nuget-cache.outputs.cache-hit != 'true' }}
name: Cache NuGet packages
uses: actions/cache/save@v3
with:
key: ${{ hashFiles('**/Directory.packages.props', './build/LibraryVersions.g.cs', '**/packages.config' ) }}
path: ${{ env.NUGET_PACKAGES }}
- run: ./build.cmd BuildWorkflow --no-restore ${{ steps.nuget-cache.outputs.cache-hit != 'true' }}
- run: brew install coreutils
if: ${{ runner.os == 'macOS' }}
- name: Create test directory
run: sudo mkdir -p ${{ matrix.log-dir }} && sudo chmod a+rwx ${{ matrix.log-dir }} # the instrumented process has no permissions to create log dir
if: ${{ runner.os != 'Windows' }}
- name: Test the Shell scripts from README.md
shell: bash
run: |
set -e
dotnet publish -f net7.0 -c Release ./test/test-applications/integrations/TestApplication.Smoke
export OTEL_DOTNET_AUTO_HOME="${PWD}/bin/tracer-home"
. ./instrument.sh
./test/test-applications/integrations/bin/TestApplication.Smoke/Release/net7.0/publish/TestApplication.Smoke
test "$(ls -A '${{ matrix.log-dir }}' )"
- name: Test the PowerShell module instructions from README.md
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
$log_path = "C:\ProgramData\OpenTelemetry .NET AutoInstrumentation\logs\*"
Import-Module "${PWD}/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
if (-not $?) { throw "dotnet help returned exit code: $LASTEXITCODE" }
if (-not (Test-Path $log_path)) { throw "Log file does not exist. Instrumentation test failed." }
Remove-Item $log_path
Unregister-OpenTelemetryForCurrentSession
./test/test-applications/integrations/bin/TestApplication.Smoke/Release/net7.0/TestApplication.Smoke.exe
if (-not $?) { throw "dotnet help returned exit code: $LASTEXITCODE" }
if (Test-Path $log_path) { throw "Log file exists. Instrumentation unregister failed." }
- name: Upload binaries
uses: actions/upload-artifact@v3.1.2
if: always()
with:
name: bin-${{ matrix.machine }}
path: bin/tracer-home
- name: Generated files unchanged
shell: bash
run: |
git status
git diff
[[ -z "$(git status --porcelain)" ]]
build-container:
strategy:
fail-fast: false
matrix:
include:
- base-image: alpine
os-type: linux-musl
- base-image: centos
os-type: linux-glibc
runs-on: ubuntu-20.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v3.5.3
- name: Build in Docker container
run: |
set -e
docker build -t mybuildimage -f "./docker/${{ matrix.base-image }}.dockerfile" ./docker
docker run -e OS_TYPE=${{ matrix.os-type }} --rm --mount type=bind,source="${GITHUB_WORKSPACE}",target=/project mybuildimage \
./build.sh BuildWorkflow
- name: Test the Shell scripts from README.md in Docker container
run: |
set -e
docker build -t mybuildimage -f "./docker/${{ matrix.base-image }}.dockerfile" ./docker
docker run --mount type=bind,source="${GITHUB_WORKSPACE}",target=/project --rm mybuildimage /bin/sh -c '
set -e
dotnet publish -f net7.0 -c Release ./test/test-applications/integrations/TestApplication.Smoke
export OTEL_DOTNET_AUTO_HOME="${PWD}/bin/tracer-home"
. ./instrument.sh
./test/test-applications/integrations/bin/TestApplication.Smoke/Release/net7.0/publish/TestApplication.Smoke
test "$(ls -A /var/log/opentelemetry/dotnet )"
'
- name: Publish Linux build
uses: actions/upload-artifact@v3.1.2
with:
name: bin-${{ matrix.base-image }}
path: bin/tracer-home
if: (${{ job.status }} != 'cancelled')
continue-on-error: true
build-nuget-packages:
needs: [ build, build-container ]
runs-on: windows-2022
steps:
- uses: actions/checkout@v3.5.3
- uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: |
6.0.408
7.0.302
- name: Check for NuGet packages cache
uses: actions/cache@v3.3.1
id: nuget-cache
with:
key: ${{ hashFiles('**/Directory.packages.props', './build/LibraryVersions.g.cs', '**/packages.config' ) }}
path: ${{ env.NUGET_PACKAGES }}
- name: Download Windows Artifacts from build job
uses: actions/download-artifact@v3.0.2
with:
name: bin-windows-2022
path: bin/ci-artifacts/bin-windows-2022
- name: Download CentOS Artifacts from build job
uses: actions/download-artifact@v3.0.2
with:
name: bin-centos
path: bin/ci-artifacts/bin-centos
- name: Download Alpine Artifacts from build job
uses: actions/download-artifact@v3.0.2
with:
name: bin-alpine
path: bin/ci-artifacts/bin-alpine
- name: Download Mac-OS Artifacts from build job
uses: actions/download-artifact@v3.0.2
with:
name: bin-macos-11
path: bin/ci-artifacts/bin-macos-11
- name: Build NuGet Runtime Packages
run: ./build.cmd BuildNuGetPackages
- name: Test NuGet Packages
run: ./build.cmd TestNuGetPackages
- name: Upload Nuget Artifacts
uses: actions/upload-artifact@v3.1.2
with:
name: OpenTelemetry.AutoInstrumentation.NuGet.Packages
path: bin/nuget-artifacts/
test-build-managed:
needs: build
strategy:
fail-fast: false
matrix:
test-tfm: [ net7.0, net6.0, net462 ]
machine: [ windows-2022, ubuntu-20.04, macos-11 ]
exclude:
- test-tfm: net462
machine: macos-11
- test-tfm: net462
machine: ubuntu-20.04
include:
- machine: windows-2022
containers: none
- machine: ubuntu-20.04
containers: linux
- machine: macos-11
containers: none
runs-on: ${{ matrix.machine }}
steps:
- uses: actions/checkout@v3.5.3
- uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: |
6.0.408
7.0.302
- name: Check for NuGet packages cache
uses: actions/cache@v3.3.1
id: nuget-cache
with:
key: ${{ hashFiles('**/Directory.packages.props', './build/LibraryVersions.g.cs', '**/packages.config' ) }}
path: ${{ env.NUGET_PACKAGES }}
- name: Download Artifacts from build job
uses: actions/download-artifact@v3.0.2
with:
name: bin-${{ matrix.machine }}
path: bin/tracer-home
- name: Install SQL Server (localdb)
uses: potatoqualitee/mssqlsuite@v1.7
if: ${{ runner.os == 'Windows' }}
with:
install: localdb
- run: ./build.cmd --skip NativeTests --target TestWorkflow --test-target-framework ${{ matrix.test-tfm }} --containers ${{ matrix.containers }}
- name: Upload test logs
uses: actions/upload-artifact@v3.1.2
if: always()
with:
name: test-logs-${{ matrix.machine }}-${{ matrix.test-tfm }}-containers-${{ matrix.containers }}
path: test-artifacts/
- name: Delete SQL Server MSI
if: ${{ runner.os == 'Windows' }}
shell: bash
run: |
rm SqlLocalDB.msi
test-build-native:
needs: build
strategy:
fail-fast: false
matrix:
machine: [ windows-2022 ]
runs-on: ${{ matrix.machine }}
steps:
- uses: actions/checkout@v3.5.3
- uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: |
6.0.408
7.0.302
- name: Check for NuGet packages cache
uses: actions/cache@v3.3.1
id: nuget-cache
with:
key: ${{ hashFiles('**/Directory.packages.props', './build/LibraryVersions.g.cs', '**/packages.config' ) }}
path: ${{ env.NUGET_PACKAGES }}
- name: Download Artifacts from build job
uses: actions/download-artifact@v3.0.2
with:
name: bin-${{ matrix.machine }}
path: bin/tracer-home
- run: ./build.cmd NativeTests
test-build-windows-container-tests:
needs: build
strategy:
fail-fast: false
matrix:
include:
- machine: windows-2022
containers: windows-only
runs-on: ${{ matrix.machine }}
steps:
- uses: actions/checkout@v3.5.3
- uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: |
6.0.408
7.0.302
- name: Check for NuGet packages cache
uses: actions/cache@v3.3.1
id: nuget-cache
with:
key: ${{ hashFiles('**/Directory.packages.props', './build/LibraryVersions.g.cs', '**/packages.config' ) }}
path: ${{ env.NUGET_PACKAGES }}
- name: Download Artifacts from build job
uses: actions/download-artifact@v3.0.2
with:
name: bin-${{ matrix.machine }}
path: bin/tracer-home
- name: Build artifacts required for the test (no native tests)
run: ./build.cmd --skip RunManagedTests --target ManagedTests --containers ${{ matrix.containers }}
- name: Run the integration tests
run: ./build.cmd --target RunManagedIntegrationTests --containers ${{ matrix.containers }}
- name: Upload test logs
uses: actions/upload-artifact@v3.1.2
if: always()
with:
name: test-logs-${{ matrix.machine }}-containers-${{ matrix.containers }}
path: test-artifacts/
test-build-container:
needs: build-container
strategy:
fail-fast: false
matrix:
include:
- base-image: alpine
os-type: linux-musl
- base-image: centos
os-type: linux-glibc
runs-on: ubuntu-20.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v3.5.3
- name: Download Artifacts from build job
uses: actions/download-artifact@v3.0.2
with:
name: bin-${{ matrix.base-image }}
path: bin/tracer-home
- name: Build in Docker container
run: |
set -e
docker build -t mybuildimage -f "./docker/${{ matrix.base-image }}.dockerfile" ./docker
docker run -e OS_TYPE=${{ matrix.os-type }} --rm --mount type=bind,source="${GITHUB_WORKSPACE}",target=/project mybuildimage \
./build.sh TestWorkflow --containers none
test-nuget-packages:
needs: build-nuget-packages
strategy:
fail-fast: false
matrix:
include:
- machine: ubuntu-20.04
- machine: macos-11
runs-on: ${{ matrix.machine }}
steps:
- uses: actions/checkout@v3.5.3
- uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: |
6.0.408
7.0.302
- name: Check for NuGet packages cache
uses: actions/cache@v3.3.1
id: nuget-cache
with:
key: ${{ hashFiles('**/Directory.packages.props', './build/LibraryVersions.g.cs', '**/packages.config' ) }}
path: ${{ env.NUGET_PACKAGES }}
- name: Download NuGet Artifacts from build-nuget-packages job
uses: actions/download-artifact@v3.0.2
with:
name: OpenTelemetry.AutoInstrumentation.NuGet.Packages
path: bin/nuget-artifacts/
- name: Test NuGet Packages
run: ./build.cmd TestNuGetPackages