Skip to content
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

pulumi: 3.122.0 -> 3.152.0 #382594

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
190 changes: 92 additions & 98 deletions pkgs/by-name/pu/pulumi/package.nix
Original file line number Diff line number Diff line change
@@ -1,133 +1,119 @@
{
stdenv,
lib,
buildGo122Module,
coreutils,
stdenv,
buildGoModule,
fetchFromGitHub,
fetchpatch,
installShellFiles,
git,
buildPackages,
# passthru
runCommand,
makeWrapper,
testers,
pulumi,
pulumiPackages,
}:

# Using go 1.22 as pulumi 3.122.0 will not build with 1.23.
# Issue: https://github.com/NixOS/nixpkgs/issues/351955
# Upgrading pulumi version should fix it, but requires more involved changes, so
# this is a temporary workaround.
# Upgrade: https://github.com/NixOS/nixpkgs/pull/352221
buildGo122Module rec {
buildGoModule rec {
pname = "pulumi";
version = "3.122.0";
version = "3.152.0";

src = fetchFromGitHub {
owner = pname;
repo = pname;
rev = "v${version}";
hash = "sha256-5KHptoQliqPtJ6J5u23ZgRZOdO77BJhZbdc3Cty9Myk=";
owner = "pulumi";
repo = "pulumi";
tag = "v${version}";
hash = "sha256-/cRWj7y6d5sNQRUXg9l7eDAOkUqNGXTzgpWDQdPP8zw=";
# Some tests rely on checkout directory name
name = "pulumi";
};

vendorHash = "sha256-1UyYbmNNHlAeaW6M6AkaQ5Hs25ziHenSs4QjlnUQGjs=";

patches = [
# Fix a test failure, can be dropped in next release (3.100.0)
(fetchpatch {
url = "https://github.com/pulumi/pulumi/commit/6dba7192d134d3b6f7e26dee9205711ccc736fa7.patch";
hash = "sha256-QRN6XnIR2rrqJ4UFYNt/YmIlokTSkGUvnBO/Q9UN8X8=";
stripLen = 1;
})
];
vendorHash = "sha256-JhIyivD+YpUUr9T8roNpINb3Tx8ZElHa+BrpJkyFx60=";

sourceRoot = "${src.name}/pkg";

nativeBuildInputs = [ installShellFiles ];

# Bundle release metadata
nativeCheckInputs = [ git ];

# https://github.com/pulumi/pulumi/blob/3ec1aa75d5bf7103b283f46297321a9a4b1a8a33/.goreleaser.yml#L20-L26
tags = [ "osusergo" ];
ldflags = [
# Omit the symbol table and debug information.
"-s"
# Omit the DWARF symbol table.
"-w"
] ++ importpathFlags;

importpathFlags = [
"-X github.com/pulumi/pulumi/pkg/v3/version.Version=v${version}"
"-X=github.com/pulumi/pulumi/sdk/v3/go/common/version.Version=v${version}"
];

nativeCheckInputs = [
git
excludedPackages = [
"util/generate"
"codegen/gen_program_test"
];

preCheck =
''
# The tests require `version.Version` to be unset
ldflags=''${ldflags//"$importpathFlags"/}

# Create some placeholders for plugins used in tests. Otherwise, Pulumi
# tries to donwload them and fails, resulting in really long test runs
dummyPluginPath=$(mktemp -d)
for name in pulumi-{resource-pkg{A,B},-pkgB}; do
ln -s ${coreutils}/bin/true "$dummyPluginPath/$name"
done

export PATH=$dummyPluginPath''${PATH:+:}$PATH

# Code generation tests also download dependencies from network
rm codegen/{docs,dotnet,go,nodejs,python,schema}/*_test.go
rm -R codegen/{dotnet,go,nodejs,python}/gen_program_test

''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
export PULUMI_HOME=$(mktemp -d)
'';

checkFlags =
let
disabledTests = [
# Flaky test
"TestPendingDeleteOrder"
# Required for user.Current implementation with osusergo on Darwin.
preCheck = ''
export HOME=$TMPDIR USER=nixbld
'';

checkFlags = [
# The tests require `version.Version` (i.e. ldflags) to be unset.
"-ldflags="
# Skip tests that fail in Nix sandbox.
"-skip=^${
lib.concatStringsSep "$|^" [
# Seems to require TTY.
"TestProgressEvents"

# Tries to clone repo: https://github.com/pulumi/test-repo.git
"TestValidateRelativeDirectory"
"TestRepoLookup"
"TestDSConfigureGit"

# Tries to clone repo: github.com/pulumi/templates.git
"TestGenerateOnlyProjectCheck"
# Following tests give this error, not quite sure why:
# Error Trace: /build/pulumi/pkg/engine/lifecycletest/update_plan_test.go:273
# Error: Received unexpected error:
# Unexpected diag message: <{%reset%}>using pulumi-resource-pkgA from $PATH at /build/tmp.bS8caxmTx7/pulumi-resource-pkgA<{%reset%}>
# Test: TestUnplannedDelete
"TestExpectedDelete"
"TestPlannedInputOutputDifferences"
"TestPlannedUpdateChangedStack"
"TestExpectedCreate"
"TestUnplannedDelete"
# Following test gives this error, not sure why:
# --- Expected
# +++ Actual
# @@ -1 +1 @@
# -gcp
# +aws
"TestPluginMapper_MappedNamesDifferFromPulumiName"
"TestProtect"
];
in
[ "-skip=^${lib.concatStringsSep "$|^" disabledTests}$" ];
"TestPulumiNewSetsTemplateTag"
"TestPulumiPromptRuntimeOptions"

# Connects to https://pulumi-testing.vault.azure.net/…
"TestAzureCloudManager"
"TestAzureKeyEditProjectStack"
"TestAzureKeyVaultAutoFix15329"
"TestAzureKeyVaultExistingKey"
"TestAzureKeyVaultExistingKeyState"
"TestAzureKeyVaultExistingState"

# Requires pulumi-yaml
"TestProjectNameDefaults"
"TestProjectNameOverrides"

# Downloads pulumi-resource-random from Pulumi plugin registry.
"TestPluginInstallCancellation"

# Requires language-specific tooling and/or Internet access.
"TestGenerateProgram"
"TestGenerateProgramVersionSelection"
"TestGeneratePackage"
"TestGeneratePackageOne"
"TestGeneratePackageThree"
"TestGeneratePackageTwo"
"TestParseAndRenderDocs"
"TestImportResourceRef"
]
}$"
];

# Allow tests that bind or connect to localhost on macOS.
__darwinAllowLocalNetworking = true;

doInstallCheck = true;
installCheckPhase = ''
PULUMI_SKIP_UPDATE_CHECK=1 $out/bin/pulumi version | grep v${version} > /dev/null
'';
# Use pulumi from the previous stage if we can’t execute compiled binary.
pulumiExe =
if stdenv.buildPlatform.canExecute stdenv.hostPlatform then
"${placeholder "out"}/bin/pulumi"
else
"${buildPackages.pulumi}/bin/pulumi";

postInstall = ''
installShellCompletion --cmd pulumi \
--bash <($out/bin/pulumi gen-completion bash) \
--fish <($out/bin/pulumi gen-completion fish) \
--zsh <($out/bin/pulumi gen-completion zsh)
for shell in bash fish zsh; do
"$pulumiExe" gen-completion $shell >pulumi.$shell
installShellCompletion pulumi.$shell
done
'';

passthru = {
Expand All @@ -144,17 +130,25 @@ buildGo122Module rec {
--suffix PATH : ${lib.makeBinPath (f pulumiPackages)} \
--set LD_LIBRARY_PATH "${lib.getLib stdenv.cc.cc}/lib"
'';
tests = {
version = testers.testVersion {
package = pulumi;
version = "v${version}";
command = "PULUMI_SKIP_UPDATE_CHECK=1 pulumi version";
};
};
};

meta = with lib; {
homepage = "https://pulumi.io/";
meta = {
homepage = "https://www.pulumi.com";
description = "Pulumi is a cloud development platform that makes creating cloud programs easy and productive";
sourceProvenance = [ sourceTypes.fromSource ];
license = licenses.asl20;
platforms = platforms.unix;
maintainers = with maintainers; [
sourceProvenance = [ lib.sourceTypes.fromSource ];
license = lib.licenses.asl20;
mainProgram = "pulumi";
maintainers = with lib.maintainers; [
trundle
veehaitch
tie
];
};
}
107 changes: 66 additions & 41 deletions pkgs/development/python-modules/pulumi/default.nix
Original file line number Diff line number Diff line change
@@ -1,71 +1,96 @@
{
lib,
pkgs,
pulumiPackages,
buildPythonPackage,
pythonOlder,
hatchling,
protobuf,
dill,
grpcio,
pulumi,
isPy27,
dill,
six,
semver,
pip,
pytestCheckHook,
pyyaml,
six,
debugpy,
pip,
pytest,
pytest-asyncio,
pytest-timeout,
python,
}:
buildPythonPackage rec {
inherit (pulumi) version src;
let
inherit (pkgs.pulumi) pname version src;
inherit (pulumiPackages) pulumi-language-python;
sourceRoot = "${src.name}/sdk/python";
in
buildPythonPackage {
inherit
pname
version
src
sourceRoot
;

pname = "pulumi";
format = "setuptools";
outputs = [
"out"
"dev"
];

disabled = isPy27;
pyproject = true;

propagatedBuildInputs = [
semver
disabled = pythonOlder "3.9";

build-system = [ hatchling ];

dependencies = [
protobuf
dill
grpcio
pyyaml
dill
six
];

nativeCheckInputs = [
semver
pyyaml
debugpy
pip
pulumi.pkgs.pulumi-language-python
pytestCheckHook
];

pytestFlagsArray = [ "test/" ];
pythonRelaxDeps = [
"grpcio"
"pip"
"semver"
];

sourceRoot = "${src.name}/sdk/python/lib";
nativeCheckInputs = [
pytest
pytest-asyncio
pytest-timeout
pulumi-language-python
];

# we apply the modifications done in the pulumi/sdk/python/Makefile
# but without the venv code
postPatch = ''
cp ../../README.md .
substituteInPlace setup.py \
--replace "3.0.0" "${version}" \
--replace "grpcio==1.56.2" "grpcio" \
--replace "semver~=2.13" "semver"
# https://github.com/pulumi/pulumi/blob/0acaf8060640fdd892abccf1ce7435cd6aae69fe/sdk/python/scripts/test_fast.sh#L10-L11
# https://github.com/pulumi/pulumi/blob/0acaf8060640fdd892abccf1ce7435cd6aae69fe/sdk/python/scripts/test_fast.sh#L16
installCheckPhase = ''
runHook preInstallCheck
${python.executable} -m pytest --ignore=lib/test/automation lib/test
pushd lib/test_with_mocks
${python.executable} -m pytest
popd
runHook postInstallCheck
'';

# Allow local networking in tests on Darwin
__darwinAllowLocalNetworking = true;

# Verify that the version substitution works
preCheck = ''
pip show "${pname}" | grep "Version: ${version}" > /dev/null \
|| (echo "ERROR: Version substitution seems to be broken"; exit 1)
'';

pythonImportsCheck = [ "pulumi" ];

meta = with lib; {
meta = {
description = "Modern Infrastructure as Code. Any cloud, any language";
homepage = "https://github.com/pulumi/pulumi";
license = licenses.asl20;
maintainers = with maintainers; [ teto ];
homepage = "https://www.pulumi.com";
license = lib.licenses.asl20;
# https://github.com/pulumi/pulumi/issues/16828
broken = versionAtLeast protobuf.version "5";
broken = lib.versionAtLeast protobuf.version "5";
maintainers = with lib.maintainers; [
teto
tie
];
};
}
Loading