@@ -146,7 +146,7 @@ describe('Deploy to ECS', () => {
146
146
} ) ;
147
147
} ) ;
148
148
149
- test ( 'registers the task definition contents and updates the service' , async ( ) => {
149
+ test ( 'registers the task definition contents and updates the service' , async ( ) => {
150
150
await run ( ) ;
151
151
expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 ) ;
152
152
expect ( mockEcsRegisterTaskDef ) . toHaveBeenNthCalledWith ( 1 , { family : 'task-def-family' } ) ;
@@ -158,7 +158,8 @@ describe('Deploy to ECS', () => {
158
158
expect ( mockEcsUpdateService ) . toHaveBeenNthCalledWith ( 1 , {
159
159
cluster : 'cluster-789' ,
160
160
service : 'service-456' ,
161
- taskDefinition : 'task:def:arn'
161
+ taskDefinition : 'task:def:arn' ,
162
+ forceNewDeployment : false
162
163
} ) ;
163
164
expect ( mockEcsWaiter ) . toHaveBeenCalledTimes ( 0 ) ;
164
165
expect ( core . info ) . toBeCalledWith ( "Deployment started. Watch this deployment's progress in the Amazon ECS console: https://console.aws.amazon.com/ecs/home?region=fake-region#/clusters/cluster-789/services/service-456/events" ) ;
@@ -497,6 +498,7 @@ describe('Deploy to ECS', () => {
497
498
. mockReturnValueOnce ( 'cluster-789' ) // cluster
498
499
. mockReturnValueOnce ( 'false' ) // wait-for-service-stability
499
500
. mockReturnValueOnce ( '' ) // wait-for-minutes
501
+ . mockReturnValueOnce ( '' ) // force-new-deployment
500
502
. mockReturnValueOnce ( '/hello/appspec.json' ) // codedeploy-appspec
501
503
. mockReturnValueOnce ( 'MyApplication' ) // codedeploy-application
502
504
. mockReturnValueOnce ( 'MyDeploymentGroup' ) ; // codedeploy-deployment-group
@@ -608,7 +610,7 @@ describe('Deploy to ECS', () => {
608
610
expect ( mockEcsWaiter ) . toHaveBeenCalledTimes ( 0 ) ;
609
611
} ) ;
610
612
611
- test ( 'registers the task definition contents at an absolute path' , async ( ) => {
613
+ test ( 'registers the task definition contents at an absolute path' , async ( ) => {
612
614
core . getInput = jest . fn ( ) . mockReturnValueOnce ( '/hello/task-definition.json' ) ;
613
615
fs . readFileSync . mockImplementation ( ( pathInput , encoding ) => {
614
616
if ( encoding != 'utf8' ) {
@@ -649,7 +651,8 @@ describe('Deploy to ECS', () => {
649
651
expect ( mockEcsUpdateService ) . toHaveBeenNthCalledWith ( 1 , {
650
652
cluster : 'cluster-789' ,
651
653
service : 'service-456' ,
652
- taskDefinition : 'task:def:arn'
654
+ taskDefinition : 'task:def:arn' ,
655
+ forceNewDeployment : false
653
656
} ) ;
654
657
expect ( mockEcsWaiter ) . toHaveBeenNthCalledWith ( 1 , 'servicesStable' , {
655
658
services : [ 'service-456' ] ,
@@ -668,7 +671,7 @@ describe('Deploy to ECS', () => {
668
671
. mockReturnValueOnce ( 'service-456' ) // service
669
672
. mockReturnValueOnce ( 'cluster-789' ) // cluster
670
673
. mockReturnValueOnce ( 'TRUE' ) // wait-for-service-stability
671
- . mockReturnValue ( '60' ) ; // wait-for-minutes
674
+ . mockReturnValueOnce ( '60' ) ; // wait-for-minutes
672
675
673
676
await run ( ) ;
674
677
expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 ) ;
@@ -682,7 +685,8 @@ describe('Deploy to ECS', () => {
682
685
expect ( mockEcsUpdateService ) . toHaveBeenNthCalledWith ( 1 , {
683
686
cluster : 'cluster-789' ,
684
687
service : 'service-456' ,
685
- taskDefinition : 'task:def:arn'
688
+ taskDefinition : 'task:def:arn' ,
689
+ forceNewDeployment : false
686
690
} ) ;
687
691
expect ( mockEcsWaiter ) . toHaveBeenNthCalledWith ( 1 , 'servicesStable' , {
688
692
services : [ 'service-456' ] ,
@@ -701,7 +705,7 @@ describe('Deploy to ECS', () => {
701
705
. mockReturnValueOnce ( 'service-456' ) // service
702
706
. mockReturnValueOnce ( 'cluster-789' ) // cluster
703
707
. mockReturnValueOnce ( 'TRUE' ) // wait-for-service-stability
704
- . mockReturnValue ( '1000' ) ; // wait-for-minutes
708
+ . mockReturnValueOnce ( '1000' ) ; // wait-for-minutes
705
709
706
710
await run ( ) ;
707
711
expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 ) ;
@@ -715,7 +719,8 @@ describe('Deploy to ECS', () => {
715
719
expect ( mockEcsUpdateService ) . toHaveBeenNthCalledWith ( 1 , {
716
720
cluster : 'cluster-789' ,
717
721
service : 'service-456' ,
718
- taskDefinition : 'task:def:arn'
722
+ taskDefinition : 'task:def:arn' ,
723
+ forceNewDeployment : false
719
724
} ) ;
720
725
expect ( mockEcsWaiter ) . toHaveBeenNthCalledWith ( 1 , 'servicesStable' , {
721
726
services : [ 'service-456' ] ,
@@ -727,6 +732,33 @@ describe('Deploy to ECS', () => {
727
732
} ) ;
728
733
} ) ;
729
734
735
+ test ( 'force new deployment' , async ( ) => {
736
+ core . getInput = jest
737
+ . fn ( )
738
+ . mockReturnValueOnce ( 'task-definition.json' ) // task-definition
739
+ . mockReturnValueOnce ( 'service-456' ) // service
740
+ . mockReturnValueOnce ( 'cluster-789' ) // cluster
741
+ . mockReturnValueOnce ( 'false' ) // wait-for-service-stability
742
+ . mockReturnValueOnce ( '' ) // wait-for-minutes
743
+ . mockReturnValueOnce ( true ) ; // force-new-deployment
744
+
745
+ await run ( ) ;
746
+ expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 ) ;
747
+
748
+ expect ( mockEcsRegisterTaskDef ) . toHaveBeenNthCalledWith ( 1 , { family : 'task-def-family' } ) ;
749
+ expect ( core . setOutput ) . toHaveBeenNthCalledWith ( 1 , 'task-definition-arn' , 'task:def:arn' ) ;
750
+ expect ( mockEcsDescribeServices ) . toHaveBeenNthCalledWith ( 1 , {
751
+ cluster : 'cluster-789' ,
752
+ services : [ 'service-456' ]
753
+ } ) ;
754
+ expect ( mockEcsUpdateService ) . toHaveBeenNthCalledWith ( 1 , {
755
+ cluster : 'cluster-789' ,
756
+ service : 'service-456' ,
757
+ taskDefinition : 'task:def:arn' ,
758
+ forceNewDeployment : true
759
+ } ) ;
760
+ } ) ;
761
+
730
762
test ( 'defaults to the default cluster' , async ( ) => {
731
763
core . getInput = jest
732
764
. fn ( )
@@ -745,7 +777,8 @@ describe('Deploy to ECS', () => {
745
777
expect ( mockEcsUpdateService ) . toHaveBeenNthCalledWith ( 1 , {
746
778
cluster : 'default' ,
747
779
service : 'service-456' ,
748
- taskDefinition : 'task:def:arn'
780
+ taskDefinition : 'task:def:arn' ,
781
+ forceNewDeployment : false
749
782
} ) ;
750
783
} ) ;
751
784
@@ -847,7 +880,6 @@ describe('Deploy to ECS', () => {
847
880
expect ( core . setFailed ) . toBeCalledWith ( 'Unsupported deployment controller: EXTERNAL' ) ;
848
881
} ) ;
849
882
850
-
851
883
test ( 'error is caught if task def registration fails' , async ( ) => {
852
884
mockEcsRegisterTaskDef . mockImplementation ( ( ) => {
853
885
throw new Error ( "Could not parse" ) ;
@@ -859,4 +891,4 @@ describe('Deploy to ECS', () => {
859
891
expect ( core . setFailed ) . toHaveBeenNthCalledWith ( 1 , 'Failed to register task definition in ECS: Could not parse' ) ;
860
892
expect ( core . setFailed ) . toHaveBeenNthCalledWith ( 2 , 'Could not parse' ) ;
861
893
} ) ;
862
- } ) ;
894
+ } ) ;
0 commit comments