mirror of
				https://github.com/Swatinem/rust-cache.git
				synced 2025-10-31 16:03:48 +00:00 
			
		
		
		
	Cache-on-failure support (#22)
This commit is contained in:
		
							parent
							
								
									842ef286ff
								
							
						
					
					
						commit
						536c94f32c
					
				
							
								
								
									
										4
									
								
								.github/workflows/selftest.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/selftest.yml
									
									
									
									
										vendored
									
									
								
							| @ -22,8 +22,10 @@ jobs: | ||||
|           override: true | ||||
| 
 | ||||
|       - uses: ./ | ||||
|         with: | ||||
|           cache-on-failure: true | ||||
| 
 | ||||
|       - run: | | ||||
|           cargo install cargo-deny --locked | ||||
|           cargo check | ||||
|           cargo test | ||||
|           cargo test | ||||
| @ -31,6 +31,9 @@ located in the repo root. | ||||
| : `target-dir` | ||||
| The target directory that should be cleaned and persisted, defaults to `./target`. | ||||
| 
 | ||||
| : `cache-on-failure` | ||||
| Cache even if the build fails, defaults to false | ||||
| 
 | ||||
| ## Outputs | ||||
| 
 | ||||
| : `cache-hit` | ||||
|  | ||||
| @ -14,6 +14,9 @@ inputs: | ||||
|   target-dir: | ||||
|     description: "The target dir that should be cleaned and persisted, defaults to `./target`" | ||||
|     required: false | ||||
|   cache-on-failure: | ||||
|     description: "Cache even if the build fails. Defaults to false" | ||||
|     required: false | ||||
| outputs: | ||||
|   cache-hit: | ||||
|     description: "A boolean value that indicates an exact match was found" | ||||
| @ -21,7 +24,7 @@ runs: | ||||
|   using: "node12" | ||||
|   main: "dist/restore/index.js" | ||||
|   post: "dist/save/index.js" | ||||
|   post-if: "success()" | ||||
|   post-if: "success() || env.CACHE_ON_FAILURE == 'true'" | ||||
| branding: | ||||
|   icon: "archive" | ||||
|   color: "gray-dark" | ||||
|  | ||||
| @ -9,6 +9,9 @@ import path from "path"; | ||||
| 
 | ||||
| process.on("uncaughtException", (e) => { | ||||
|   core.info(`[warning] ${e.message}`); | ||||
|   if (e.stack) { | ||||
|     core.info(e.stack) | ||||
|   } | ||||
| }); | ||||
| 
 | ||||
| const cwd = core.getInput("working-directory"); | ||||
|  | ||||
| @ -4,6 +4,11 @@ import { cleanTarget, getCacheConfig, getCargoBins, getPackages, stateBins, stat | ||||
| 
 | ||||
| async function run() { | ||||
|   try { | ||||
|     var cacheOnFailure = core.getInput("cache-on-failure").toLowerCase() | ||||
|     if (cacheOnFailure !== "true") { | ||||
|       cacheOnFailure = "false" | ||||
|     } | ||||
|     core.exportVariable("CACHE_ON_FAILURE", cacheOnFailure) | ||||
|     core.exportVariable("CARGO_INCREMENTAL", 0); | ||||
| 
 | ||||
|     const { paths, key, restoreKeys } = await getCacheConfig(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user