Skip to content

Commit bdecd8b

Browse files
James LechtnerJames Lechtner
authored andcommitted
Savepoint of current progress before I nuke the "ci" command
1 parent 8574b03 commit bdecd8b

5 files changed

Lines changed: 106 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- #992: Implement automatic history purge logic
1212
- #973: Enables CORS and JWT configuration for WebApplications in module.xml
1313
- #1110: Add `iriscli` and `ipm` container utility scripts that are auto-installed to `~/.local/bin/` and `~/bin/` so they work both inside and outside of containers (Unix/Linux only)
14+
- #962: Adding zpm "ci" command to install from a lock file
1415

1516
### Fixed
1617
- #1001: The `unmap` and `enable` commands will now only activate CPF merge once after all namespaces have been configured instead after every namespace
@@ -26,7 +27,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2627

2728
### Added
2829
- #1024: Added flag -export-python-deps to publish command
29-
- #962: Adding zpm "ci" command to install from a lock file
3030

3131
### Fixed
3232
- #996: Ensure COS commands execute in exec under a dedicated, isolated context

src/cls/IPM/General/LockFile.cls

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ ClassMethod InstallFromLockFile(
136136
write !, "Repo: "_repoName_" already exists, skipping creating new one from lock file"
137137
}
138138
continue
139-
}
140-
elseif (verbose) {
139+
} elseif (verbose) {
141140
write !, "Creating repo: "_repoName_" from lock file"
142141
}
143142
do ##class(%IPM.Repo.Definition).CollectServerTypes(.types)
@@ -163,6 +162,10 @@ ClassMethod InstallFromLockFile(
163162
set commandInfo("parameters","module") = repository_"/"_depName
164163
set commandInfo("parameters", "version") = version
165164
set commandInfo("data", "LockFileInstallStarted") = 1
165+
166+
set commandInfo("data","cmd") = "ci"
167+
set commandInfo("data","CleanInstall") = 1
168+
166169
do ##class(%IPM.Main).CleanInstall(.commandInfo)
167170
}
168171
}

src/cls/IPM/Main.cls

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ load C:\module\root\path -env C:\path\to\env1.json;C:\path\to\env2.json
293293
<modifier name="synchronous" value="false" deprecated="true" description="DEPRECATED. Dependencies are now always loaded synchronously with independent lifecycle phases doing their own multi-threading as needed." />
294294
<modifier name="force" aliases="f" value="false" description="Allows the user to load a newer version of an existing module without running update steps." />
295295
<modifier name="create-lockfile" aliases="lock" dataAlias="CreateLockFile" dataValue="1" description="Upon load, creates/updates the module's lock file." />
296+
<modifier name="from-lockfile" aliases="ci" dataAlias="LoadFromLockFile" dataValue="1" description="Load the module from the lock file present at the path." />
296297

297298
<!-- Parameters -->
298299
<parameter name="path" required="true" description="Directory on the local filesystem, containing a file named module.xml" />
@@ -811,6 +812,7 @@ generate /my/path -export 00000,PacketName2,IgnorePacket2^00000,PacketName3,Igno
811812

812813
<!-- Modifiers -->
813814
<modifier name="verbose" aliases="v" dataAlias="Verbose" dataValue="1" description="Produces verbose output from the command." />
815+
<modifier name="path" aliases="p" value="true" description="Location of local tarball containing the updated version of the module. Overrides 'version' parameter if present." />
814816
</command>
815817

816818
</commands>
@@ -2398,14 +2400,18 @@ ClassMethod LoadInternal(
23982400
}
23992401
}
24002402

