@@ -85,6 +85,7 @@ var allTests = integration.TestFuncs(
85
85
testDockerfileAddArchive ,
86
86
testDockerfileScratchConfig ,
87
87
testExportedHistory ,
88
+ testExportedHistoryFlattenArgs ,
88
89
testExposeExpansion ,
89
90
testUser ,
90
91
testUserAdditionalGids ,
@@ -3625,6 +3626,70 @@ RUN ["ls"]
3625
3626
require .NotNil (t , ociimg .History [6 ].Created )
3626
3627
}
3627
3628
3629
+ // moby/buildkit#5505
3630
+ func testExportedHistoryFlattenArgs (t * testing.T , sb integration.Sandbox ) {
3631
+ integration .SkipOnPlatform (t , "windows" )
3632
+ f := getFrontend (t , sb )
3633
+ f .RequiresBuildctl (t )
3634
+
3635
+ dockerfile := []byte (`
3636
+ FROM busybox
3637
+ ARG foo=bar
3638
+ ARG bar=123
3639
+ ARG foo=bar2
3640
+ RUN ls /etc/
3641
+ ` )
3642
+
3643
+ dir := integration .Tmpdir (
3644
+ t ,
3645
+ fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
3646
+ )
3647
+
3648
+ args , trace := f .DFCmdArgs (dir .Name , dir .Name )
3649
+ defer os .RemoveAll (trace )
3650
+
3651
+ workers .CheckFeatureCompat (t , sb , workers .FeatureImageExporter )
3652
+ workers .CheckFeatureCompat (t , sb , workers .FeatureDirectPush )
3653
+
3654
+ registry , err := sb .NewRegistry ()
3655
+ if errors .Is (err , integration .ErrRequirements ) {
3656
+ t .Skip (err .Error ())
3657
+ }
3658
+ require .NoError (t , err )
3659
+
3660
+ target := registry + "/buildkit/testargduplicate:latest"
3661
+ cmd := sb .Cmd (args + " --output type=image,push=true,name=" + target )
3662
+ require .NoError (t , cmd .Run ())
3663
+
3664
+ desc , provider , err := contentutil .ProviderFromRef (target )
3665
+ require .NoError (t , err )
3666
+
3667
+ imgs , err := testutil .ReadImages (sb .Context (), provider , desc )
3668
+ require .NoError (t , err )
3669
+
3670
+ require .Equal (t , 1 , len (imgs .Images ))
3671
+
3672
+ history := imgs .Images [0 ].Img .History
3673
+
3674
+ firstNonBase := - 1
3675
+ for i , h := range history {
3676
+ if h .CreatedBy == "ARG foo=bar" {
3677
+ firstNonBase = i
3678
+ break
3679
+ }
3680
+ }
3681
+ require .Greater (t , firstNonBase , 0 )
3682
+
3683
+ require .Len (t , history , firstNonBase + 4 )
3684
+ require .Contains (t , history [firstNonBase + 1 ].CreatedBy , "ARG bar=123" )
3685
+ require .Contains (t , history [firstNonBase + 2 ].CreatedBy , "ARG foo=bar2" )
3686
+
3687
+ runLine := history [firstNonBase + 3 ].CreatedBy
3688
+ require .Contains (t , runLine , "ls /etc/" )
3689
+ require .NotContains (t , runLine , "ARG foo=bar" )
3690
+ require .Contains (t , runLine , "RUN |2 foo=bar2 bar=123 " )
3691
+ }
3692
+
3628
3693
func testUser (t * testing.T , sb integration.Sandbox ) {
3629
3694
integration .SkipOnPlatform (t , "windows" )
3630
3695
workers .CheckFeatureCompat (t , sb , workers .FeatureImageExporter )
0 commit comments