Unverified Commit 5e3fe32d authored by Ryan Mulligan's avatar Ryan Mulligan Committed by GitHub
Browse files

stripe-cli: 1.30.0 -> 1.31.0, maintenance (#448032)

parents d7ef8334 35b85dde
Loading
Loading
Loading
Loading
+49 −29
Original line number Diff line number Diff line
@@ -4,17 +4,24 @@
  fetchFromGitHub,
  installShellFiles,
  stdenv,

  writableTmpDirAsHomeHook,

  buildPackages,
}:

buildGoModule rec {
buildGoModule (finalAttrs: {
  pname = "stripe-cli";
  version = "1.30.0";
  version = "1.31.0";

  # required for tests
  __darwinAllowLocalNetworking = true;

  src = fetchFromGitHub {
    owner = "stripe";
    repo = "stripe-cli";
    rev = "v${version}";
    hash = "sha256-qDrEDP3gDHggXxavMVuVitFN+OWz5WlamePS/1/zlq8=";
    tag = "v${finalAttrs.version}";
    hash = "sha256-fvemd1yo8WOWob/l3TU9lHcFc7OAI/oaX5XEK38vDwo=";
  };
  vendorHash = "sha256-EDdRgApJ7gv/4ma/IfaHi+jjpTPegsUfqHbvoFMn048=";

@@ -23,54 +30,67 @@ buildGoModule rec {
  ldflags = [
    "-s"
    "-w"
    "-X github.com/stripe/stripe-cli/pkg/version.Version=${version}"
    "-X github.com/stripe/stripe-cli/pkg/version.Version=${finalAttrs.version}"
  ];

  nativeCheckInputs = [
    # required by pkg/rpcservice/sample_create_test.go
    writableTmpDirAsHomeHook
  ];

  preCheck = ''
    # the tests expect the Version ldflag not to be set
    unset ldflags

    # requires internet access
    rm pkg/cmd/plugin_cmds_test.go
    rm pkg/cmd/resources_test.go
    rm pkg/cmd/root_test.go

    # TODO: no clue why it's broken (1.17.1), remove for now.
    rm pkg/login/client_login_test.go
    rm pkg/git/editor_test.go
    rm pkg/rpcservice/sample_create_test.go
  ''
  +
    lib.optionalString
      (
        # delete plugin tests on all platforms but exact matches
        # https://github.com/stripe/stripe-cli/issues/850
        # https://github.com/stripe/stripe-cli/blob/e3020d2e2df9c731b2f51df3aa53bf16383e863f/pkg/plugins/test_artifacts/plugins.toml
        !lib.lists.any (platform: lib.meta.platformMatch stdenv.hostPlatform platform) [
          "x86_64-linux"
          "x86_64-darwin"
          "aarch64-darwin"
        ]
      )
      ''
        rm pkg/plugins/plugin_test.go
      '';

  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
    installShellCompletion --cmd stripe \
      --bash <($out/bin/stripe completion --write-to-stdout --shell bash) \
      --zsh <($out/bin/stripe completion --write-to-stdout --shell zsh)
  '';
  checkFlags =
    let
      skippedTests = [
        # network access
        "TestConflictWithPluginCommand"
        "TestLogin"

  doInstallCheck = true;
  installCheckPhase = ''
    runHook preInstallCheck
    $out/bin/stripe --help
    $out/bin/stripe --version | grep "${version}"
    runHook postInstallCheck
        # not providing git or the various editors it wants to call
        "TestGetOpenEditorCommand"
        "TestGetDefaultGitEditor"
      ];
    in
    [ "-skip=^${lib.concatStringsSep "$|^" skippedTests}$" ];

  postInstall =
    let
      inherit (finalAttrs.meta) mainProgram;
      exe =
        if stdenv.buildPlatform.canExecute stdenv.hostPlatform then
          "$out/bin/${mainProgram}"
        else
          lib.getExe buildPackages.stripe-cli;
    in
    ''
      # only outputs bash and zsh completion
      installShellCompletion --cmd ${mainProgram} \
        --bash <(${exe} completion --write-to-stdout --shell bash) \
        --zsh <(${exe} completion --write-to-stdout --shell zsh)
    '';

  meta = {
    homepage = "https://stripe.com/docs/stripe-cli";
    changelog = "https://github.com/stripe/stripe-cli/releases/tag/v${version}";
    changelog = "https://github.com/stripe/stripe-cli/releases/tag/${finalAttrs.src.tag}";
    description = "Command-line tool for Stripe";
    longDescription = ''
      The Stripe CLI helps you build, test, and manage your Stripe integration
@@ -90,4 +110,4 @@ buildGoModule rec {
    ];
    mainProgram = "stripe";
  };
}
})