Skip to content

Workflow and TFM updates #2026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 23 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ env:
jobs:
build:
name: Build
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3.5.0
with:
fetch-depth: 0
- name: Install .NET SDK
uses: actions/setup-dotnet@v1.8.1
uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
- name: Build
run: dotnet build LibGit2Sharp.sln --configuration Release
- name: Upload packages
uses: actions/upload-artifact@v2.2.4
uses: actions/upload-artifact@v3.1.2
with:
name: NuGet packages
path: bin/Packages/
Expand All @@ -36,57 +36,48 @@ jobs:
strategy:
matrix:
arch: [ amd64 ]
os: [windows-2019, macos-10.15]
tfm: [ net472, netcoreapp3.1, net6.0 ]
os: [ windows-2019, macos-11 ]
tfm: [ net472, net6.0, net7.0 ]
exclude:
- os: macos-10.15
- os: macos-11
tfm: net472
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3.5.0
with:
fetch-depth: 0
- name: Install .NET SDK
uses: actions/setup-dotnet@v1.8.1
uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: 6.0.x
- name: Install .NET Core 3.1 runtime
if: matrix.tfm == 'netcoreapp3.1'
uses: actions/setup-dotnet@v1.8.1
with:
dotnet-version: 3.1.x
dotnet-version: |
7.0.x
6.0.x
- name: Run ${{ matrix.tfm }} tests
run: dotnet test LibGit2Sharp.sln --configuration Release --framework ${{ matrix.tfm }} --logger "GitHubActions" /p:ExtraDefine=LEAKS_IDENTIFYING
test-linux:
name: Test / ${{ matrix.distro }} / ${{ matrix.arch }} / ${{ matrix.tfm }}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
arch: [ amd64 ]
# arch: [ amd64, arm64 ]
distro: [ alpine.3.12, alpine.3.13, alpine.3.14, centos.7, centos.8, debian.9, debian.10, debian.11, fedora.33, ubuntu.18.04, ubuntu.20.04 ]
sdk: [ '6.0', '3.1' ]
distro: [ alpine.3.13, alpine.3.14, alpine.3.15, alpine.3.16, alpine.3.17, centos.7, centos.stream.8, debian.10, debian.11, fedora.36, ubuntu.18.04, ubuntu.20.04, ubuntu.22.04 ]
sdk: [ '6.0', '7.0' ]
exclude:
- arch: arm64
distro: alpine.3.12
- arch: arm64
distro: alpine.3.13
sdk: '3.1'
- arch: arm64
distro: alpine.3.14
sdk: '3.1'
- arch: arm64
distro: centos.7
- distro: alpine.3.13
sdk: '7.0'
- distro: alpine.3.14
sdk: '7.0'
include:
- sdk: '6.0'
tfm: net6.0
- sdk: '3.1'
tfm: netcoreapp3.1
- sdk: '7.0'
tfm: net7.0
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3.5.0
with:
fetch-depth: 0
- name: Setup QEMU
Expand Down
6 changes: 3 additions & 3 deletions LibGit2Sharp.Tests/BlobFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void CanGetBlobAsFilteredText(string autocrlf, string expectedText)
}
}

#if NETFRAMEWORK || NETCOREAPP3_1 //UTF-7 is disabled in .NET 5+
#if NETFRAMEWORK //UTF-7 is disabled in .NET 5+
[Theory]
[InlineData("ascii", 4, "31 32 33 34")]
[InlineData("utf-7", 4, "31 32 33 34")]
Expand Down Expand Up @@ -239,11 +239,11 @@ public void CanTellIfABlobIsMissing()
// Manually delete the objects directory to simulate a partial clone
Directory.Delete(Path.Combine(repoPath, "objects", "a8"), true);

using (var repo = new Repository(repoPath))
using (var repo = new Repository(repoPath))
{
// Look up for the tree that reference the blob which is now missing
var tree = repo.Lookup<Tree>("fd093bff70906175335656e6ce6ae05783708765");
var blob = (Blob) tree["README"].Target;
var blob = (Blob)tree["README"].Target;

Assert.Equal("a8233120f6ad708f843d861ce2b7228ec4e3dec6", blob.Sha);
Assert.NotNull(blob);
Expand Down
14 changes: 7 additions & 7 deletions LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net472;netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net472;net6.0;net7.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -11,12 +11,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="1.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.console" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageReference Include="xunit.skippablefact" Version="1.4.13" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static string GetGlobalSettingsNativeLibraryPath()
return Path.Combine(nativeLibraryDir, libgit2 + Platform.GetNativeLibraryExtension());
}

#if NETSTANDARD
#if NETFRAMEWORK
private static bool TryUseNativeLibrary() => false;
#else
private static bool TryUseNativeLibrary()
Expand Down
10 changes: 5 additions & 5 deletions LibGit2Sharp/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class GlobalSettings

private static string nativeLibraryPath;
private static bool nativeLibraryPathLocked;
private static string nativeLibraryDefaultPath;
private static readonly string nativeLibraryDefaultPath = null;

static GlobalSettings()
{
Expand All @@ -29,19 +29,18 @@ static GlobalSettings()

nativeLibraryPathAllowed = netFX || netCore;

#if NETFRAMEWORK
if (netFX)
{
// For .NET Framework apps the dependencies are deployed to lib/win32/{architecture} directory
nativeLibraryDefaultPath = Path.Combine(GetExecutingAssemblyDirectory(), "lib", "win32", Platform.ProcessorArchitecture);
}
else
{
nativeLibraryDefaultPath = null;
}
#endif

registeredFilters = new Dictionary<Filter, FilterRegistration>();
}

#if NETFRAMEWORK
private static string GetExecutingAssemblyDirectory()
{
// Assembly.CodeBase is not actually a correctly formatted
Expand All @@ -66,6 +65,7 @@ private static string GetExecutingAssemblyDirectory()
managedPath = Path.GetDirectoryName(managedPath);
return managedPath;
}
#endif

/// <summary>
/// Returns information related to the current LibGit2Sharp
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp/LibGit2Sharp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Description>LibGit2Sharp brings all the might and speed of libgit2, a native Git implementation, to the managed world of .NET</Description>
<Company>LibGit2Sharp contributors</Company>
Expand Down Expand Up @@ -31,7 +31,7 @@

<ItemGroup>
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="[2.0.319]" PrivateAssets="none" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.220" PrivateAssets="all" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp/ObjectDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ private unsafe Blob CreateBlob(Stream stream, string hintpath, long? numberOfByt
throw new EndOfStreamException("The stream ended unexpectedly");
}
}
catch(Exception e)
catch (Exception)
{
writestream.free(writestream_ptr);
throw e;
throw;
}

ObjectId id = Proxy.git_blob_create_fromstream_commit(writestream_ptr);
Expand Down