From 1e024acb3bf41b3cc62dcc5ae06b5b15dd5f8d06 Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Tue, 29 Oct 2024 13:36:48 +0100 Subject: [PATCH 01/13] ci: setup building nuget packages in CI --- .github/workflows/dotnet.yml | 102 ++++++++++++++++++++++++++ windows/build-artifacts.ps1 | 10 ++- windows/build/build.ps1 | 109 +++++++++++++++++++++++++++ windows/build/build.sh | 115 +++++++++++++++++++++++++++++ windows/libdatadog.csproj | 138 ++++++++++++++++++++++++----------- windows/libdatadog.props | 24 ------ windows/libdatadog.targets | 59 +++++++++++++++ 7 files changed, 485 insertions(+), 72 deletions(-) create mode 100644 .github/workflows/dotnet.yml mode change 100644 => 100755 windows/build-artifacts.ps1 create mode 100644 windows/build/build.ps1 create mode 100755 windows/build/build.sh delete mode 100644 windows/libdatadog.props create mode 100644 windows/libdatadog.targets diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 000000000..88a670c40 --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,102 @@ +on: + push: + branches: + - main + pull_request: + +name: .NET + +jobs: + windows-build: + runs-on: windows-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: Install rustup using win.rustup.rs + run: | + # disable download progress bar + $ProgressPreference = "SilentlyContinue" + Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe + .\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --default-toolchain=none + del rustup-init.exe + rustup target add x86_64-pc-windows-msvc + rustup target add i686-pc-windows-msvc + shell: powershell + + - name: build + run: | + .\windows\build\build.ps1 -output_dir .\bin + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: windows-bin + path: | + bin/x86_64-pc-windows-msvc/*/datadog_profiling_ffi.dll + bin/x86_64-pc-windows-msvc/*/datadog_profiling_ffi.lib + bin/x86_64-pc-windows-msvc/*/datadog_profiling_ffi.pdb + bin/i686-pc-windows-msvc/*/datadog_profiling_ffi.dll + bin/i686-pc-windows-msvc/*/datadog_profiling_ffi.lib + bin/i686-pc-windows-msvc/*/datadog_profiling_ffi.pdb + if-no-files-found: error + + macos-build: + runs-on: macos-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: Install rustup using rustup.rs + run: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + source $HOME/.cargo/env + rustup target add x86_64-apple-darwin + rustup target add aarch64-apple-darwin + shell: bash + + - name: build + run: | + chmod +x ./windows/build/build.sh + ./windows/build/build.sh -o ./bin + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: macos-bin + path: | + bin/x86_64-apple-darwin/*/libdatadog_profiling_ffi.dylib + bin/x86_64-apple-darwin/*/libdatadog_profiling_ffi.a + bin/aarch64-apple-darwin/*/libdatadog_profiling_ffi.dylib + bin/aarch64-apple-darwin/*/libdatadog_profiling_ffi.a + if-no-files-found: error + + pack: + runs-on: windows-latest + needs: [windows-build, macos-build] + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: Download Windows artifacts + uses: actions/download-artifact@v4 + with: + name: windows-bin + path: bin + + - name: Download mac artifacts + uses: actions/download-artifact@v4 + with: + name: macos-bin + path: bin + + - name: pack + run: | + dotnet pack .\windows\libdatadog.csproj -p:LibDatadogBinariesOutputDir=..\bin -p:LibDatadogVersion="42.0.0" -o .nuget\packages\ + + - name: store artifacts + uses: actions/upload-artifact@v4 + with: + name: packages + path: .nuget/packages/* + if-no-files-found: error diff --git a/windows/build-artifacts.ps1 b/windows/build-artifacts.ps1 old mode 100644 new mode 100755 index b1ae15968..0372a995f --- a/windows/build-artifacts.ps1 +++ b/windows/build-artifacts.ps1 @@ -22,10 +22,12 @@ Write-Host "Building project into $($output_dir)" -ForegroundColor Magenta # build inside the crate to use the config.toml file pushd profiling-ffi -Invoke-Call -ScriptBlock { cargo build --features datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target i686-pc-windows-msvc --release --target-dir $output_dir } -Invoke-Call -ScriptBlock { cargo build --features datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target i686-pc-windows-msvc --target-dir $output_dir } -Invoke-Call -ScriptBlock { cargo build --features datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target x86_64-pc-windows-msvc --release --target-dir $output_dir } -Invoke-Call -ScriptBlock { cargo build --features datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target x86_64-pc-windows-msvc --target-dir $output_dir } +Invoke-Call -ScriptBlock { cargo build --features data-pipeline-ffi,datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target aarch64-apple-darwin --release --target-dir $output_dir } +Invoke-Call -ScriptBlock { cargo build --features data-pipeline-ffi,datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target aarch64-apple-darwin --target-dir $output_dir } +Invoke-Call -ScriptBlock { cargo build --features data-pipeline-ffi,datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target i686-pc-windows-msvc --release --target-dir $output_dir } +Invoke-Call -ScriptBlock { cargo build --features data-pipeline-ffi,datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target i686-pc-windows-msvc --target-dir $output_dir } +Invoke-Call -ScriptBlock { cargo build --features data-pipeline-ffi,datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target x86_64-pc-windows-msvc --release --target-dir $output_dir } +Invoke-Call -ScriptBlock { cargo build --features data-pipeline-ffi,datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target x86_64-pc-windows-msvc --target-dir $output_dir } popd Write-Host "Building tools" -ForegroundColor Magenta diff --git a/windows/build/build.ps1 b/windows/build/build.ps1 new file mode 100644 index 000000000..f5eaea142 --- /dev/null +++ b/windows/build/build.ps1 @@ -0,0 +1,109 @@ +param ( + [string]$output_dir, + [string[]]$targets = @( + # "aarch64-apple-darwin" + # "x86_64-apple-darwin" + # "aarch64-unknown-linux-gnu", + # "x86_64-unknown-linux-gnu" + "i686-pc-windows-msvc", + "x86_64-pc-windows-msvc" + ) +) + +# Check if output directory is set +if (-not $output_dir) { + Write-Host "You must specify an output directory with -output. Example: .\build_script.ps1 -output bin" + exit 1 +} + +# Make output_dir an absolute path if it's not already +if (-not [System.IO.Path]::IsPathRooted($output_dir)) { + $output_dir = Join-Path -Path (Get-Location) -ChildPath $output_dir +} + +Write-Host "Building project into $output_dir" -ForegroundColor Magenta + +# Function to invoke a command and exit if it fails +function Invoke-Call { + param ( + [scriptblock]$ScriptBlock + ) + & $ScriptBlock + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } +} + +# Function to build project with given target, features, and release flag +function Build-Project { + param ( + [string]$target, + [bool]$release = $false + ) + + Invoke-Call -ScriptBlock { + $featues = @( + "data-pipeline-ffi", + "datadog-profiling-ffi/ddtelemetry-ffi", + "datadog-profiling-ffi/crashtracker-receiver", + "datadog-profiling-ffi/crashtracker-collector", + "datadog-profiling-ffi/demangler" + ) + + # cargo has a bug when passing "" as configuration, so branch for debug and release + if ($release) { + cargo build --features $($featues -join ",") --target $target --release --target-dir $output_dir + } else { + cargo build --features $($featues -join ",") --target $target --target-dir $output_dir + } + } +} + +# Function to generate header files using cbindgen +function Generate-Header { + param ( + [string]$crateName, + [string]$configPath, + [string]$outputPath + ) + + Invoke-Call -ScriptBlock { + cbindgen --crate $crateName --config $configPath --output $outputPath + } +} + +# Build project for multiple targets + +try { + Push-Location "profiling-ffi" + foreach ($target in $targets) { + Build-Project -target $target -release $true + Build-Project -target $target + } +} +finally { + Pop-Location +} + +Write-Host "Building tools" -ForegroundColor Magenta +try { + Push-Location "tools" + Invoke-Call -ScriptBlock { cargo build --release } +} +finally { + Pop-Location +} + +Write-Host "Generating headers" -ForegroundColor Magenta + +# Generate headers for each FFI crate +Generate-Header -crateName "ddcommon-ffi" -configPath "ddcommon-ffi/cbindgen.toml" -outputPath "$output_dir\common.h" +Generate-Header -crateName "datadog-profiling-ffi" -configPath "profiling-ffi/cbindgen.toml" -outputPath "$output_dir\profiling.h" +Generate-Header -crateName "ddtelemetry-ffi" -configPath "ddtelemetry-ffi/cbindgen.toml" -outputPath "$output_dir\telemetry.h" +Generate-Header -crateName "data-pipeline-ffi" -configPath "data-pipeline-ffi/cbindgen.toml" -outputPath "$output_dir\data-pipeline.h" +Generate-Header -crateName "datadog-crashtracker-ffi" -configPath "crashtracker-ffi/cbindgen.toml" -outputPath "$output_dir\crashtracker.h" + +# Deduplicate headers +Invoke-Call -ScriptBlock { .\target\release\dedup_headers "$output_dir\common.h" "$output_dir\profiling.h" "$output_dir\telemetry.h" "$output_dir\data-pipeline.h" "$output_dir\crashtracker.h" } + +Write-Host "Build finished" -ForegroundColor Magenta diff --git a/windows/build/build.sh b/windows/build/build.sh new file mode 100755 index 000000000..5d53983ac --- /dev/null +++ b/windows/build/build.sh @@ -0,0 +1,115 @@ +#!/bin/bash + +# Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/ +# SPDX-License-Identifier: Apache-2.0 + +# Default values +output_dir="" +targets=( + # Uncomment or add targets as needed + "aarch64-apple-darwin" + "x86_64-apple-darwin" + # "aarch64-unknown-linux-gnu" + # "x86_64-unknown-linux-gnu" + # "i686-pc-windows-msvc" + # "x86_64-pc-windows-msvc" +) + +# Parse named parameters +while [[ "$#" -gt 0 ]]; do + case "$1" in + -o|--output) + output_dir="$2" + shift 2 + ;; + -t|--target) + targets=() + shift + while [[ "$1" && ! "$1" =~ ^- ]]; do + targets+=("$1") + shift + done + ;; + *) + echo "Unknown parameter: $1" + exit 1 + ;; + esac +done + +# Check if output directory is set +if [ -z "$output_dir" ]; then + echo "You must specify an output directory with -o or --output. Example: ./build_script.sh -o bin" + exit 1 +fi + +# Make output_dir an absolute path if it's not already +if [[ "$output_dir" != /* ]]; then + output_dir="$(pwd)/$output_dir" +fi + +echo -e "Building project into $output_dir" + +# Function to invoke a command and exit if it fails +invoke_call() { + "$@" + if [ $? -ne 0 ]; then + exit $? + fi +} + +# Function to build project with given target, features, and release flag +build_project() { + local target="$1" + local release_flag="$2" + + features=( + "data-pipeline-ffi" + "datadog-profiling-ffi/ddtelemetry-ffi" + "datadog-profiling-ffi/crashtracker-receiver" + "datadog-profiling-ffi/crashtracker-collector" + "datadog-profiling-ffi/demangler" + ) + + if [ "$release_flag" = "--release" ]; then + invoke_call cargo build --features "$(IFS=,; echo "${features[*]}")" --target "$target" --release --target-dir "$output_dir" + else + invoke_call cargo build --features "$(IFS=,; echo "${features[*]}")" --target "$target" --target-dir "$output_dir" + fi +} + +# Function to generate header files using cbindgen +generate_header() { + local crate_name="$1" + local config_path="$2" + local output_path="$3" + + invoke_call cbindgen --crate "$crate_name" --config "$config_path" --output "$output_path" +} + +# Build project for multiple targets +pushd profiling-ffi || exit +for target in "${targets[@]}"; do + build_project "$target" "--release" + build_project "$target" "" +done +popd || exit + +echo -e "Building tools" +pushd tools || exit +invoke_call cargo build --release +popd || exit + +echo -e "Generating headers" + +# Generate headers for each FFI crate +generate_header "ddcommon-ffi" "ddcommon-ffi/cbindgen.toml" "$output_dir/common.h" +generate_header "datadog-profiling-ffi" "profiling-ffi/cbindgen.toml" "$output_dir/profiling.h" +generate_header "ddtelemetry-ffi" "ddtelemetry-ffi/cbindgen.toml" "$output_dir/telemetry.h" +generate_header "data-pipeline-ffi" "data-pipeline-ffi/cbindgen.toml" "$output_dir/data-pipeline.h" +generate_header "datadog-crashtracker-ffi" "crashtracker-ffi/cbindgen.toml" "$output_dir/crashtracker.h" + +# Deduplicate headers +invoke_call ./target/release/dedup_headers "$output_dir/common.h" "$output_dir/profiling.h" "$output_dir/telemetry.h" "$output_dir/data-pipeline.h" "$output_dir/crashtracker.h" + +echo -e "Build finished" diff --git a/windows/libdatadog.csproj b/windows/libdatadog.csproj index eb40afbe7..ac9ea6534 100644 --- a/windows/libdatadog.csproj +++ b/windows/libdatadog.csproj @@ -1,4 +1,4 @@ - + net7.0 libdatadog @@ -13,57 +13,107 @@ false https://github.com/DataDog/libdatadog libdatadog provides a shared library containing common code used in the - implementation of Datadog's libraries, including Datadog Continuous Profilers + implementation of Datadog's libraries, including Datadog Continuous Profilers + Release of libdatadog Copyright 2022 Datadog, Inc. Datadog;native; git + + + $(MSBuildThisFileDirectory)..\bin true + + + true + + + + true + + + + true + + + + x64 + + + + true + ARM64 + + + + true + ARM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/windows/libdatadog.props b/windows/libdatadog.props deleted file mode 100644 index 973cb560b..000000000 --- a/windows/libdatadog.props +++ /dev/null @@ -1,24 +0,0 @@ - - - - x64 - x86 - - - - - - - @(LibdatadogLibs) - PowrProf.lib;NtDll.lib;UserEnv.lib;Bcrypt.lib;crypt32.lib;wsock32.lib;ws2_32.lib;shlwapi.lib;Secur32.lib;Ncrypt.lib - - - - $(MSBuildThisFileDirectory)..\..\include\native;%(AdditionalIncludeDirectories) - - - $(LibdatadogLibraries);$(LibdatadogDependencies);%(AdditionalDependencies) - - - diff --git a/windows/libdatadog.targets b/windows/libdatadog.targets new file mode 100644 index 000000000..b8700842c --- /dev/null +++ b/windows/libdatadog.targets @@ -0,0 +1,59 @@ + + + + true + + + + true + + + + true + + + + x86 + + + + x64 + + + + ARM64 + + + + ARM + + + + + datadog_profiling_ffi.dll + Always + + + + + + datadog_profiling_ffi.dll + Always + + + + + + datadog_profiling_ffi.dylib + Always + + + + + + datadog_profiling_ffi.dylib + Always + + + From f917b0249df473224571d5ce5efbd1c2779b5470 Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Fri, 15 Nov 2024 15:23:36 +0100 Subject: [PATCH 02/13] try parallel builds --- .github/workflows/dotnet.yml | 114 +++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 52 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 88a670c40..26d2d1810 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -3,100 +3,110 @@ on: branches: - main pull_request: + branches: + - main -name: .NET +name: Build and Pack jobs: - windows-build: - runs-on: windows-latest + build: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [windows-latest, macos-latest] + target: [ + x86_64-pc-windows-msvc, + i686-pc-windows-msvc, + x86_64-apple-darwin, + aarch64-apple-darwin + ] + include: + - os: windows-latest + target: x86_64-pc-windows-msvc + - os: windows-latest + target: i686-pc-windows-msvc + - os: macos-latest + target: x86_64-apple-darwin + - os: macos-latest + target: aarch64-apple-darwin + steps: - - name: checkout + - name: Checkout code uses: actions/checkout@v4 - - name: Install rustup using win.rustup.rs + - name: Install rustup + if: matrix.os == 'windows-latest' run: | - # disable download progress bar $ProgressPreference = "SilentlyContinue" Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe - .\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --default-toolchain=none + .\rustup-init.exe -y --default-host=${{ matrix.target }} --default-toolchain=none del rustup-init.exe - rustup target add x86_64-pc-windows-msvc - rustup target add i686-pc-windows-msvc + rustup target add ${{ matrix.target }} shell: powershell - - name: build - run: | - .\windows\build\build.ps1 -output_dir .\bin - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: windows-bin - path: | - bin/x86_64-pc-windows-msvc/*/datadog_profiling_ffi.dll - bin/x86_64-pc-windows-msvc/*/datadog_profiling_ffi.lib - bin/x86_64-pc-windows-msvc/*/datadog_profiling_ffi.pdb - bin/i686-pc-windows-msvc/*/datadog_profiling_ffi.dll - bin/i686-pc-windows-msvc/*/datadog_profiling_ffi.lib - bin/i686-pc-windows-msvc/*/datadog_profiling_ffi.pdb - if-no-files-found: error - - macos-build: - runs-on: macos-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: Install rustup using rustup.rs + - name: Install rustup + if: matrix.os == 'macos-latest' run: | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y source $HOME/.cargo/env - rustup target add x86_64-apple-darwin - rustup target add aarch64-apple-darwin + rustup target add ${{ matrix.target }} shell: bash - - name: build + - name: Build run: | - chmod +x ./windows/build/build.sh - ./windows/build/build.sh -o ./bin + if [ "${{ matrix.os }}" == "windows-latest" ]; then + .\windows\build\build.ps1 -output_dir .\bin + else + chmod +x ./windows/build/build.sh + ./windows/build/build.sh -o ./bin + fi - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: macos-bin + name: ${{ matrix.os }}-bin-${{ matrix.target }} path: | - bin/x86_64-apple-darwin/*/libdatadog_profiling_ffi.dylib - bin/x86_64-apple-darwin/*/libdatadog_profiling_ffi.a - bin/aarch64-apple-darwin/*/libdatadog_profiling_ffi.dylib - bin/aarch64-apple-darwin/*/libdatadog_profiling_ffi.a - if-no-files-found: error + bin/${{ matrix.target }}/* pack: runs-on: windows-latest - needs: [windows-build, macos-build] + needs: build steps: - - name: checkout + - name: Checkout code uses: actions/checkout@v4 - name: Download Windows artifacts uses: actions/download-artifact@v4 with: - name: windows-bin + name: windows-latest-bin-x86_64-pc-windows-msvc + path: bin + + - name: Download Windows artifacts + uses: actions/download-artifact@v4 + with: + name: windows-latest-bin-i686-pc-windows-msvc + path: bin + + - name: Download Mac artifacts + uses: actions/download-artifact@v4 + with: + name: macos-latest-bin-x86_64-apple-darwin path: bin - - name: Download mac artifacts + - name: Download Mac artifacts uses: actions/download-artifact@v4 with: - name: macos-bin + name: macos-latest-bin-aarch64-apple-darwin path: bin - - name: pack + - name: Pack run: | dotnet pack .\windows\libdatadog.csproj -p:LibDatadogBinariesOutputDir=..\bin -p:LibDatadogVersion="42.0.0" -o .nuget\packages\ - - name: store artifacts + - name: Store artifacts uses: actions/upload-artifact@v4 with: name: packages path: .nuget/packages/* - if-no-files-found: error + if-no-files-found: error \ No newline at end of file From afa9ec5d4423678bfb0995f11368f2ed983a76a0 Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Fri, 15 Nov 2024 15:28:44 +0100 Subject: [PATCH 03/13] try removing unwanted platforms --- .github/workflows/dotnet.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 26d2d1810..c1e35872c 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -21,15 +21,15 @@ jobs: x86_64-apple-darwin, aarch64-apple-darwin ] - include: + exclude: - os: windows-latest - target: x86_64-pc-windows-msvc + target: x86_64-apple-darwin - os: windows-latest - target: i686-pc-windows-msvc + target: aarch64-apple-darwin - os: macos-latest - target: x86_64-apple-darwin + target: x86_64-pc-windows-msvc - os: macos-latest - target: aarch64-apple-darwin + target: i686-pc-windows-msvc steps: - name: Checkout code @@ -55,12 +55,13 @@ jobs: - name: Build run: | - if [ "${{ matrix.os }}" == "windows-latest" ]; then + if [[ "${{ matrix.os }}" == "windows-latest" ]]; then .\windows\build\build.ps1 -output_dir .\bin else chmod +x ./windows/build/build.sh ./windows/build/build.sh -o ./bin fi + shell: bash - name: Upload artifacts uses: actions/upload-artifact@v4 From 86c1041f3032e67dfe2ec739fa7f440a0cf31093 Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Fri, 15 Nov 2024 15:31:14 +0100 Subject: [PATCH 04/13] split jobs --- .github/workflows/dotnet.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index c1e35872c..d550a7b4b 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -53,14 +53,16 @@ jobs: rustup target add ${{ matrix.target }} shell: bash - - name: Build + - name: Build on Windows + if: matrix.os == 'windows-latest' + run: .\windows\build\build.ps1 -output_dir .\bin + shell: pwsh + + - name: Build on macOS + if: matrix.os == 'macos-latest' run: | - if [[ "${{ matrix.os }}" == "windows-latest" ]]; then - .\windows\build\build.ps1 -output_dir .\bin - else - chmod +x ./windows/build/build.sh - ./windows/build/build.sh -o ./bin - fi + chmod +x ./windows/build/build.sh + ./windows/build/build.sh -o ./bin shell: bash - name: Upload artifacts From 6fc26208f886385b628045d24003f2bcc1445142 Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Fri, 15 Nov 2024 15:38:46 +0100 Subject: [PATCH 05/13] fix targets --- .github/workflows/dotnet.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index d550a7b4b..4fdfffe82 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -6,7 +6,7 @@ on: branches: - main -name: Build and Pack +name: .NET jobs: build: @@ -55,14 +55,14 @@ jobs: - name: Build on Windows if: matrix.os == 'windows-latest' - run: .\windows\build\build.ps1 -output_dir .\bin + run: .\windows\build\build.ps1 -output_dir .\bin -targets ${{ matrix.target }} shell: pwsh - name: Build on macOS if: matrix.os == 'macos-latest' run: | chmod +x ./windows/build/build.sh - ./windows/build/build.sh -o ./bin + ./windows/build/build.sh -o ./bin -t ${{ matrix.target }} shell: bash - name: Upload artifacts From 0230423e712d5fb95fbb2c3309a7b8b39d5b67c8 Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Mon, 18 Nov 2024 10:02:21 +0100 Subject: [PATCH 06/13] pack everything --- .github/workflows/dotnet.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 4fdfffe82..03ebd0f40 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -61,7 +61,6 @@ jobs: - name: Build on macOS if: matrix.os == 'macos-latest' run: | - chmod +x ./windows/build/build.sh ./windows/build/build.sh -o ./bin -t ${{ matrix.target }} shell: bash @@ -70,7 +69,7 @@ jobs: with: name: ${{ matrix.os }}-bin-${{ matrix.target }} path: | - bin/${{ matrix.target }}/* + bin/* pack: runs-on: windows-latest From 6df79d00e82f38cd55ef7aec486d37d88c36990d Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Mon, 18 Nov 2024 10:25:01 +0100 Subject: [PATCH 07/13] reduce artifact size by removing build related files --- .github/workflows/dotnet.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 03ebd0f40..f7873792d 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -70,6 +70,10 @@ jobs: name: ${{ matrix.os }}-bin-${{ matrix.target }} path: | bin/* + !bin/*/*/build + !bin/*/*/deps + !bin/*/*/examples + !bin/*/*/incremental pack: runs-on: windows-latest From ca5feb82b6a18c9a6e501d47648afbcbe6f73c82 Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Mon, 18 Nov 2024 14:37:44 +0100 Subject: [PATCH 08/13] add source control information --- .github/workflows/dotnet.yml | 6 +++++- windows/libdatadog.csproj | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index f7873792d..aa3e71dc8 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -8,6 +8,10 @@ on: name: .NET +env: + BRANCH: ${{ github.head_ref || github.ref_name }} + COMMIT_SHA: ${{ github.sha }} + jobs: build: runs-on: ${{ matrix.os }} @@ -108,7 +112,7 @@ jobs: - name: Pack run: | - dotnet pack .\windows\libdatadog.csproj -p:LibDatadogBinariesOutputDir=..\bin -p:LibDatadogVersion="42.0.0" -o .nuget\packages\ + dotnet pack .\windows\libdatadog.csproj -p:LibDatadogBinariesOutputDir=..\bin -p:LibDatadogVersion="42.0.0" -p:RepositoryBranch=$env:BRANCH -p:RepositoryCommit=$env:COMMIT_SHA -o .nuget\packages\ - name: Store artifacts uses: actions/upload-artifact@v4 diff --git a/windows/libdatadog.csproj b/windows/libdatadog.csproj index ac9ea6534..ed28afef2 100644 --- a/windows/libdatadog.csproj +++ b/windows/libdatadog.csproj @@ -18,6 +18,9 @@ Release of libdatadog Copyright 2022 Datadog, Inc. Datadog;native; + https://github.com/DataDog/libdatadog + $(RepositoryBranch) + $(RepositoryCommit) git From fa8bdb05cd88d97cf6669d918322f504bee5006f Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Mon, 18 Nov 2024 14:50:50 +0100 Subject: [PATCH 09/13] unique version to get around nuget cache gotchas --- .github/workflows/dotnet.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index aa3e71dc8..1a2da8dc2 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -112,7 +112,12 @@ jobs: - name: Pack run: | - dotnet pack .\windows\libdatadog.csproj -p:LibDatadogBinariesOutputDir=..\bin -p:LibDatadogVersion="42.0.0" -p:RepositoryBranch=$env:BRANCH -p:RepositoryCommit=$env:COMMIT_SHA -o .nuget\packages\ + dotnet pack .\windows\libdatadog.csproj ` + -p:LibDatadogBinariesOutputDir=..\bin ` + -p:LibDatadogVersion=$([System.DateTime]::Now.ToString("yyyy.MM.dd.HHmmss")) ` + -p:RepositoryBranch=$env:BRANCH ` + -p:RepositoryCommit=$env:COMMIT_SHA ` + -o .nuget\packages\ - name: Store artifacts uses: actions/upload-artifact@v4 From 02f7442d9bfdf1abbb05805ad3a440c0af559555 Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Mon, 18 Nov 2024 15:04:05 +0100 Subject: [PATCH 10/13] version in artifacts name --- .github/workflows/dotnet.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 1a2da8dc2..4a8de1245 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -82,6 +82,8 @@ jobs: pack: runs-on: windows-latest needs: build + env: + VERSION: $([System.DateTime]::Now.ToString("yyyy.MM.dd.HHmmss")) steps: - name: Checkout code uses: actions/checkout@v4 @@ -114,7 +116,7 @@ jobs: run: | dotnet pack .\windows\libdatadog.csproj ` -p:LibDatadogBinariesOutputDir=..\bin ` - -p:LibDatadogVersion=$([System.DateTime]::Now.ToString("yyyy.MM.dd.HHmmss")) ` + -p:LibDatadogVersion=$env:VERSION ` -p:RepositoryBranch=$env:BRANCH ` -p:RepositoryCommit=$env:COMMIT_SHA ` -o .nuget\packages\ @@ -122,6 +124,6 @@ jobs: - name: Store artifacts uses: actions/upload-artifact@v4 with: - name: packages + name: packages-$env:VERSION path: .nuget/packages/* if-no-files-found: error \ No newline at end of file From 7c1310b6ab3c9f7992936dc8a078e0a520cce16f Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Mon, 18 Nov 2024 15:45:21 +0100 Subject: [PATCH 11/13] try different scheme --- .github/workflows/dotnet.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 4a8de1245..a75ef52a1 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -82,8 +82,6 @@ jobs: pack: runs-on: windows-latest needs: build - env: - VERSION: $([System.DateTime]::Now.ToString("yyyy.MM.dd.HHmmss")) steps: - name: Checkout code uses: actions/checkout@v4 @@ -112,6 +110,13 @@ jobs: name: macos-latest-bin-aarch64-apple-darwin path: bin + - name: Set version + run: | + # 13.1.0-preview.{epoch} format + $epoch = [math]::Floor((Get-Date).Subtract([datetime]'1970-01-01').TotalSeconds) + $env:VERSION = "13.1.0-preview.$epoch" + echo "Version: $env:VERSION" + - name: Pack run: | dotnet pack .\windows\libdatadog.csproj ` From 941cfd72aa5dbd76d2f3dfbc7f306467032d3add Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Mon, 18 Nov 2024 16:00:38 +0100 Subject: [PATCH 12/13] name is fine --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index a75ef52a1..374d8d8c4 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -129,6 +129,6 @@ jobs: - name: Store artifacts uses: actions/upload-artifact@v4 with: - name: packages-$env:VERSION + name: packages path: .nuget/packages/* if-no-files-found: error \ No newline at end of file From 88f6c10e3ef28e2b30cf278998c0bdb0c249e241 Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Tue, 19 Nov 2024 10:29:49 +0100 Subject: [PATCH 13/13] version detection in same step --- .github/workflows/dotnet.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 374d8d8c4..bca6ee979 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -110,18 +110,14 @@ jobs: name: macos-latest-bin-aarch64-apple-darwin path: bin - - name: Set version + - name: Pack run: | # 13.1.0-preview.{epoch} format $epoch = [math]::Floor((Get-Date).Subtract([datetime]'1970-01-01').TotalSeconds) - $env:VERSION = "13.1.0-preview.$epoch" - echo "Version: $env:VERSION" - - - name: Pack - run: | - dotnet pack .\windows\libdatadog.csproj ` + $version = "13.1.0-preview.$epoch" + dotnet pack .\windows\libdatadog.csproj ` -p:LibDatadogBinariesOutputDir=..\bin ` - -p:LibDatadogVersion=$env:VERSION ` + -p:LibDatadogVersion=$version ` -p:RepositoryBranch=$env:BRANCH ` -p:RepositoryCommit=$env:COMMIT_SHA ` -o .nuget\packages\