use lock for tests #136
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
pull_request: | |
# Allow manual runs. It is necessary to run the workflow manually, when the "formatter" workflow applies any changes. | |
workflow_dispatch: | |
jobs: | |
Processor_Partial: | |
if: github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, windows-latest, macos-latest, macos-13 ] # macos-13 for x86_x64 arch | |
framework: [ net6.0, net8.0, net9.0 ] | |
include: | |
- os: windows-latest | |
framework: net462 | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup .NET SDK v9.0.x | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.0.x | |
- name: Setup .NET SDK v8.0.x (if needed) | |
if: ${{ matrix.framework == 'net8.0' }} | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Setup .NET SDK v6.0.x (if needed) | |
if: ${{ matrix.framework == 'net6.0' }} | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 6.0.x | |
- name: Run tests | |
shell: bash | |
run: dotnet test --configuration=Release --framework=${{ matrix.framework }} | |
package: | |
runs-on: ubuntu-latest | |
needs: [ Processor_Partial ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup .NET SDK v9.0.x | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.0.x | |
- name: Create NuGet packages | |
shell: pwsh | |
run: | | |
if (-not ("${{ github.ref }}" -like "refs/tags/v*")) { | |
$suffix = "preview-$(Get-Date -Format yyyyMMddHHmmss -AsUTC)-$(git rev-parse --short HEAD)" | |
$params = "--version-suffix", $suffix | |
} | |
dotnet pack --configuration=Release --output dist @params | |
if ("${{ github.ref }}" -like "refs/tags/v*") { | |
$tag = "${{ github.ref }}".SubString(11) | |
$expectedPartialProcessorFile = "dist/G-Research.OpenTelemetry.Processor.Partial.$tag.nupkg" | |
# Check whether the tag and the package version match together | |
if (-not (Test-Path -Path $expectedPartialProcessorFile)) { | |
echo "::error ::Expected file $expectedPartialProcessorFile doesn't exist" | |
exit 1 | |
} | |
} | |
- name: Upload NuGet package artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nuget-packages | |
path: dist/*.nupkg | |
# Publish NuGet packages when a tag is pushed. | |
# Tests need to succeed for all components and on all platforms first, | |
# including having a tag name that matches the version number. | |
publish-release: | |
if: ${{ !github.event.repository.fork && startsWith(github.ref, 'refs/tags/v') }} | |
needs: package | |
environment: release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download NuGet package artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: nuget-packages | |
path: dist | |
- name: Publish to NuGet | |
run: dotnet nuget push "dist/G-Research.OpenTelemetry.Processor.Partial.*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json |