mirror of
				https://github.com/Swatinem/rust-cache.git
				synced 2025-10-31 23:43:47 +00:00 
			
		
		
		
	support warpbuild cache provider
This commit is contained in:
		
							parent
							
								
									eaa85be6b1
								
							
						
					
					
						commit
						f29739b6ab
					
				| @ -82,7 +82,7 @@ sensible defaults. | |||||||
|     lookup-only: "" |     lookup-only: "" | ||||||
| 
 | 
 | ||||||
|     # Specifies what to use as the backend providing cache |     # Specifies what to use as the backend providing cache | ||||||
|     # Can be set to either "github" or "buildjet" |     # Can be set to "github", "buildjet", or "warpbuild" | ||||||
|     # default: "github" |     # default: "github" | ||||||
|     cache-provider: "" |     cache-provider: "" | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -41,7 +41,7 @@ inputs: | |||||||
|     required: false |     required: false | ||||||
|     default: "true" |     default: "true" | ||||||
|   cache-provider: |   cache-provider: | ||||||
|     description: "Determines which provider to use for caching. Options are github or buildjet, defaults to github." |     description: "Determines which provider to use for caching. Options are github, buildjet, or warpbuild. Defaults to github." | ||||||
|     required: false |     required: false | ||||||
|     default: "github" |     default: "github" | ||||||
|   cache-bin: |   cache-bin: | ||||||
|  | |||||||
							
								
								
									
										60520
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										60520
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										60520
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										60520
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										898
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										898
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -23,6 +23,7 @@ | |||||||
|   "homepage": "https://github.com/Swatinem/rust-cache#readme", |   "homepage": "https://github.com/Swatinem/rust-cache#readme", | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@actions/buildjet-cache": "npm:github-actions.cache-buildjet@0.2.0", |     "@actions/buildjet-cache": "npm:github-actions.cache-buildjet@0.2.0", | ||||||
|  |     "@actions/warpbuild-cache": "npm:github-actions.warp-cache@1.4.5", | ||||||
|     "@actions/cache": "^4.0.0", |     "@actions/cache": "^4.0.0", | ||||||
|     "@actions/core": "^1.11.1", |     "@actions/core": "^1.11.1", | ||||||
|     "@actions/exec": "^1.1.1", |     "@actions/exec": "^1.1.1", | ||||||
|  | |||||||
							
								
								
									
										26
									
								
								src/utils.ts
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								src/utils.ts
									
									
									
									
									
								
							| @ -1,6 +1,7 @@ | |||||||
| import * as core from "@actions/core"; | import * as core from "@actions/core"; | ||||||
| import * as exec from "@actions/exec"; | import * as exec from "@actions/exec"; | ||||||
| import * as buildjetCache from "@actions/buildjet-cache"; | import * as buildjetCache from "@actions/buildjet-cache"; | ||||||
|  | import * as warpbuildCache from "@actions/warpbuild-cache"; | ||||||
| import * as ghCache from "@actions/cache"; | import * as ghCache from "@actions/cache"; | ||||||
| import fs from "fs"; | import fs from "fs"; | ||||||
| 
 | 
 | ||||||
| @ -44,17 +45,32 @@ export async function getCmdOutput( | |||||||
|   return stdout; |   return stdout; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | export interface GhCache { | ||||||
|  |   isFeatureAvailable: typeof ghCache.isFeatureAvailable; | ||||||
|  |   restoreCache: typeof ghCache.restoreCache; | ||||||
|  |   saveCache: (paths: string[], key: string) => Promise<string | number>; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| export interface CacheProvider { | export interface CacheProvider { | ||||||
|   name: string; |   name: string; | ||||||
|   cache: typeof ghCache; |   cache: GhCache; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export function getCacheProvider(): CacheProvider { | export function getCacheProvider(): CacheProvider { | ||||||
|   const cacheProvider = core.getInput("cache-provider"); |   const cacheProvider = core.getInput("cache-provider"); | ||||||
|   const cache = cacheProvider === "github" ? ghCache : cacheProvider === "buildjet" ? buildjetCache : undefined; |   let cache: GhCache; | ||||||
| 
 |   switch (cacheProvider) { | ||||||
|   if (!cache) { |     case "github": | ||||||
|     throw new Error(`The \`cache-provider\` \`{cacheProvider}\` is not valid.`); |       cache = ghCache; | ||||||
|  |       break; | ||||||
|  |     case "buildjet": | ||||||
|  |       cache = buildjetCache; | ||||||
|  |       break; | ||||||
|  |     case "warpbuild": | ||||||
|  |       cache = warpbuildCache; | ||||||
|  |       break; | ||||||
|  |     default: | ||||||
|  |       throw new Error(`The \`cache-provider\` \`${cacheProvider}\` is not valid.`); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   return { |   return { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user