@@ -137,6 +137,7 @@ func TestIntegration(t *testing.T) {
137
137
testHostnameSpecifying ,
138
138
testPushByDigest ,
139
139
testBasicInlineCacheImportExport ,
140
+ testBasicGhaCacheImportExport ,
140
141
testExportBusyboxLocal ,
141
142
testBridgeNetworking ,
142
143
testCacheMountNoCache ,
@@ -4831,6 +4832,45 @@ func testBasicInlineCacheImportExport(t *testing.T, sb integration.Sandbox) {
4831
4832
require .EqualValues (t , unique , unique3 )
4832
4833
}
4833
4834
4835
+ func testBasicGhaCacheImportExport (t * testing.T , sb integration.Sandbox ) {
4836
+ integration .CheckFeatureCompat (t , sb , integration .FeatureCacheExport )
4837
+ runtimeToken := os .Getenv ("ACTIONS_RUNTIME_TOKEN" )
4838
+ cacheURL := os .Getenv ("ACTIONS_CACHE_URL" )
4839
+ if runtimeToken == "" || cacheURL == "" {
4840
+ t .Skip ("ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL must be set" )
4841
+ }
4842
+
4843
+ scope := "buildkit-" + t .Name ()
4844
+ if ref := os .Getenv ("GITHUB_REF" ); ref != "" {
4845
+ if strings .HasPrefix (ref , "refs/heads/" ) {
4846
+ scope += "-" + strings .TrimPrefix (ref , "refs/heads/" )
4847
+ } else if strings .HasPrefix (ref , "refs/tags/" ) {
4848
+ scope += "-" + strings .TrimPrefix (ref , "refs/tags/" )
4849
+ } else if strings .HasPrefix (ref , "refs/pull/" ) {
4850
+ scope += "-pr" + strings .TrimPrefix (strings .TrimSuffix (strings .TrimSuffix (ref , "/head" ), "/merge" ), "refs/pull/" )
4851
+ }
4852
+ }
4853
+
4854
+ im := CacheOptionsEntry {
4855
+ Type : "gha" ,
4856
+ Attrs : map [string ]string {
4857
+ "url" : cacheURL ,
4858
+ "token" : runtimeToken ,
4859
+ "scope" : scope ,
4860
+ },
4861
+ }
4862
+ ex := CacheOptionsEntry {
4863
+ Type : "gha" ,
4864
+ Attrs : map [string ]string {
4865
+ "url" : cacheURL ,
4866
+ "token" : runtimeToken ,
4867
+ "scope" : scope ,
4868
+ "mode" : "max" ,
4869
+ },
4870
+ }
4871
+ testBasicCacheImportExport (t , sb , []CacheOptionsEntry {im }, []CacheOptionsEntry {ex })
4872
+ }
4873
+
4834
4874
func readFileInImage (ctx context.Context , t * testing.T , c * Client , ref , path string ) ([]byte , error ) {
4835
4875
def , err := llb .Image (ref ).Marshal (ctx )
4836
4876
if err != nil {
0 commit comments