Skip to content
Draft
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
7 changes: 0 additions & 7 deletions .github/actions/docker-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ inputs:
dotnet_version:
description: '.net version'
default: '8.0'
git_backend:
description: 'Git backend to exercise (libgit2 or managed)'
default: 'libgit2'

runs:
using: 'composite'
steps:
- name: '[Docker Build & Test] DockerHub'
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
env:
GITVERSION_GIT_BACKEND: ${{ inputs.git_backend }}
with:
shell: pwsh
timeout_minutes: 30
Expand All @@ -33,8 +28,6 @@ runs:

- name: '[Docker Build & Test] GitHub'
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
env:
GITVERSION_GIT_BACKEND: ${{ inputs.git_backend }}
with:
shell: pwsh
timeout_minutes: 30
Expand Down
3 changes: 0 additions & 3 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ component_management:
- component_id: gitversion-core
name: GitVersion.Core
paths: [ src/GitVersion.Core/** ]
- component_id: gitversion-libgit2sharp
name: GitVersion.LibGit2Sharp
paths: [ src/GitVersion.LibGit2Sharp/** ]
- component_id: gitversion-msbuild
name: GitVersion.MsBuild
paths: [ src/GitVersion.MsBuild/** ]
Expand Down
4 changes: 0 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ updates:
patterns:
- "NUnit.*"
- "NUnit3TestAdapter"
LibGit2Sharp:
group-by: dependency-name
patterns:
- "LibGit2Sharp.*"
JsonSchemaNet:
group-by: dependency-name
patterns:
Expand Down
2 changes: 1 addition & 1 deletion .github/skills/dotnet-dev/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ dotnet add ./src/ProjectName/ProjectName.csproj package PackageName
| `GitVersion.Output` | Output formatters (JSON, BuildServer) |
| `GitVersion.BuildAgents` | CI/CD platform integrations |
| `GitVersion.MsBuild` | MSBuild task integration |
| `GitVersion.LibGit2Sharp` | Git repository abstraction |
| `GitVersion.Git.Managed` | Managed Git reads and Git CLI writes |

## Coding Conventions

Expand Down
26 changes: 1 addition & 25 deletions .github/workflows/_artifacts_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,8 @@ jobs:
- name: Set up Docker
uses: $/.github/actions/docker-setup # NOSONAR -- $/ resolves to the running commit.

# Run both backends concurrently in the same job (GitHub Actions parallel steps).
# Each ArtifactsTest sub-test runs in ephemeral --rm containers, so the runs are independent.
- name: '[Test Artifacts] (libgit2)'
background: true
- name: '[Test Artifacts]'
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
env:
GITVERSION_GIT_BACKEND: libgit2
with:
shell: pwsh
timeout_minutes: 30
Expand All @@ -73,22 +68,3 @@ jobs:
--target=ArtifactsTest --arch=${{ inputs.arch }} `
--dotnet_version=${{ matrix.dotnet_version }} `
--docker_distro=${{ matrix.docker_distro }}

- name: '[Test Artifacts] (managed)'
background: true
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
env:
GITVERSION_GIT_BACKEND: managed
with:
shell: pwsh
timeout_minutes: 30
max_attempts: 3
retry_on: error
command: |
dotnet run/artifacts.dll `
--target=ArtifactsTest --arch=${{ inputs.arch }} `
--dotnet_version=${{ matrix.dotnet_version }} `
--docker_distro=${{ matrix.docker_distro }}

- name: Wait for artifact backend tests
wait-all:
17 changes: 1 addition & 16 deletions .github/workflows/_artifacts_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,8 @@ jobs:
name: nuget
path: ${{ github.workspace }}/artifacts/packages/nuget

# In-process tests share a single package install directory, so the two backends
# run sequentially here (not as parallel background steps).
- name: '[Test Artifacts] (libgit2)'
- name: '[Test Artifacts]'
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
env:
GITVERSION_GIT_BACKEND: libgit2
with:
shell: pwsh
timeout_minutes: 30
max_attempts: 3
retry_on: error
command: dotnet run/artifacts.dll --target=Artifacts${{ matrix.package }}Test

- name: '[Test Artifacts] (managed)'
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
env:
GITVERSION_GIT_BACKEND: managed
with:
shell: pwsh
timeout_minutes: 30
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
env:
DOTNET_INSTALL_DIR: "./.dotnet"
DOTNET_ROLL_FORWARD: "Major"
GITVERSION_GIT_BACKEND: managed

jobs:
build:
Expand Down
18 changes: 1 addition & 17 deletions .github/workflows/_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,14 @@ jobs:
- name: Set up Docker
uses: $/.github/actions/docker-setup # NOSONAR -- $/ resolves to the running commit.

# Run both backends concurrently in the same job (GitHub Actions parallel steps).
# Each uses an ephemeral --rm container, so the two runs don't interfere.
- name: Docker Test (libgit2)
- name: Docker Test
if: success() && inputs.publish_images == false
background: true
uses: $/.github/actions/docker-test # NOSONAR -- $/ resolves to the running commit.
with:
arch: ${{ inputs.arch }}
docker_distro: ${{ matrix.docker_distro }}
dotnet_version: ${{ matrix.dotnet_version }}
git_backend: libgit2

- name: Docker Test (managed)
if: success() && inputs.publish_images == false
background: true
uses: $/.github/actions/docker-test # NOSONAR -- $/ resolves to the running commit.
with:
arch: ${{ inputs.arch }}
docker_distro: ${{ matrix.docker_distro }}
dotnet_version: ${{ matrix.dotnet_version }}
git_backend: managed

- name: Wait for docker backend tests
wait-all:

publish:
name: ${{ matrix.docker_distro }} - net${{ matrix.dotnet_version }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/_prepare.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
on:
workflow_call:
outputs:
test_matrix:
description: 'Unit-test project groups generated by Cake'
value: ${{ jobs.set_matrix.outputs.test_matrix }}
docker_distros:
description: 'List of Docker distros'
value: ${{ jobs.set_matrix.outputs.docker_distros }}
Expand Down Expand Up @@ -70,6 +73,7 @@ jobs:
name: Set Matrix
runs-on: ubuntu-24.04
outputs:
test_matrix: ${{ steps.set_matrix.outputs.test_matrix }}
docker_distros: ${{ steps.set_matrix.outputs.docker_distros }}
dotnet_versions: ${{ steps.set_matrix.outputs.dotnet_versions }}
steps:
Expand Down
29 changes: 16 additions & 13 deletions .github/workflows/_unit_tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
workflow_call:
inputs:
dotnet_versions:
test_matrix:
required: true
type: string
publish_coverage:
Expand All @@ -16,23 +16,17 @@ permissions:

jobs:
unit_test:
name: ${{ matrix.os }} - net${{ matrix.dotnet_version }} - ${{ matrix.git_backend }}
name: ${{ matrix.name }}
permissions:
id-token: write
strategy:
fail-fast: false
matrix:
os: [ windows-2025-vs2026, ubuntu-24.04, macos-26 ]
dotnet_version: ${{ fromJson(inputs.dotnet_versions) }}
# Run the suite against both Git backends until libgit2 is removed,
# see https://github.com/GitTools/GitVersion/issues/5031
git_backend: [ libgit2, managed ]
matrix: ${{ fromJson(inputs.test_matrix) }}

runs-on: ${{ matrix.os }}
timeout-minutes: 45
env:
GITVERSION_GIT_BACKEND: ${{ matrix.git_backend }}
TEST_RESULTS: ${{ github.workspace }}/artifacts/test-results/${{ matrix.git_backend }}/attempt-${{ github.run_attempt }}
TEST_RESULTS: ${{ github.workspace }}/artifacts/test-results/attempt-${{ github.run_attempt }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
Expand All @@ -51,6 +45,9 @@ jobs:
id: unit_tests
timeout-minutes: 30
shell: bash
env:
TEST_PROJECTS: ${{ matrix.test_projects }}
TEST_FILTER: ${{ matrix.test_filter }}
run: |
# Explicit bash uses pipefail on every runner. Keep the log outside Cake's Clean target.
preserve_reports() {
Expand All @@ -61,7 +58,15 @@ jobs:
fi
}
trap preserve_reports EXIT
test_arguments=()
if [[ -n "$TEST_PROJECTS" ]]; then
test_arguments+=("--test_projects=$TEST_PROJECTS")
fi
if [[ -n "$TEST_FILTER" ]]; then
test_arguments+=("--test_filter=$TEST_FILTER")
fi
dotnet run/build.dll --target=UnitTest --dotnet_version=${{ matrix.dotnet_version }} --test_results="$TEST_RESULTS" \
"${test_arguments[@]}" \
2>&1 | tee "$RUNNER_TEMP/unit-tests.log"

- name: Explain failed or incomplete test run
Expand All @@ -83,7 +88,7 @@ jobs:
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with:
name: test-results-${{ matrix.os }}-net${{ matrix.dotnet_version }}-${{ matrix.git_backend }}-${{ github.run_id }}-${{ github.run_attempt }}
name: test-results-${{ matrix.os }}-net${{ matrix.dotnet_version }}-${{ matrix.group }}-${{ github.run_id }}-${{ github.run_attempt }}
path: artifacts/test-results/
if-no-files-found: warn
retention-days: 7
Expand All @@ -94,7 +99,6 @@ jobs:
with:
files: artifacts/test-results/**/results.xml
report_type: 'test_results'
flags: ${{ matrix.git_backend }}
use_oidc: true

- name: Upload Coverage
Expand All @@ -103,5 +107,4 @@ jobs:
with:
directory: artifacts/test-results
report_type: 'coverage'
flags: ${{ matrix.git_backend }}
use_oidc: true
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
id-token: write
uses: $/.github/workflows/_unit_tests.yml # NOSONAR -- $/ resolves to the running commit.
with:
dotnet_versions: ${{ needs.prepare.outputs.dotnet_versions }}
test_matrix: ${{ needs.prepare.outputs.test_matrix }}
publish_coverage: ${{ fromJson(needs.publish_flags.outputs.can_publish) }}

artifacts_windows_test:
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The repo has two parallel solution trees:
| `GitVersion.Configuration` | Configuration loading and validation |
| `GitVersion.App` | CLI entry point |
| `GitVersion.BuildAgents` | Platform-specific build agent adapters |
| `GitVersion.LibGit2Sharp` | Git repository access |
| `GitVersion.Git.Managed` | Managed Git reads and Git CLI writes |
| `*Tests` projects | Unit and integration tests |

Build-agent adapters live in `src/GitVersion.BuildAgents/Agents/`. They write `GitVersion_`-prefixed environment variables — preserve that prefix when reading or writing outputs.
Expand All @@ -45,7 +45,7 @@ Build-agent adapters live in `src/GitVersion.BuildAgents/Agents/`. They write `G
| `GitVersion.Normalization` | Normalization plugin |
| `GitVersion.Output` | Output plugin |
| `GitVersion.Common` | Shared utilities |
| `GitVersion.Core.Libgit2Sharp` | Git repository access |
| `GitVersion.Core.Managed` | Managed Git repository access |
| `GitVersion.Cli.Generator` | Source generator for CLI commands |
| `GitVersion.Cli.Generator.Tests` | Generator tests |

Expand Down
45 changes: 45 additions & 0 deletions build/build/Tasks/Package/PackageContentsValidation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.IO.Compression;

namespace Build.Tasks;

internal static class PackageContentsValidation
{
public static void ValidatePackages(IEnumerable<string> toolPackages, IEnumerable<string> msBuildPackages)
{
var tools = toolPackages.ToArray();
var msBuild = msBuildPackages.ToArray();
if (tools.Length == 0 || msBuild.Length == 0)
{
throw new CakeException("Expected both GitVersion.Tool and GitVersion.MsBuild NuGet packages for validation.");
}
foreach (var package in tools.Concat(msBuild))
{
Validate(package);
}
}

public static void Validate(string packagePath)
{
using var archive = ZipFile.OpenRead(packagePath);
foreach (var entry in archive.Entries)
{
var path = entry.FullName.Replace('\\', '/');
if (path.Contains("libgit2", StringComparison.OrdinalIgnoreCase)
|| path.Contains("runtimes/", StringComparison.OrdinalIgnoreCase) && path.Contains("/native/", StringComparison.OrdinalIgnoreCase))
{
throw new CakeException($"Native Git or runtime payload '{path}' is forbidden in {packagePath}.");
}

if (!path.EndsWith(".nuspec", StringComparison.OrdinalIgnoreCase)
&& !path.EndsWith(".deps.json", StringComparison.OrdinalIgnoreCase))
{
continue;
}
using var reader = new StreamReader(entry.Open());
if (reader.ReadToEnd().Contains("LibGit2Sharp", StringComparison.OrdinalIgnoreCase))
{
throw new CakeException($"LibGit2Sharp dependency remains in '{path}' in {packagePath}.");
}
}
}
}
4 changes: 4 additions & 0 deletions build/build/Tasks/Package/PackageNuget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@ private static void PackageWithCli(BuildContext context)

settings.ArgumentCustomization = arg => arg.Append("-p:IsPackaging=true");
context.DotNetPack("./src/GitVersion.MsBuild", settings);

PackageContentsValidation.ValidatePackages(
context.GetFiles($"{Paths.Nuget}/GitVersion.Tool*.nupkg").Select(package => package.FullPath),
context.GetFiles($"{Paths.Nuget}/GitVersion.MsBuild*.nupkg").Select(package => package.FullPath));
}
}
Loading
Loading