2401-
// When loading a module from a local folder, there might be a <mod root>/.modules/ folder containining dependencies.
2402-
// It's easier to configure a temporary repository than to handle this case in the dependency resolution code.
24032403
set tTargetDirectory = $get(tTargetDirectory, tDirectoryName)
2404-
set dotModules = ##class(%File).NormalizeDirectory(".modules", tTargetDirectory)
2405-
set tmpRepoMgr = ##class(%IPM.General.TempLocalRepoManager).%New(dotModules, 1)
2406-
set tSC = ##class(%IPM.Utils.Module).LoadNewModule(tTargetDirectory, .tParams, , pLog)
2407-
set tSC = $$$ADDSC(tSC, tmpRepoMgr.CleanUp())
2408-
$$$ThrowOnError(tSC)
2404+
if ($get(pCommandInfo("data", "LoadFromLockFile"))) {
2405+
do ##class(%IPM.General.LockFile).InstallFromLockFile(tTargetDirectory, .tParams)
2406+
} else {
2407+
// When loading a module from a local folder, there might be a <mod root>/.modules/ folder containining dependencies.
2408+
// It's easier to configure a temporary repository than to handle this case in the dependency resolution code.
2409+
set dotModules = ##class(%File).NormalizeDirectory(".modules", tTargetDirectory)
2410+
set tmpRepoMgr = ##class(%IPM.General.TempLocalRepoManager).%New(dotModules, 1)
2411+
set tSC = ##class(%IPM.Utils.Module).LoadNewModule(tTargetDirectory, .tParams, , pLog)
2412+
set tSC = $$$ADDSC(tSC, tmpRepoMgr.CleanUp())
2413+
$$$ThrowOnError(tSC)
2414+
}
24092415
}
24102416

24112417
ClassMethod CheckModuleNamespace() As %Status
@@ -2552,10 +2558,17 @@ ClassMethod CleanInstall(ByRef commandInfo) [ Internal ]
25522558
// Indicating to commandInfo that this is a clean install command, not an install or load command. commandInfo will be passed to either Install() or Load() to continue performing the update.
25532559
set commandInfo("data","cmd") = "ci"
25542560
set commandInfo("data","CleanInstall") = 1
2555-
set log = ##class(%IPM.General.HistoryTemp).UpdateInit(moduleName)
2561+
//set log = ##class(%IPM.General.HistoryTemp).UpdateInit(moduleName)
25562562

2557-
// Forward execution to install
2558-
do ..Install(.commandInfo, log)
2563+
// A path to a tarball is specified. Call ..Load() in order to load the newer version of the module.
2564+
set path = $$$GetModifier(pCommandInfo,"path")
2565+
if (path) {
2566+
set pCommandInfo("parameters","path") = path
2567+
do ..Load(.pCommandInfo, log)
2568+
} else {
2569+
// Forward execution to install
2570+
do ..Install(.commandInfo, log)
2571+
}
25592572
}
25602573

25612574
ClassMethod Reinstall(ByRef pCommandInfo) [ Internal ]

tests/integration_tests/Test/PM/Integration/History.cls

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,41 @@ Method TestUpdate()
535535
}
536536
}
537537

