@@ -133,6 +133,7 @@ func TestIntegration(t *testing.T) {
133
133
testHostnameSpecifying ,
134
134
testPushByDigest ,
135
135
testBasicInlineCacheImportExport ,
136
+ testBasicGhaCacheImportExport ,
136
137
testExportBusyboxLocal ,
137
138
testBridgeNetworking ,
138
139
testCacheMountNoCache ,
@@ -4723,6 +4724,45 @@ func testBasicInlineCacheImportExport(t *testing.T, sb integration.Sandbox) {
4723
4724
require .EqualValues (t , unique , unique3 )
4724
4725
}
4725
4726
4727
+ func testBasicGhaCacheImportExport (t * testing.T , sb integration.Sandbox ) {
4728
+ integration .CheckFeatureCompat (t , sb , integration .FeatureCacheExport )
4729
+ runtimeToken := os .Getenv ("ACTIONS_RUNTIME_TOKEN" )
4730
+ cacheURL := os .Getenv ("ACTIONS_CACHE_URL" )
4731
+ if runtimeToken == "" || cacheURL == "" {
4732
+ t .Skip ("ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL must be set" )
4733
+ }
4734
+
4735
+ scope := "buildkit-" + t .Name ()
4736
+ if ref := os .Getenv ("GITHUB_REF" ); ref != "" {
4737
+ if strings .HasPrefix (ref , "refs/heads/" ) {
4738
+ scope += "-" + strings .TrimPrefix (ref , "refs/heads/" )
4739
+ } else if strings .HasPrefix (ref , "refs/tags/" ) {
4740
+ scope += "-" + strings .TrimPrefix (ref , "refs/tags/" )
4741
+ } else if strings .HasPrefix (ref , "refs/pull/" ) {
4742
+ scope += "-pr" + strings .TrimPrefix (strings .TrimSuffix (strings .TrimSuffix (ref , "/head" ), "/merge" ), "refs/pull/" )
4743
+ }
4744
+ }
4745
+
4746
+ im := CacheOptionsEntry {
4747
+ Type : "gha" ,
4748
+ Attrs : map [string ]string {
4749
+ "url" : cacheURL ,
4750
+ "token" : runtimeToken ,
4751
+ "scope" : scope ,
4752
+ },
4753
+ }
4754
+ ex := CacheOptionsEntry {
4755
+ Type : "gha" ,
4756
+ Attrs : map [string ]string {
4757
+ "url" : cacheURL ,
4758
+ "token" : runtimeToken ,
4759
+ "scope" : scope ,
4760
+ "mode" : "max" ,
4761
+ },
4762
+ }
4763
+ testBasicCacheImportExport (t , sb , []CacheOptionsEntry {im }, []CacheOptionsEntry {ex })
4764
+ }
4765
+
4726
4766
func readFileInImage (ctx context.Context , t * testing.T , c * Client , ref , path string ) ([]byte , error ) {
4727
4767
def , err := llb .Image (ref ).Marshal (ctx )
4728
4768
if err != nil {
0 commit comments