@@ -3719,12 +3719,12 @@ describe('json', () => {
3719
3719
} ) ;
3720
3720
} ) ;
3721
3721
3722
- describe ( 'bake ' , ( ) => {
3722
+ describe ( 'bakeFile ' , ( ) => {
3723
3723
// prettier-ignore
3724
3724
// eslint-disable-next-line jest/expect-expect
3725
3725
test . each ( [
3726
3726
[
3727
- 'bake01 ' ,
3727
+ 'bakeFile01 ' ,
3728
3728
'event_push_dev.env' ,
3729
3729
{
3730
3730
images : [ 'user/app' ] ,
@@ -3747,6 +3747,16 @@ describe('bake', () => {
3747
3747
"user/app:custom" ,
3748
3748
"user/app:tags"
3749
3749
] ,
3750
+ "args" : {
3751
+ "DOCKER_META_IMAGES" : "user/app" ,
3752
+ "DOCKER_META_VERSION" : "dev" ,
3753
+ }
3754
+ }
3755
+ }
3756
+ } ,
3757
+ {
3758
+ "target" : {
3759
+ "docker-metadata-action" : {
3750
3760
"labels" : {
3751
3761
"org.opencontainers.image.created" : "2020-01-10T00:30:00.000Z" ,
3752
3762
"org.opencontainers.image.description" : "This your first repo!" ,
@@ -3756,17 +3766,13 @@ describe('bake', () => {
3756
3766
"org.opencontainers.image.title" : "Hello-World" ,
3757
3767
"org.opencontainers.image.url" : "https://github.com/octocat/Hello-World" ,
3758
3768
"org.opencontainers.image.version" : "dev"
3759
- } ,
3760
- "args" : {
3761
- "DOCKER_META_IMAGES" : "user/app" ,
3762
- "DOCKER_META_VERSION" : "dev" ,
3763
3769
}
3764
3770
}
3765
3771
}
3766
3772
}
3767
3773
] ,
3768
3774
[
3769
- 'bake02 ' ,
3775
+ 'bakeFile02 ' ,
3770
3776
'event_push_dev.env' ,
3771
3777
{
3772
3778
images : [ 'user/app' ] ,
@@ -3782,6 +3788,16 @@ describe('bake', () => {
3782
3788
"user/app:dev" ,
3783
3789
"user/app:my" ,
3784
3790
] ,
3791
+ "args" : {
3792
+ "DOCKER_META_IMAGES" : "user/app" ,
3793
+ "DOCKER_META_VERSION" : "dev" ,
3794
+ }
3795
+ }
3796
+ }
3797
+ } ,
3798
+ {
3799
+ "target" : {
3800
+ "docker-metadata-action" : {
3785
3801
"labels" : {
3786
3802
"org.opencontainers.image.created" : "2020-01-10T00:30:00.000Z" ,
3787
3803
"org.opencontainers.image.description" : "This your first repo!" ,
@@ -3791,17 +3807,13 @@ describe('bake', () => {
3791
3807
"org.opencontainers.image.title" : "Hello-World" ,
3792
3808
"org.opencontainers.image.url" : "https://github.com/octocat/Hello-World" ,
3793
3809
"org.opencontainers.image.version" : "dev"
3794
- } ,
3795
- "args" : {
3796
- "DOCKER_META_IMAGES" : "user/app" ,
3797
- "DOCKER_META_VERSION" : "dev" ,
3798
3810
}
3799
3811
}
3800
3812
}
3801
3813
}
3802
3814
] ,
3803
3815
[
3804
- 'bake03 ' ,
3816
+ 'bakeFile03 ' ,
3805
3817
'event_tag_release1.env' ,
3806
3818
{
3807
3819
images : [ 'user/app' ] ,
@@ -3823,6 +3835,16 @@ describe('bake', () => {
3823
3835
"user/app:tags" ,
3824
3836
"user/app:latest"
3825
3837
] ,
3838
+ "args" : {
3839
+ "DOCKER_META_IMAGES" : "user/app" ,
3840
+ "DOCKER_META_VERSION" : "release1" ,
3841
+ }
3842
+ }
3843
+ }
3844
+ } ,
3845
+ {
3846
+ "target" : {
3847
+ "meta" : {
3826
3848
"labels" : {
3827
3849
"org.opencontainers.image.created" : "2020-01-10T00:30:00.000Z" ,
3828
3850
"org.opencontainers.image.description" : "This your first repo!" ,
@@ -3832,17 +3854,13 @@ describe('bake', () => {
3832
3854
"org.opencontainers.image.title" : "Hello-World" ,
3833
3855
"org.opencontainers.image.url" : "https://github.com/octocat/Hello-World" ,
3834
3856
"org.opencontainers.image.version" : "release1"
3835
- } ,
3836
- "args" : {
3837
- "DOCKER_META_IMAGES" : "user/app" ,
3838
- "DOCKER_META_VERSION" : "release1" ,
3839
3857
}
3840
3858
}
3841
3859
}
3842
3860
}
3843
3861
] ,
3844
3862
[
3845
- 'bake04 ' ,
3863
+ 'bakeFile04 ' ,
3846
3864
'event_tag_20200110-RC2.env' ,
3847
3865
{
3848
3866
images : [ 'user/app' ] ,
@@ -3865,6 +3883,16 @@ describe('bake', () => {
3865
3883
"user/app:custom" ,
3866
3884
"user/app:tags"
3867
3885
] ,
3886
+ "args" : {
3887
+ "DOCKER_META_IMAGES" : "user/app" ,
3888
+ "DOCKER_META_VERSION" : "20200110" ,
3889
+ }
3890
+ }
3891
+ }
3892
+ } ,
3893
+ {
3894
+ "target" : {
3895
+ "docker-metadata-action" : {
3868
3896
"labels" : {
3869
3897
"org.opencontainers.image.created" : "2020-01-10T00:30:00.000Z" ,
3870
3898
"org.opencontainers.image.description" : "This your first repo!" ,
@@ -3874,17 +3902,13 @@ describe('bake', () => {
3874
3902
"org.opencontainers.image.title" : "Hello-World" ,
3875
3903
"org.opencontainers.image.url" : "https://github.com/octocat/Hello-World" ,
3876
3904
"org.opencontainers.image.version" : "20200110"
3877
- } ,
3878
- "args" : {
3879
- "DOCKER_META_IMAGES" : "user/app" ,
3880
- "DOCKER_META_VERSION" : "20200110" ,
3881
3905
}
3882
3906
}
3883
3907
}
3884
3908
}
3885
3909
] ,
3886
3910
[
3887
- 'bake05 ' ,
3911
+ 'bakeFile05 ' ,
3888
3912
'event_tag_v1.1.1.env' ,
3889
3913
{
3890
3914
images : [ 'org/app' , 'ghcr.io/user/app' ] ,
@@ -3916,6 +3940,16 @@ describe('bake', () => {
3916
3940
"ghcr.io/user/app:tags" ,
3917
3941
"ghcr.io/user/app:latest"
3918
3942
] ,
3943
+ "args" : {
3944
+ "DOCKER_META_IMAGES" : "org/app,ghcr.io/user/app" ,
3945
+ "DOCKER_META_VERSION" : "1.1.1" ,
3946
+ }
3947
+ }
3948
+ }
3949
+ } ,
3950
+ {
3951
+ "target" : {
3952
+ "docker-metadata-action" : {
3919
3953
"labels" : {
3920
3954
"org.opencontainers.image.created" : "2020-01-10T00:30:00.000Z" ,
3921
3955
"org.opencontainers.image.description" : "This your first repo!" ,
@@ -3925,17 +3959,13 @@ describe('bake', () => {
3925
3959
"org.opencontainers.image.title" : "Hello-World" ,
3926
3960
"org.opencontainers.image.url" : "https://github.com/octocat/Hello-World" ,
3927
3961
"org.opencontainers.image.version" : "1.1.1"
3928
- } ,
3929
- "args" : {
3930
- "DOCKER_META_IMAGES" : "org/app,ghcr.io/user/app" ,
3931
- "DOCKER_META_VERSION" : "1.1.1" ,
3932
3962
}
3933
3963
}
3934
3964
}
3935
3965
}
3936
3966
] ,
3937
3967
[
3938
- 'bake06 ' ,
3968
+ 'bakeFile06 ' ,
3939
3969
'event_tag_v1.1.1.env' ,
3940
3970
{
3941
3971
images : [ 'org/app' , 'ghcr.io/user/app' ] ,
@@ -3956,6 +3986,16 @@ describe('bake', () => {
3956
3986
"ghcr.io/user/app:custom" ,
3957
3987
"ghcr.io/user/app:tags"
3958
3988
] ,
3989
+ "args" : {
3990
+ "DOCKER_META_IMAGES" : "org/app,ghcr.io/user/app" ,
3991
+ "DOCKER_META_VERSION" : "my" ,
3992
+ }
3993
+ }
3994
+ }
3995
+ } ,
3996
+ {
3997
+ "target" : {
3998
+ "docker-metadata-action" : {
3959
3999
"labels" : {
3960
4000
"org.opencontainers.image.created" : "2020-01-10T00:30:00.000Z" ,
3961
4001
"org.opencontainers.image.description" : "This your first repo!" ,
@@ -3965,17 +4005,13 @@ describe('bake', () => {
3965
4005
"org.opencontainers.image.title" : "Hello-World" ,
3966
4006
"org.opencontainers.image.url" : "https://github.com/octocat/Hello-World" ,
3967
4007
"org.opencontainers.image.version" : "my"
3968
- } ,
3969
- "args" : {
3970
- "DOCKER_META_IMAGES" : "org/app,ghcr.io/user/app" ,
3971
- "DOCKER_META_VERSION" : "my" ,
3972
4008
}
3973
4009
}
3974
4010
}
3975
4011
}
3976
4012
] ,
3977
4013
[
3978
- 'bake07 ' ,
4014
+ 'bakeFile07 ' ,
3979
4015
'event_tag_v1.1.1.env' ,
3980
4016
{
3981
4017
images : [ 'org/app' ] ,
@@ -3993,6 +4029,16 @@ describe('bake', () => {
3993
4029
"org/app:v1.1.1" ,
3994
4030
"org/app:latest"
3995
4031
] ,
4032
+ "args" : {
4033
+ "DOCKER_META_IMAGES" : "org/app" ,
4034
+ "DOCKER_META_VERSION" : "v1.1.1" ,
4035
+ }
4036
+ }
4037
+ }
4038
+ } ,
4039
+ {
4040
+ "target" : {
4041
+ "docker-metadata-action" : {
3996
4042
"labels" : {
3997
4043
"maintainer" : "CrazyMax" ,
3998
4044
"org.opencontainers.image.created" : "2020-01-10T00:30:00.000Z" ,
@@ -4004,10 +4050,67 @@ describe('bake', () => {
4004
4050
"org.opencontainers.image.url" : "https://github.com/octocat/Hello-World" ,
4005
4051
"org.opencontainers.image.vendor" : "MyCompany" ,
4006
4052
"org.opencontainers.image.version" : "v1.1.1"
4053
+ }
4054
+ }
4055
+ }
4056
+ }
4057
+ ]
4058
+ ] ) ( 'given %p with %p event' , async ( name : string , envFile : string , inputs : Inputs , exBakeTags : unknown , exBakeLabels : unknown ) => {
4059
+ process . env = dotenv . parse ( fs . readFileSync ( path . join ( __dirname , 'fixtures' , envFile ) ) ) ;
4060
+
4061
+ const toolkit = new Toolkit ( ) ;
4062
+ const repo = await toolkit . github . repoData ( ) ;
4063
+ const meta = new Meta ( { ...getInputs ( ) , ...inputs } , await getContext ( ContextSource . workflow ) , repo ) ;
4064
+
4065
+ const bakeFileTags = meta . getBakeFile ( 'tags' ) ;
4066
+ expect ( JSON . parse ( fs . readFileSync ( bakeFileTags , 'utf8' ) ) ) . toEqual ( exBakeTags ) ;
4067
+
4068
+ const bakeFileLabels = meta . getBakeFile ( 'labels' ) ;
4069
+ expect ( JSON . parse ( fs . readFileSync ( bakeFileLabels , 'utf8' ) ) ) . toEqual ( exBakeLabels ) ;
4070
+ } ) ;
4071
+ } ) ;
4072
+
4073
+ describe ( 'bakeFileTagsLabels' , ( ) => {
4074
+ // prettier-ignore
4075
+ // eslint-disable-next-line jest/expect-expect
4076
+ test . each ( [
4077
+ [
4078
+ 'bakeFileTagsLabels01' ,
4079
+ 'event_push_dev.env' ,
4080
+ {
4081
+ images : [ 'user/app' ] ,
4082
+ tags : [
4083
+ `type=ref,event=branch` ,
4084
+ `type=raw,my` ,
4085
+ `type=raw,custom` ,
4086
+ `type=raw,tags`
4087
+ ] ,
4088
+ labels : [
4089
+ "invalid"
4090
+ ]
4091
+ } as Inputs ,
4092
+ {
4093
+ "target" : {
4094
+ "docker-metadata-action" : {
4095
+ "tags" : [
4096
+ "user/app:dev" ,
4097
+ "user/app:my" ,
4098
+ "user/app:custom" ,
4099
+ "user/app:tags"
4100
+ ] ,
4101
+ "labels" : {
4102
+ "org.opencontainers.image.created" : "2020-01-10T00:30:00.000Z" ,
4103
+ "org.opencontainers.image.description" : "This your first repo!" ,
4104
+ "org.opencontainers.image.licenses" : "MIT" ,
4105
+ "org.opencontainers.image.revision" : "860c1904a1ce19322e91ac35af1ab07466440c37" ,
4106
+ "org.opencontainers.image.source" : "https://github.com/octocat/Hello-World" ,
4107
+ "org.opencontainers.image.title" : "Hello-World" ,
4108
+ "org.opencontainers.image.url" : "https://github.com/octocat/Hello-World" ,
4109
+ "org.opencontainers.image.version" : "dev"
4007
4110
} ,
4008
4111
"args" : {
4009
- "DOCKER_META_IMAGES" : "org /app" ,
4010
- "DOCKER_META_VERSION" : "v1.1.1 " ,
4112
+ "DOCKER_META_IMAGES" : "user /app" ,
4113
+ "DOCKER_META_VERSION" : "dev " ,
4011
4114
}
4012
4115
}
4013
4116
}
@@ -4020,7 +4123,7 @@ describe('bake', () => {
4020
4123
const repo = await toolkit . github . repoData ( ) ;
4021
4124
const meta = new Meta ( { ...getInputs ( ) , ...inputs } , await getContext ( ContextSource . workflow ) , repo ) ;
4022
4125
4023
- const bakeFile = meta . getBakeFile ( ) ;
4126
+ const bakeFile = meta . getBakeFileTagsLabels ( ) ;
4024
4127
expect ( JSON . parse ( fs . readFileSync ( bakeFile , 'utf8' ) ) ) . toEqual ( exBakeDefinition ) ;
4025
4128
} ) ;
4026
4129
} ) ;
0 commit comments