Skip to content

Commit

Permalink
Update to SDK v8 (#107)
Browse files Browse the repository at this point in the history
* Update to v8 SDK

* Fix and update actions

* Refactor test and prefer global.json for actions

* Make test assetions Linux safe

* Bump tool versions
  • Loading branch information
stevejgordon authored Mar 22, 2024
1 parent e681f15 commit 8ff4a66
Show file tree
Hide file tree
Showing 32 changed files with 207 additions and 195 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,41 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v4
with:
fetch-depth: 1

- run: |
git fetch --prune --unshallow --tags
echo exit code $?
git tag --list
- uses: actions/setup-dotnet@v1
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
5.0.x
6.0.x
source-url: https://nuget.pkg.github.com/elastic/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
global-json-file: ./global.json

- run: ./build.sh build -s true
name: Build

- run: ./build.sh test -s true
name: Test

- run: ./build.sh generatepackages -s true
name: Generate local nuget packages

- run: ./build.sh validatepackages -s true
name: "validate *.npkg files that were created"

- run: ./build.sh generateapichanges -s true
name: "Inspect public API changes"

- name: publish canary packages github package repository
if: github.event_name == 'push' && startswith(github.ref, 'refs/heads')
shell: bash
run: |
until dotnet nuget push 'build/output/*.nupkg' -k ${{secrets.GITHUB_TOKEN}} --skip-duplicate --no-symbols; do echo "Retrying"; sleep 1; done;
dotnet nuget add source --username USERNAME --password ${{secrets.GITHUB_TOKEN}} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/elastic/index.json"
until dotnet nuget push 'build/output/*.nupkg' -k ${{secrets.GITHUB_TOKEN}} --skip-duplicate --no-symbols --source "github"; do echo "Retrying"; sleep 1; done;
# Github packages requires authentication, this is likely going away in the future so for now we publish to feedz.io
- run: dotnet nuget push 'build/output/*.nupkg' -k ${{secrets.FEEDZ_IO_API_KEY}} -s https://f.feedz.io/elastic/all/nuget/index.json --skip-duplicate --no-symbols
Expand All @@ -59,6 +62,7 @@ jobs:
- run: ./build.sh generatereleasenotes -s true
name: Generate release notes for tag
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags')

- run: ./build.sh createreleaseongithub -s true --token ${{secrets.GITHUB_TOKEN}}
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags')
name: Create or update release for tag on github
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:

permissions:
contents: read
checks: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -32,10 +33,10 @@ defaults:
jobs:
tests:
runs-on: windows-2022

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1

Expand All @@ -45,7 +46,7 @@ jobs:
git tag --list
name: Fetch Tags
- uses: actions/cache@v3
- uses: actions/cache@v4
name: NuGet package cache
with:
path: ~/.nuget/packages
Expand All @@ -54,10 +55,9 @@ jobs:
${{ runner.os }}-nuget
- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
global-json-file: ./global.json

- run: ./build.bat build -s true
name: Build
Expand All @@ -67,7 +67,7 @@ jobs:

- name: Test Results
if: success() || failure()
uses: mikepenz/action-junit-report@v3
uses: mikepenz/action-junit-report@v4
with:
report_paths: 'build/output/junit-*.xml'
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ project.lock.json
/src/.vs/restore.dg
src/packages/
BenchmarkDotNet.Artifacts
*.received.*

/.ionide/symbolCache.db
5 changes: 4 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MinVer" Version="2.5.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.2" PrivateAssets="all"/>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
File renamed without changes.
File renamed without changes.
8 changes: 2 additions & 6 deletions Playground/Playground.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.9.2" />
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.12.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\Elastic.Transport\Elastic.Transport.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>9.0</LangVersion>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,8 +15,4 @@
<ProjectReference Include="..\..\src\Elastic.Transport\Elastic.Transport.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Profiler.Api" Version="1.4.0" />
<PackageReference Include="JetBrains.Profiler.Api" Version="1.4.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Elastic.Transport\Elastic.Transport.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.3" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions build/scripts/CommandLine.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ with
interface IArgParserTemplate with
member this.Usage =
match this with
| Clean _ -> "clean known output locations"
| Build _ -> "Run build"
| Test _ -> "Runs build then tests"
| Release _ -> "runs build, tests, and create and validates the packages shy of publishing them"
| Publish _ -> "Runs the full release"
| Clean -> "clean known output locations"
| Build -> "Run build"
| Test -> "Runs build then tests"
| Release -> "runs build, tests, and create and validates the packages shy of publishing them"
| Publish -> "Runs the full release"

| SingleTarget _ -> "Runs the provided sub command without running their dependencies"
| Token _ -> "Token to be used to authenticate with github"
Expand Down
2 changes: 1 addition & 1 deletion build/scripts/Targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let private test (arguments:ParseResults<Arguments>) =
let loggerPathArgs = sprintf "LogFilePath=%s" junitOutput
let loggerArg = sprintf "--logger:\"junit;%s\"" loggerPathArgs
let tfmArgs =
if getOS = OS.Windows then [] else ["-f"; "net6.0"]
if getOS = OS.Windows then [] else ["-f"; "net8.0"]
exec "dotnet" (["test"; "-c"; "Release"; loggerArg] @ tfmArgs) |> ignore

let private generatePackages (arguments:ParseResults<Arguments>) =
Expand Down
12 changes: 4 additions & 8 deletions build/scripts/scripts.fsproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Argu" Version="6.1.1" />
<PackageReference Include="Argu" Version="6.2.2" />
<PackageReference Include="Bullseye" Version="3.5.0" />
<PackageReference Include="Proc" Version="0.6.2" />
<PackageReference Include="Fake.Tools.Git" Version="5.20.3" />
<PackageReference Include="Fake.Tools.Git" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand All @@ -19,8 +19,4 @@
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.3" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
]
},
"assembly-differ": {
"version": "0.13.0",
"version": "0.15.0",
"commands": [
"assembly-differ"
]
},
"release-notes": {
"version": "0.3.0",
"version": "0.6.0",
"commands": [
"release-notes"
]
},
"nupkg-validator": {
"version": "0.5.0",
"version": "0.6.0",
"commands": [
"nupkg-validator"
]
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"version": "6.0.403",
"rollForward": "latestFeature",
"version": "8.0.100",
"rollForward": "latestMajor",
"allowPrerelease": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Elastic.Transport\Elastic.Transport.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.3" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.Json;
using System.Text.Json.Serialization;
using JsonSerializer = System.Text.Json.JsonSerializer;
Expand All @@ -19,6 +16,8 @@ namespace Elastic.Transport;
/// </summary>
internal class ExceptionConverter : JsonConverter<Exception>
{
public override bool CanConvert(Type typeToConvert) => typeof(Exception).IsAssignableFrom(typeToConvert);

private static List<Dictionary<string, object>> FlattenExceptions(Exception e)
{
var maxExceptions = 20;
Expand All @@ -37,62 +36,21 @@ private static List<Dictionary<string, object>> FlattenExceptions(Exception e)

private static Dictionary<string, object> ToDictionary(Exception e, int depth)
{
var o = new Dictionary<string, object>(10);
var si = new SerializationInfo(e.GetType(), new FormatterConverter());
var sc = new StreamingContext();
e.GetObjectData(si, sc);
var o = new Dictionary<string, object>(7);

var helpUrl = si.GetString("HelpURL");
var stackTrace = si.GetString("StackTraceString");
var remoteStackTrace = si.GetString("RemoteStackTraceString");
var remoteStackIndex = si.GetInt32("RemoteStackIndex");
var exceptionMethod = si.GetString("ExceptionMethod");
var hresult = si.GetInt32("HResult");
var source = si.GetString("Source");
var className = si.GetString("ClassName");
var className = e.GetType().FullName;

o.Add("Depth", depth);
o.Add("ClassName", className);
o.Add("Message", e.Message);
o.Add("Source", source);
o.Add("StackTraceString", stackTrace);
o.Add("RemoteStackTraceString", remoteStackTrace);
o.Add("RemoteStackIndex", remoteStackIndex);
o.Add("HResult", hresult);
o.Add("HelpURL", helpUrl);
o.Add("Source", e.Source);
o.Add("StackTraceString", e.StackTrace);
o.Add("HResult", e.HResult);
o.Add("HelpURL", e.HelpLink);

WriteStructuredExceptionMethod(o, exceptionMethod);
return o;
}

private static void WriteStructuredExceptionMethod(Dictionary<string, object> o, string exceptionMethodString)
{
if (string.IsNullOrWhiteSpace(exceptionMethodString)) return;

var args = exceptionMethodString.Split('\0', '\n');

if (args.Length != 5) return;

var memberType = int.Parse(args[0], CultureInfo.InvariantCulture);
var name = args[1];
var assemblyName = args[2];
var className = args[3];
var signature = args[4];
var an = new AssemblyName(assemblyName);
var exceptionMethod = new Dictionary<string, object>(7)
{
{ "Name", name },
{ "AssemblyName", an.Name },
{ "AssemblyVersion", an.Version.ToString() },
{ "AssemblyCulture", an.CultureName },
{ "ClassName", className },
{ "Signature", signature },
{ "MemberType", memberType }
};

o.Add("ExceptionMethod", exceptionMethod);
}

public override Exception Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
throw new NotSupportedException();

Expand Down
Loading

0 comments on commit 8ff4a66

Please sign in to comment.