From eccf043ba0c882822869eb9069f32ca697bd792d Mon Sep 17 00:00:00 2001 From: SealabJaster Date: Tue, 10 Mar 2020 09:36:59 +0000 Subject: [PATCH] Fix things and shiz --- source/aim/deploy/commands.d | 12 +++++++++--- source/aim/deploy/triggers.d | 8 ++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/source/aim/deploy/commands.d b/source/aim/deploy/commands.d index 8733731..f188b20 100644 --- a/source/aim/deploy/commands.d +++ b/source/aim/deploy/commands.d @@ -196,6 +196,9 @@ final class AimDeployTriggerCheck : BaseCommand private IAimCliConfig!AimDeployConfig _deployConf; private ICommandLineInterface _cli; + @CommandNamedArg("no-post-deploy", "Don't trigger post deployments for triggers. Useful for debugging.") + Nullable!bool noPostDeploy; + this(IAimDeployTriggerFactory factory, IAimCliConfig!AimDeployConfig deployConf, ICommandLineInterface cli) { this._triggerFactory = factory; @@ -231,9 +234,12 @@ final class AimDeployTriggerCheck : BaseCommand status = this._cli.parseAndExecute(["deploy", "trigger"], IgnoreFirstArg.no); else Shell.verboseLogfln("No triggers were successful"); - - foreach(trigger; successfulTriggers) - trigger.onPostDeploy(status == 0); + + if(!this.noPostDeploy.get(false)) + { + foreach(trigger; successfulTriggers) + trigger.onPostDeploy(status == 0); + } return status; } diff --git a/source/aim/deploy/triggers.d b/source/aim/deploy/triggers.d index 6f8f38f..d7f5b2b 100644 --- a/source/aim/deploy/triggers.d +++ b/source/aim/deploy/triggers.d @@ -81,7 +81,7 @@ final class GithubAimDeployTrigger : IAimDeployTrigger this._githubConf.edit((scope ref conf) { if(conf.lastDeploymentTime.length == 0) - conf.lastDeploymentTime = Clock.currTime.toISOString(); + conf.lastDeploymentTime = (new SysTime(0)).toISOExtString(); }); } @@ -123,12 +123,12 @@ final class GithubAimDeployTrigger : IAimDeployTrigger ).readJson(); Shell.verboseLogfln("Response: %s", response.toPrettyString()); - auto lastDeployTime = SysTime.fromISOString(this._githubConf.value.lastDeploymentTime); + auto lastDeployTime = SysTime.fromISOExtString(this._githubConf.value.lastDeploymentTime); auto nodes = response["data"]["repository"]["deployments"]["nodes"]; auto firstPendingProduction = nodes.byValue .filter!(v => v["environment"].to!string == "production" // TODO: This should be a config option. && v["state"].to!string == "PENDING" // TODO: Arguably this too, but it's less important. - && SysTime.fromISOExtString(v["createdAt"].to!string()) > lastDeployTime + && SysTime.fromISOExtString(v["createdAt"].to!string()[0..$-1] ~ ".0000000" ~ "Z") > lastDeployTime ); if(firstPendingProduction.empty) @@ -145,7 +145,7 @@ final class GithubAimDeployTrigger : IAimDeployTrigger this._githubConf.edit((scope ref conf) { conf.deploymentId = databaseId; // So onPostDeploy knows what ID to use. - conf.lastDeploymentTime = deployment["createdAt"].to!string(); + conf.lastDeploymentTime = deployment["createdAt"].to!string()[0..$-1] ~ ".0000000" ~ "Z"; }); // Find the ref, as that's being used as the image tag.