@@ -625,12 +625,12 @@ test.serial('Comment on issue/PR without ading a label', async (t) => {
625
625
t . true ( github . isDone ( ) ) ;
626
626
} ) ;
627
627
628
- test . serial ( 'Editing the release to include all release links at the bottom' , async ( t ) => {
628
+ test . serial ( 'Edit the release to include all the release links at the bottom by default ' , async ( t ) => {
629
629
const owner = 'test_user' ;
630
630
const repo = 'test_repo' ;
631
631
const env = { GITHUB_TOKEN : 'github_token' } ;
632
632
const failTitle = 'The automated release is failing 🚨' ;
633
- const pluginConfig = { releasedLabels : false , addReleases : 'bottom' } ;
633
+ const pluginConfig = { releasedLabels : false } ; // The addReleases is omitted
634
634
const prs = [ { number : 1 , pull_request : { } , state : 'closed' } ] ;
635
635
const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
636
636
const nextRelease = { version : '2.0.0' , gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
@@ -682,12 +682,64 @@ test.serial('Editing the release to include all release links at the bottom', as
682
682
t . true ( github . isDone ( ) ) ;
683
683
} ) ;
684
684
685
- test . serial ( 'Editing the release to include all release links at the top ' , async ( t ) => {
685
+ test . serial ( 'Edit the release to not include the release links' , async ( t ) => {
686
686
const owner = 'test_user' ;
687
687
const repo = 'test_repo' ;
688
688
const env = { GITHUB_TOKEN : 'github_token' } ;
689
689
const failTitle = 'The automated release is failing 🚨' ;
690
- const pluginConfig = { releasedLabels : false , addReleases : 'top' } ;
690
+ const pluginConfig = { releasedLabels : false , addReleases : false } ;
691
+ const prs = [ { number : 1 , pull_request : { } , state : 'closed' } ] ;
692
+ const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
693
+ const nextRelease = { version : '2.0.0' , gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
694
+ const lastRelease = { version : '1.0.0' } ;
695
+ const commits = [ { hash : '123' , message : 'Commit 1 message' } ] ;
696
+ const releaseId = 1 ;
697
+ const releases = [
698
+ { name : 'GitHub release' , url : 'https://github.com/release' , id : releaseId } ,
699
+ { name : 'S3' , url : 's3://my-bucket/release-asset' } ,
700
+ { name : 'Docker: docker.io/python:slim' } ,
701
+ ] ;
702
+ const github = authenticate ( env )
703
+ . get ( `/repos/${ owner } /${ repo } ` )
704
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
705
+ . get (
706
+ `/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
707
+ . map ( ( commit ) => commit . hash )
708
+ . join ( '+' ) } `
709
+ )
710
+ . reply ( 200 , { items : prs } )
711
+ . get ( `/repos/${ owner } /${ repo } /pulls/1/commits` )
712
+ . reply ( 200 , [ { sha : commits [ 0 ] . hash } ] )
713
+ . post ( `/repos/${ owner } /${ repo } /issues/1/comments` , { body : / T h i s P R i s i n c l u d e d / } )
714
+ . reply ( 200 , { html_url : 'https://github.com/successcomment-1' } )
715
+ . get (
716
+ `/search/issues?q=${ escape ( 'in:title' ) } +${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:issue' ) } +${ escape (
717
+ 'state:open'
718
+ ) } +${ escape ( failTitle ) } `
719
+ )
720
+ . reply ( 200 , { items : [ ] } ) ;
721
+
722
+ await success ( pluginConfig , {
723
+ env,
724
+ options,
725
+ branch : { name : 'master' } ,
726
+ lastRelease,
727
+ commits,
728
+ nextRelease,
729
+ releases,
730
+ logger : t . context . logger ,
731
+ } ) ;
732
+
733
+ t . true ( t . context . log . calledWith ( 'Added comment to issue #%d: %s' , 1 , 'https://github.com/successcomment-1' ) ) ;
734
+ t . true ( github . isDone ( ) ) ;
735
+ } ) ;
736
+
737
+ test . serial ( 'Edit the release to include all the release links at the bottom' , async ( t ) => {
738
+ const owner = 'test_user' ;
739
+ const repo = 'test_repo' ;
740
+ const env = { GITHUB_TOKEN : 'github_token' } ;
741
+ const failTitle = 'The automated release is failing 🚨' ;
742
+ const pluginConfig = { releasedLabels : false , addReleases : 'bottom' } ;
691
743
const prs = [ { number : 1 , pull_request : { } , state : 'closed' } ] ;
692
744
const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
693
745
const nextRelease = { version : '2.0.0' , gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
@@ -720,7 +772,7 @@ test.serial('Editing the release to include all release links at the top', async
720
772
)
721
773
. reply ( 200 , { items : [ ] } )
722
774
. patch ( `/repos/${ owner } /${ repo } /releases/${ releaseId } ` , {
723
- body : getReleaseLinks ( releases ) . concat ( '\n---\n' , nextRelease . notes ) ,
775
+ body : nextRelease . notes . concat ( '\n---\n' , getReleaseLinks ( releases ) ) ,
724
776
} )
725
777
. reply ( 200 , { html_url : releaseUrl } ) ;
726
778
@@ -739,7 +791,7 @@ test.serial('Editing the release to include all release links at the top', async
739
791
t . true ( github . isDone ( ) ) ;
740
792
} ) ;
741
793
742
- test . serial ( 'Editing the release to include all release links with no additional releases ( top) ' , async ( t ) => {
794
+ test . serial ( 'Edit the release to include all the release links at the top' , async ( t ) => {
743
795
const owner = 'test_user' ;
744
796
const repo = 'test_repo' ;
745
797
const env = { GITHUB_TOKEN : 'github_token' } ;
@@ -750,8 +802,13 @@ test.serial('Editing the release to include all release links with no additional
750
802
const nextRelease = { version : '2.0.0' , gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
751
803
const lastRelease = { version : '1.0.0' } ;
752
804
const commits = [ { hash : '123' , message : 'Commit 1 message' } ] ;
805
+ const releaseUrl = `https://github.com/${ owner } /${ repo } /releases/${ nextRelease . version } ` ;
753
806
const releaseId = 1 ;
754
- const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' , id : releaseId } ] ;
807
+ const releases = [
808
+ { name : 'GitHub release' , url : 'https://github.com/release' , id : releaseId } ,
809
+ { name : 'S3' , url : 's3://my-bucket/release-asset' } ,
810
+ { name : 'Docker: docker.io/python:slim' } ,
811
+ ] ;
755
812
const github = authenticate ( env )
756
813
. get ( `/repos/${ owner } /${ repo } ` )
757
814
. reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
@@ -770,7 +827,11 @@ test.serial('Editing the release to include all release links with no additional
770
827
'state:open'
771
828
) } +${ escape ( failTitle ) } `
772
829
)
773
- . reply ( 200 , { items : [ ] } ) ;
830
+ . reply ( 200 , { items : [ ] } )
831
+ . patch ( `/repos/${ owner } /${ repo } /releases/${ releaseId } ` , {
832
+ body : getReleaseLinks ( releases ) . concat ( '\n---\n' , nextRelease . notes ) ,
833
+ } )
834
+ . reply ( 200 , { html_url : releaseUrl } ) ;
774
835
775
836
await success ( pluginConfig , {
776
837
env,
@@ -787,12 +848,12 @@ test.serial('Editing the release to include all release links with no additional
787
848
t . true ( github . isDone ( ) ) ;
788
849
} ) ;
789
850
790
- test . serial ( 'Editing the release to include all release links with no additional releases (bottom) ' , async ( t ) => {
851
+ test . serial ( 'Edit the release to include all the release links at the top with no additional releases' , async ( t ) => {
791
852
const owner = 'test_user' ;
792
853
const repo = 'test_repo' ;
793
854
const env = { GITHUB_TOKEN : 'github_token' } ;
794
855
const failTitle = 'The automated release is failing 🚨' ;
795
- const pluginConfig = { releasedLabels : false , addReleases : 'bottom ' } ;
856
+ const pluginConfig = { releasedLabels : false , addReleases : 'top ' } ;
796
857
const prs = [ { number : 1 , pull_request : { } , state : 'closed' } ] ;
797
858
const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
798
859
const nextRelease = { version : '2.0.0' , gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
@@ -835,7 +896,58 @@ test.serial('Editing the release to include all release links with no additional
835
896
t . true ( github . isDone ( ) ) ;
836
897
} ) ;
837
898
838
- test . serial ( 'Editing the release to include all release links with no releases' , async ( t ) => {
899
+ test . serial (
900
+ 'Edit the release to include all the release links at the bottom with no additional releases' ,
901
+ async ( t ) => {
902
+ const owner = 'test_user' ;
903
+ const repo = 'test_repo' ;
904
+ const env = { GITHUB_TOKEN : 'github_token' } ;
905
+ const failTitle = 'The automated release is failing 🚨' ;
906
+ const pluginConfig = { releasedLabels : false , addReleases : 'bottom' } ;
907
+ const prs = [ { number : 1 , pull_request : { } , state : 'closed' } ] ;
908
+ const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
909
+ const nextRelease = { version : '2.0.0' , gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
910
+ const lastRelease = { version : '1.0.0' } ;
911
+ const commits = [ { hash : '123' , message : 'Commit 1 message' } ] ;
912
+ const releaseId = 1 ;
913
+ const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' , id : releaseId } ] ;
914
+ const github = authenticate ( env )
915
+ . get ( `/repos/${ owner } /${ repo } ` )
916
+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
917
+ . get (
918
+ `/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
919
+ . map ( ( commit ) => commit . hash )
920
+ . join ( '+' ) } `
921
+ )
922
+ . reply ( 200 , { items : prs } )
923
+ . get ( `/repos/${ owner } /${ repo } /pulls/1/commits` )
924
+ . reply ( 200 , [ { sha : commits [ 0 ] . hash } ] )
925
+ . post ( `/repos/${ owner } /${ repo } /issues/1/comments` , { body : / T h i s P R i s i n c l u d e d / } )
926
+ . reply ( 200 , { html_url : 'https://github.com/successcomment-1' } )
927
+ . get (
928
+ `/search/issues?q=${ escape ( 'in:title' ) } +${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:issue' ) } +${ escape (
929
+ 'state:open'
930
+ ) } +${ escape ( failTitle ) } `
931
+ )
932
+ . reply ( 200 , { items : [ ] } ) ;
933
+
934
+ await success ( pluginConfig , {
935
+ env,
936
+ options,
937
+ branch : { name : 'master' } ,
938
+ lastRelease,
939
+ commits,
940
+ nextRelease,
941
+ releases,
942
+ logger : t . context . logger ,
943
+ } ) ;
944
+
945
+ t . true ( t . context . log . calledWith ( 'Added comment to issue #%d: %s' , 1 , 'https://github.com/successcomment-1' ) ) ;
946
+ t . true ( github . isDone ( ) ) ;
947
+ }
948
+ ) ;
949
+
950
+ test . serial ( 'Edit the release to include all the release links with no releases' , async ( t ) => {
839
951
const owner = 'test_user' ;
840
952
const repo = 'test_repo' ;
841
953
const env = { GITHUB_TOKEN : 'github_token' } ;
@@ -882,7 +994,7 @@ test.serial('Editing the release to include all release links with no releases',
882
994
t . true ( github . isDone ( ) ) ;
883
995
} ) ;
884
996
885
- test . serial ( 'Editing the release with no ID in the release' , async ( t ) => {
997
+ test . serial ( 'Edit the release to include all the release links with no ID in the release' , async ( t ) => {
886
998
const owner = 'test_user' ;
887
999
const repo = 'test_repo' ;
888
1000
const env = { GITHUB_TOKEN : 'github_token' } ;
0 commit comments