From 01ba6830dec8c9de82a24eebffd15f51414867b1 Mon Sep 17 00:00:00 2001 From: 06kellyjac Date: Wed, 18 Jun 2025 14:04:56 +0100 Subject: [PATCH 1/2] go-mockery: 2.53.3 -> 3.4.0 Diff: https://github.com/vektra/mockery/compare/refs/tags/v2.53.3...refs/tags/v3.4.0 Move to finalAttrs func Replace version check test with version check hook Added release note --- doc/release-notes/rl-2511.section.md | 2 + pkgs/by-name/go/go-mockery/package.nix | 94 ++++++++++++-------------- 2 files changed, 45 insertions(+), 51 deletions(-) diff --git a/doc/release-notes/rl-2511.section.md b/doc/release-notes/rl-2511.section.md index 1f28d5222632..3538d45a7817 100644 --- a/doc/release-notes/rl-2511.section.md +++ b/doc/release-notes/rl-2511.section.md @@ -43,6 +43,8 @@ of the [4.3 release](https://github.com/netbox-community/netbox/releases/tag/v4.2.0), make the required changes to your database, if needed, then upgrade by setting `services.netbox.package = pkgs.netbox_4_3;` in your configuration. +- `go-mockery` has been updated to v3. For migration instructions see the [upstream documentation](https://vektra.github.io/mockery/latest/v3/). + ## Other Notable Changes {#sec-nixpkgs-release-25.11-notable-changes} diff --git a/pkgs/by-name/go/go-mockery/package.nix b/pkgs/by-name/go/go-mockery/package.nix index 99cd99afeaaa..ecc0dddaf54e 100644 --- a/pkgs/by-name/go/go-mockery/package.nix +++ b/pkgs/by-name/go/go-mockery/package.nix @@ -1,80 +1,72 @@ { lib, - buildGoModule, # sync with go below, update to latest release + stdenv, + buildGoModule, fetchFromGitHub, - - # passthru test - go-mockery, - runCommand, - go, + versionCheckHook, + go-task, + gotestsum, }: -buildGoModule rec { +buildGoModule (finalAttrs: { pname = "go-mockery"; - version = "2.53.3"; + version = "3.4.0"; src = fetchFromGitHub { owner = "vektra"; repo = "mockery"; - rev = "v${version}"; - sha256 = "sha256-X0cHpv4o6pzgjg7+ULCuFkspeff95WFtJbVHqy4LxAg="; + tag = "v${finalAttrs.version}"; + hash = "sha256-qcK0FXtAL7kJ+dotthmnMcGa9wu97UsDKBoKy5lD2W4="; }; + proxyVendor = true; + vendorHash = "sha256-Xy2w61ATNDOZKtdekeA9NSdyJq2/eiEZ9iJ3PDSUm9Q="; + ldflags = [ "-s" "-w" - "-X" - "github.com/vektra/mockery/v${lib.versions.major version}/pkg/logging.SemVer=v${version}" + "-X github.com/vektra/mockery/v${lib.versions.major finalAttrs.version}/internal/logging.SemVer=v${finalAttrs.version}" ]; env.CGO_ENABLED = false; - proxyVendor = true; - vendorHash = "sha256-AQY4x2bLqMwHIjoKHzEm1hebR29gRs3LJN8i00Uup5o="; - subPackages = [ "." ]; - preCheck = '' - # check all paths - unset subPackages + nativeCheckInputs = [ + versionCheckHook + go-task + gotestsum + ]; - substituteInPlace ./pkg/generator_test.go --replace-fail 0.0.0-dev ${version} - substituteInPlace ./pkg/logging/logging_test.go --replace-fail v0.0 v${lib.versions.majorMinor version} + prePatch = '' + # remove test.ci's dependency on lint since we don't need it and + # it tries to use remote golangci-lint + substituteInPlace Taskfile.yml \ + --replace-fail "deps: [lint]" "" \ + --replace-fail "go run gotest.tools/gotestsum" "gotestsum" + + # patch scripts used in e2e testing + patchShebangs e2e ''; - passthru.tests = { - generateMock = - runCommand "${pname}-test" - { - nativeBuildInputs = [ go-mockery ]; - buildInputs = [ go ]; - } - '' - if [[ $(${meta.mainProgram} --version) != *"${version}"* ]]; then - echo "Error: program version does not match package version" - exit 1 - fi + checkPhase = '' + runHook preCheck - export HOME=$TMPDIR + ${ + # TestRemoteTemplates/schema_validation_OK fails only on x86_64-darwin + (lib.optionalString ( + stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86 + ) "rm -rf e2e/test_remote_templates/") + } + # run unit tests and e2e tests plus pre-gen necessary mocks + task test.ci - cat < foo.go - package main + runHook postCheck + ''; - type Foo interface { - Bark() string - } - EOF - - ${meta.mainProgram} --name Foo --dir . - - if [[ ! -f "mocks/Foo.go" ]]; then - echo "Error: mocks/Foo.go was not generated by ${pname}" - exit 1 - fi - - touch $out - ''; - }; + doInstallCheck = true; + versionCheckProgram = "${placeholder "out"}/bin/mockery"; + versionCheckProgramArg = "version"; meta = { homepage = "https://github.com/vektra/mockery"; @@ -86,4 +78,4 @@ buildGoModule rec { mainProgram = "mockery"; license = lib.licenses.bsd3; }; -} +}) From 6092e7e4258569419365593c66fd11a96a1668c5 Mon Sep 17 00:00:00 2001 From: 06kellyjac Date: Wed, 18 Jun 2025 15:35:19 +0100 Subject: [PATCH 2/2] go-mockery_2: init at 2.53.3 Added go-mockery_2 to give users options while v2 is still supported upstream. --- doc/release-notes/rl-2511.section.md | 2 +- pkgs/by-name/gi/git-team/package.nix | 4 +- pkgs/by-name/go/go-mockery_2/package.nix | 51 ++++++++++++++++++++++++ pkgs/by-name/op/opencloud/package.nix | 4 +- 4 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 pkgs/by-name/go/go-mockery_2/package.nix diff --git a/doc/release-notes/rl-2511.section.md b/doc/release-notes/rl-2511.section.md index 3538d45a7817..3871e9ad9a57 100644 --- a/doc/release-notes/rl-2511.section.md +++ b/doc/release-notes/rl-2511.section.md @@ -43,7 +43,7 @@ of the [4.3 release](https://github.com/netbox-community/netbox/releases/tag/v4.2.0), make the required changes to your database, if needed, then upgrade by setting `services.netbox.package = pkgs.netbox_4_3;` in your configuration. -- `go-mockery` has been updated to v3. For migration instructions see the [upstream documentation](https://vektra.github.io/mockery/latest/v3/). +- `go-mockery` has been updated to v3. For migration instructions see the [upstream documentation](https://vektra.github.io/mockery/latest/v3/). If v2 is still required `go-mockery_v2` has been added but will be removed on or before 2029-12-31 in-line with it's [upstream support lifecycle](https://vektra.github.io/mockery/ ## Other Notable Changes {#sec-nixpkgs-release-25.11-notable-changes} diff --git a/pkgs/by-name/gi/git-team/package.nix b/pkgs/by-name/gi/git-team/package.nix index 081c8dc5e71d..6fb27115e1a4 100644 --- a/pkgs/by-name/gi/git-team/package.nix +++ b/pkgs/by-name/gi/git-team/package.nix @@ -2,7 +2,7 @@ lib, buildGoModule, fetchFromGitHub, - go-mockery, + go-mockery_2, installShellFiles, }: @@ -20,7 +20,7 @@ buildGoModule rec { vendorHash = "sha256-NTOUL1oE2IhgLyYYHwRCMW5yCxIRxUwqkfuhSSBXf6A="; nativeBuildInputs = [ - go-mockery + go-mockery_2 installShellFiles ]; diff --git a/pkgs/by-name/go/go-mockery_2/package.nix b/pkgs/by-name/go/go-mockery_2/package.nix new file mode 100644 index 000000000000..09243bb05618 --- /dev/null +++ b/pkgs/by-name/go/go-mockery_2/package.nix @@ -0,0 +1,51 @@ +{ + lib, + buildGoModule, + fetchFromGitHub, + versionCheckHook, + go-task, + gotestsum, + getent, +}: + +buildGoModule (finalAttrs: { + pname = "go-mockery_2"; + # supported upstream until 2029-12-31 + # https://vektra.github.io/mockery/latest/v3/#v2-support-lifecycle + version = "2.53.3"; + + src = fetchFromGitHub { + owner = "vektra"; + repo = "mockery"; + tag = "v${finalAttrs.version}"; + hash = "sha256-X0cHpv4o6pzgjg7+ULCuFkspeff95WFtJbVHqy4LxAg="; + }; + + proxyVendor = true; + vendorHash = "sha256-AQY4x2bLqMwHIjoKHzEm1hebR29gRs3LJN8i00Uup5o="; + + ldflags = [ + "-s" + "-w" + "-X github.com/vektra/mockery/v${lib.versions.major finalAttrs.version}/pkg/logging.SemVer=v${finalAttrs.version}" + ]; + + env.CGO_ENABLED = false; + + subPackages = [ "." ]; + + nativeCheckInputs = [ + versionCheckHook + ]; + + meta = { + homepage = "https://github.com/vektra/mockery"; + description = "Mock code autogenerator for Golang - v2"; + maintainers = with lib.maintainers; [ + fbrs + jk + ]; + mainProgram = "mockery"; + license = lib.licenses.bsd3; + }; +}) diff --git a/pkgs/by-name/op/opencloud/package.nix b/pkgs/by-name/op/opencloud/package.nix index 38b2c3b12e95..fba36cf7d518 100644 --- a/pkgs/by-name/op/opencloud/package.nix +++ b/pkgs/by-name/op/opencloud/package.nix @@ -6,7 +6,7 @@ ncurses, gettext, pigeon, - go-mockery, + go-mockery_2, protoc-go-inject-tag, libxcrypt, vips, @@ -76,7 +76,7 @@ buildGoModule rec { ncurses gettext pigeon - go-mockery + go-mockery_2 protoc-go-inject-tag pkg-config ];