Skip to content

Improvements to deployment of production items #695

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

Merged
merged 3 commits into from
Jan 31, 2025
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- LoadProductionsFromDirectory method to help custom deployment scripts load decomposed productions from the repository (#670)
- Added ability to reset head / revert most recent commit (#586)
- Changes deployed through Git are now logged in a new table SourceControl_Git.DeploymentLog

### Fixed
- Fixed not showing warnings on Studio (#660)
Expand All @@ -18,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed Import All options not importing the Embedded Git configuration file
- Improved performance of IDE editing and baselining of decomposed productions
- Fixed Discard / Stash not working on deletes (#688)
- Improved performance of deploying changes to decomposed production items (#690)

## [2.9.0] - 2025-01-09

Expand Down
44 changes: 44 additions & 0 deletions cls/SourceControl/Git/DeploymentLog.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Class SourceControl.Git.DeploymentLog Extends %Persistent [ Owner = {%Developer} ]
{

Property Token As %String [ InitialExpression = {$System.Util.CreateGUID()} ];

Property StartTimestamp As %TimeStamp;

Property EndTimestamp As %TimeStamp;

Property HeadRevision As %String;

Property Status As %Status;

Storage Default
{
<Data name="DeploymentLogDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>Token</Value>
</Value>
<Value name="3">
<Value>StartTimestamp</Value>
</Value>
<Value name="4">
<Value>EndTimestamp</Value>
</Value>
<Value name="5">
<Value>HeadRevision</Value>
</Value>
<Value name="6">
<Value>Status</Value>
</Value>
</Data>
<DataLocation>^SourceContro22B9.DeploymentLogD</DataLocation>
<DefaultData>DeploymentLogDefaultData</DefaultData>
<IdLocation>^SourceContro22B9.DeploymentLogD</IdLocation>
<IndexLocation>^SourceContro22B9.DeploymentLogI</IndexLocation>
<StreamLocation>^SourceContro22B9.DeploymentLogS</StreamLocation>
<Type>%Storage.Persistent</Type>
}

}
31 changes: 23 additions & 8 deletions cls/SourceControl/Git/PullEventHandler.cls
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,29 @@ Method OnPull() As %Status [ Abstract ]
/// <var>pullEventClass</var>: if defined, override the configured pull event class
ClassMethod ForModifications(ByRef files, pullEventClass As %String) As %Status
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tighten with try/catch and double check exception handling of callers (make sure they're using the returned %Status)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved error handling and confirmed that callers are already checking status.

{
set event = $classmethod(
$select(
$data(pullEventClass)#2: pullEventClass,
1: ##class(SourceControl.Git.Utils).PullEventClass())
,"%New")
set event.LocalRoot = ##class(SourceControl.Git.Utils).TempFolder()
merge event.ModifiedFiles = files
quit event.OnPull()
set st = $$$OK
try {
set log = ##class(SourceControl.Git.DeploymentLog).%New()
set log.HeadRevision = ##class(SourceControl.Git.Utils).GetCurrentRevision()
set log.StartTimestamp = $zdatetime($ztimestamp,3)
set st = log.%Save()
quit:$$$ISERR(st)
set event = $classmethod(
$select(
$data(pullEventClass)#2: pullEventClass,
1: ##class(SourceControl.Git.Utils).PullEventClass())
,"%New")
set event.LocalRoot = ##class(SourceControl.Git.Utils).TempFolder()
merge event.ModifiedFiles = files
set st = event.OnPull()
set log.EndTimestamp = $zdatetime($ztimestamp,3)
set log.Status = st
set st = log.%Save()
quit:$$$ISERR(st)
} catch err {
set st = err.AsStatus()
}
quit st
}

/// <var>InternalName</var> may be a comma-delimited string or $ListBuild list
Expand Down
5 changes: 1 addition & 4 deletions cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ ClassMethod Exists(ByRef pFilename) As %Boolean
Return 0
}

/// Adds this item to the list of items that are tracked by source control
ClassMethod AddToServerSideSourceControl(InternalName As %String) As %Status
{
#dim i as %Integer
Expand All @@ -764,10 +765,6 @@ ClassMethod AddToServerSideSourceControl(InternalName As %String) As %Status
continue
}
set @..#Storage@("items", item) = ""
#dim sc as %Status = ..ImportItem(item, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review impact of this on setting timestamps

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some code review and testing - I don't think there's going to be any impact on timestamps. In the original diff that added this #125 the intent was to use this to deploy items added in the pull. Since then we've moved that logic back to the pull event handlers, so this is purely a duplicate. Timestamps will get updated because we call ImportItem() separately in every code path where we call AddToServerSideSourceControl().

if 'sc {
set ec = $$$ADDSC(ec, sc)
}
}
quit ec
}
Expand Down
Loading