538+
Method TestCleanInstall()
539+
{
540+
// Setup repo for "ci" test
541+
set repoName = "lock-file-base"
542+
do ##class(%IPM.Main).Shell("repo -n " _ repoName _ " -fs -path /home/irisowner/zpm/tests/integration_tests/Test/PM/Integration/_data/lock-test/mods-base-cases/")
543+
544+
// Call zpm "ci" on a simple module
545+
set moduleName = "lock-mod-a-no-deps"
546+
set command = "ci " _ moduleName
547+
set sc = ##class(%IPM.Main).Shell(command)
548+
do $$$AssertStatusOK(sc, "Successfully installed " _ moduleName _ " from lock file")
549+
550+
// get history
551+
set rs = ##class(%IPM.General.History).GetHistory(,,1)
552+
while rs.%Next() {
553+
do $$$AssertTrue(rs.%Get("ID") '= "")
554+
do $$$AssertEquals(rs.%Get("Action"), "ci")
555+
do $$$AssertEquals(rs.%Get("Package"), moduleName)
556+
do $$$AssertEquals(rs.%Get("Version_Major"), "1")
557+
do $$$AssertEquals(rs.%Get("Version_Minor"), "0")
558+
do $$$AssertEquals(rs.%Get("Version_Patch"), "0")
559+
do $$$AssertEquals(rs.%Get("UserName"), "irisowner")
560+
do $$$AssertTrue(rs.%Get("TimeStart") '= "")
561+
do $$$AssertTrue(rs.%Get("TimeEnd") '= "")
562+
do $$$AssertEquals(rs.%Get("Success"),1)
563+
do $$$AssertEquals(rs.%Get("Committed"),1)
564+
do $$$AssertEquals(rs.%Get("CommandString"), command)
565+
do $$$AssertEquals(rs.%Get("SourceMoniker"), "filesystem")
566+
do $$$AssertEquals(rs.%Get("SourceName"), repoName)
567+
}
568+
569+
// Remove this test's repo now that the test is over
570+
do ##class(%IPM.Main).Shell("repo -n " _ repoName _ " -fs -path /home/irisowner/zpm/tests/integration_tests/Test/PM/Integration/_data/lock-test/mods-base-cases/")
571+
}
572+
538573
/// Tests that history entries correctly record all phases of module operations.
539574
/// Verifies that:
540575
/// - Load and install operations record 5 phases: Initialize, Reload, Validate, Compile, Activate

tests/integration_tests/Test/PM/Integration/LockFile.cls

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ Method Test08Module2DependenciesSameTransient()
286286
try {
287287
do ..ExecuteGenericLockFileTest(..#ModuleK)
288288
} catch e {
289-
do $$$AssertStatusOK(e.AsStatus(),"An exception occurred in Test09Module2DependenciesSameTransient.")
289+
do $$$AssertStatusOK(e.AsStatus(),"An exception occurred in Test08Module2DependenciesSameTransient.")
290290
}
291291
}
292292

@@ -297,7 +297,47 @@ Method Test09ComplexNestedDependencies()
297297
try {
298298
do ..ExecuteGenericLockFileTest(..#ModuleL)
299299
} catch e {
300-
do $$$AssertStatusOK(e.AsStatus(),"An exception occurred in Test10ComplexNestedDependencies.")
300+
do $$$AssertStatusOK(e.AsStatus(),"An exception occurred in Test09ComplexNestedDependencies.")
301+
}
302+
}
303+
304+
/// Installing from lock file by loading from a packaged tarball
305+
/// Uses Module K
306+
Method Test10InstallViaLoad()
307+
{
308+
try {
309+
set moduleName = ..#ModuleK
310+
311+
set sc = ##class(%IPM.Main).Shell("install " _ moduleName)
312+
do $$$AssertStatusOK(sc, "Successfully installed " _ moduleName)
313+
314+
set packagePath = "/home/irisowner/zpm/tests/integration_tests/Test/PM/Integration/_data/lock-test/package/pack"
315+
set sc = ##class(%IPM.Main).Shell("package " _ moduleName _ " -path " _ packagePath)
316+
do $$$AssertStatusOK(sc, "Successfully packaged " _ moduleName)
317+
318+
set sc = ##class(%IPM.Main).Shell("uninstall -r " _ moduleName)
319+
do $$$AssertStatusOK(sc, "Successfully packaged " _ moduleName _ " and dependencies prior to load")
320+
321+
do $$$LogMessage("GOING TO repo -list")
322+
zpm "repo -list"
323+
324+
set sc = ##class(%IPM.Main).Shell("repo -delete -name lock-file-base")
325+
do $$$AssertStatusOK(sc, "Successfully removed repo lock-file-base prior to load")
326+
set sc = ##class(%IPM.Main).Shell("repo -delete -name lock-file-edge")
327+
do $$$AssertStatusOK(sc, "Successfully removed repo lock-file-edge prior to load")
328+
329+
do $$$LogMessage("GOING TO repo -list")
330+
zpm "repo -list"
331+
332+
set sc = ##class(%IPM.Main).Shell("load -from-lockfile " _ packagePath _ ".tgz")
333+
do $$$AssertStatusOK(sc, "Successfully loaded packaged module from its lock file")
334+
335+
do $$$LogMessage("GOING TO repo -list")
336+
zpm "repo -list"
337+
} catch e {
338+
do $$$LogMessage("GOING TO repo -list")
339+
zpm "repo -list"
340+
do $$$AssertStatusOK(e.AsStatus(),"An exception occurred in Test10InstallViaLoad.")
301341
}
302342
}
303343

0 commit comments

Comments
 (0)