mirror of
				https://kkgithub.com/actions/cache.git
				synced 2025-10-31 18:51:49 +08:00 
			
		
		
		
	Compare commits
	
		
			3 Commits
		
	
	
		
			tiwarishub
			...
			v1.0.1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 86dff562ab | |||
| 0f810ad45a | |||
| 9d8c7b4041 | 
							
								
								
									
										12
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								README.md
									
									
									
									
									
								
							| @ -2,7 +2,11 @@ | |||||||
|  |  | ||||||
| This GitHub Action allows caching dependencies and build outputs to improve workflow execution time. | This GitHub Action allows caching dependencies and build outputs to improve workflow execution time. | ||||||
|  |  | ||||||
| <a href="https://github.com/actions/cache"><img alt="GitHub Actions status" src="https://github.com/actions/cache/workflows/Tests/badge.svg"></a> | <a href="https://github.com/actions/cache"><img alt="GitHub Actions status" src="https://github.com/actions/cache/workflows/Tests/badge.svg?branch=master&event=push"></a> | ||||||
|  |  | ||||||
|  | ## Documentation | ||||||
|  |  | ||||||
|  | See ["Caching dependencies to speed up workflows"](https://help.github.com/github/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows). | ||||||
|  |  | ||||||
| ## Usage | ## Usage | ||||||
|  |  | ||||||
| @ -36,7 +40,7 @@ jobs: | |||||||
|     - uses: actions/checkout@v1 |     - uses: actions/checkout@v1 | ||||||
|  |  | ||||||
|     - name: Cache node modules |     - name: Cache node modules | ||||||
|       uses: actions/cache@preview |       uses: actions/cache@v1 | ||||||
|       with: |       with: | ||||||
|         path: node_modules |         path: node_modules | ||||||
|         key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |         key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||||||
| @ -59,7 +63,7 @@ See [Examples](examples.md) | |||||||
|  |  | ||||||
| ## Cache Limits | ## Cache Limits | ||||||
|  |  | ||||||
| Individual caches are limited to 200MB and a repository can have up to 2GB of caches. Once the 2GB limit is reached, older caches will be evicted based on when the cache was last accessed.  Caches that are not accessed within the last week will also be evicted. | Individual caches are limited to 400MB and a repository can have up to 2GB of caches. Once the 2GB limit is reached, older caches will be evicted based on when the cache was last accessed.  Caches that are not accessed within the last week will also be evicted. | ||||||
|  |  | ||||||
| ## Skipping steps based on cache-hit | ## Skipping steps based on cache-hit | ||||||
|  |  | ||||||
| @ -70,7 +74,7 @@ Example: | |||||||
| steps: | steps: | ||||||
|   - uses: actions/checkout@v1 |   - uses: actions/checkout@v1 | ||||||
|  |  | ||||||
|   - uses: actions/cache@preview |   - uses: actions/cache@v1 | ||||||
|     id: cache |     id: cache | ||||||
|     with: |     with: | ||||||
|       path: path/to/dependencies |       path: path/to/dependencies | ||||||
|  | |||||||
							
								
								
									
										5166
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5166
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										5140
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5140
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										139
									
								
								examples.md
									
									
									
									
									
								
							
							
						
						
									
										139
									
								
								examples.md
									
									
									
									
									
								
							| @ -1,43 +1,22 @@ | |||||||
| # Examples | # Examples | ||||||
|  |  | ||||||
| - [Node - npm](#node---npm) |  | ||||||
| - [Node - Yarn](#node---yarn) |  | ||||||
| - [C# - Nuget](#c---nuget) | - [C# - Nuget](#c---nuget) | ||||||
|  | - [Elixir - Mix](#elixir---mix) | ||||||
|  | - [Go - Modules](#go---modules) | ||||||
| - [Java - Gradle](#java---gradle) | - [Java - Gradle](#java---gradle) | ||||||
| - [Java - Maven](#java---maven) | - [Java - Maven](#java---maven) | ||||||
|  | - [Node - npm](#node---npm) | ||||||
|  | - [Node - Yarn](#node---yarn) | ||||||
|  | - [Ruby - Gem](#ruby---gem) | ||||||
|  | - [Rust - Cargo](#rust---cargo) | ||||||
| - [Swift, Objective-C - Carthage](#swift-objective-c---carthage) | - [Swift, Objective-C - Carthage](#swift-objective-c---carthage) | ||||||
| - [Swift, Objective-C - CocoaPods](#swift-objective-c---cocoapods) | - [Swift, Objective-C - CocoaPods](#swift-objective-c---cocoapods) | ||||||
| - [Ruby - Gem](#ruby---gem) |  | ||||||
| - [Go - Modules](#go---modules) |  | ||||||
| - [Elixir - Mix](#elixir---mix) |  | ||||||
| - [Rust - Cargo](#rust---cargo) |  | ||||||
|  |  | ||||||
| ## Node - npm |  | ||||||
|  |  | ||||||
| ```yaml |  | ||||||
| - uses: actions/cache@preview |  | ||||||
|   with: |  | ||||||
|     path: node_modules |  | ||||||
|     key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |  | ||||||
|     restore-keys: | |  | ||||||
|       ${{ runner.os }}-node- |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ## Node - Yarn |  | ||||||
|  |  | ||||||
| ```yaml |  | ||||||
| - uses: actions/cache@preview |  | ||||||
|   with: |  | ||||||
|     path: ~/.cache/yarn |  | ||||||
|     key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }} |  | ||||||
|     restore-keys: | |  | ||||||
|       ${{ runner.os }}-yarn- |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ## C# - Nuget | ## C# - Nuget | ||||||
| Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies): | Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies): | ||||||
|  |  | ||||||
| ```yaml | ```yaml | ||||||
| - uses: actions/cache@preview | - uses: actions/cache@v1 | ||||||
|   with: |   with: | ||||||
|     path: ~/.nuget/packages |     path: ~/.nuget/packages | ||||||
|     key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} |     key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | ||||||
| @ -45,10 +24,31 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa | |||||||
|       ${{ runner.os }}-nuget- |       ${{ runner.os }}-nuget- | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|  | ## Elixir - Mix | ||||||
|  | ```yaml | ||||||
|  | - uses: actions/cache@v1 | ||||||
|  |   with: | ||||||
|  |     path: deps | ||||||
|  |     key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | ||||||
|  |     restore-keys: | | ||||||
|  |       ${{ runner.os }}-mix- | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Go - Modules | ||||||
|  |  | ||||||
|  | ```yaml | ||||||
|  | - uses: actions/cache@v1 | ||||||
|  |   with: | ||||||
|  |     path: ~/go/pkg/mod | ||||||
|  |     key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||||||
|  |     restore-keys: | | ||||||
|  |       ${{ runner.os }}-go- | ||||||
|  | ``` | ||||||
|  |  | ||||||
| ## Java - Gradle | ## Java - Gradle | ||||||
|  |  | ||||||
| ```yaml | ```yaml | ||||||
| - uses: actions/cache@preview | - uses: actions/cache@v1 | ||||||
|   with: |   with: | ||||||
|     path: ~/.gradle/caches |     path: ~/.gradle/caches | ||||||
|     key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} |     key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | ||||||
| @ -59,7 +59,7 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa | |||||||
| ## Java - Maven | ## Java - Maven | ||||||
|  |  | ||||||
| ```yaml | ```yaml | ||||||
| - uses: actions/cache@preview | - uses: actions/cache@v1 | ||||||
|   with: |   with: | ||||||
|     path: ~/.m2/repository |     path: ~/.m2/repository | ||||||
|     key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |     key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||||||
| @ -67,32 +67,32 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa | |||||||
|       ${{ runner.os }}-maven- |       ${{ runner.os }}-maven- | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| ## Swift, Objective-C - Carthage | ## Node - npm | ||||||
|  |  | ||||||
| ```yaml | ```yaml | ||||||
| uses: actions/cache@preview | - uses: actions/cache@v1 | ||||||
|       with: |   with: | ||||||
|         path: Carthage |     path: node_modules | ||||||
|         key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }} |     key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||||||
|         restore-keys: | |     restore-keys: | | ||||||
|           ${{ runner.os }}-carthage- |       ${{ runner.os }}-node- | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| ## Swift, Objective-C - CocoaPods | ## Node - Yarn | ||||||
|  |  | ||||||
| ```yaml | ```yaml | ||||||
| - uses: actions/cache@preview | - uses: actions/cache@v1 | ||||||
|   with: |   with: | ||||||
|     path: Pods |     path: ~/.cache/yarn | ||||||
|     key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} |     key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }} | ||||||
|     restore-keys: | |     restore-keys: | | ||||||
|       ${{ runner.os }}-pods- |       ${{ runner.os }}-yarn- | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| ## Ruby - Gem | ## Ruby - Gem | ||||||
|  |  | ||||||
| ```yaml | ```yaml | ||||||
| - uses: actions/cache@preview | - uses: actions/cache@v1 | ||||||
|   with: |   with: | ||||||
|     path: vendor/bundle |     path: vendor/bundle | ||||||
|     key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} |     key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} | ||||||
| @ -100,43 +100,44 @@ uses: actions/cache@preview | |||||||
|       ${{ runner.os }}-gem- |       ${{ runner.os }}-gem- | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| ## Go - Modules |  | ||||||
|  |  | ||||||
| ```yaml |  | ||||||
| - uses: actions/cache@preview |  | ||||||
|   with: |  | ||||||
|     path: ~/go/pkg/mod |  | ||||||
|     key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |  | ||||||
|     restore-keys: | |  | ||||||
|       ${{ runner.os }}-go- |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ## Elixir - Mix |  | ||||||
| ```yaml |  | ||||||
| - uses: actions/cache@preview |  | ||||||
|   with: |  | ||||||
|     path: deps |  | ||||||
|     key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} |  | ||||||
|     restore-keys: | |  | ||||||
|       ${{ runner.os }}-mix- |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ## Rust - Cargo | ## Rust - Cargo | ||||||
|  |  | ||||||
| ``` | ```yaml | ||||||
| - name: Cache cargo registry | - name: Cache cargo registry | ||||||
|   uses: actions/cache@preview |   uses: actions/cache@v1 | ||||||
|   with: |   with: | ||||||
|     path: ~/.cargo/registry |     path: ~/.cargo/registry | ||||||
|     key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |     key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | ||||||
| - name: Cache cargo index | - name: Cache cargo index | ||||||
|   uses: actions/cache@preview |   uses: actions/cache@v1 | ||||||
|   with: |   with: | ||||||
|     path: ~/.cargo/git |     path: ~/.cargo/git | ||||||
|     key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |     key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | ||||||
| - name: Cache cargo build | - name: Cache cargo build | ||||||
|   uses: actions/cache@preview |   uses: actions/cache@v1 | ||||||
|   with: |   with: | ||||||
|     path: target |     path: target | ||||||
|     key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} |     key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|  | ## Swift, Objective-C - Carthage | ||||||
|  |  | ||||||
|  | ```yaml | ||||||
|  | - uses: actions/cache@v1 | ||||||
|  |   with: | ||||||
|  |     path: Carthage | ||||||
|  |     key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }} | ||||||
|  |     restore-keys: | | ||||||
|  |       ${{ runner.os }}-carthage- | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Swift, Objective-C - CocoaPods | ||||||
|  |  | ||||||
|  | ```yaml | ||||||
|  | - uses: actions/cache@v1 | ||||||
|  |   with: | ||||||
|  |     path: Pods | ||||||
|  |     key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} | ||||||
|  |     restore-keys: | | ||||||
|  |       ${{ runner.os }}-pods- | ||||||
|  | ``` | ||||||
|  | |||||||
							
								
								
									
										22
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										22
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "cache", |   "name": "cache", | ||||||
|   "version": "0.0.1", |   "version": "1.0.1", | ||||||
|   "lockfileVersion": 1, |   "lockfileVersion": 1, | ||||||
|   "requires": true, |   "requires": true, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
| @ -1105,9 +1105,9 @@ | |||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "commander": { |     "commander": { | ||||||
|       "version": "2.20.1", |       "version": "2.20.3", | ||||||
|       "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.1.tgz", |       "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", | ||||||
|       "integrity": "sha512-cCuLsMhJeWQ/ZpsFTbE765kvVfoeSddc4nU3up4fV+fDBcfUXnbITJ+JzhkdjzOqhURjZgujxaioam4RM9yGUg==", |       "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", | ||||||
|       "dev": true, |       "dev": true, | ||||||
|       "optional": true |       "optional": true | ||||||
|     }, |     }, | ||||||
| @ -2318,9 +2318,9 @@ | |||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|     "handlebars": { |     "handlebars": { | ||||||
|       "version": "4.4.2", |       "version": "4.5.1", | ||||||
|       "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.2.tgz", |       "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.1.tgz", | ||||||
|       "integrity": "sha512-cIv17+GhL8pHHnRJzGu2wwcthL5sb8uDKBHvZ2Dtu5s1YNt0ljbzKbamnc+gr69y7bzwQiBdr5+hOpRd5pnOdg==", |       "integrity": "sha512-C29UoFzHe9yM61lOsIlCE5/mQVGrnIOrOq7maQl76L7tYPCgC1og0Ajt6uWnX4ZTxBPnjw+CUvawphwCfJgUnA==", | ||||||
|       "dev": true, |       "dev": true, | ||||||
|       "requires": { |       "requires": { | ||||||
|         "neo-async": "^2.6.0", |         "neo-async": "^2.6.0", | ||||||
| @ -4981,13 +4981,13 @@ | |||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|     "uglify-js": { |     "uglify-js": { | ||||||
|       "version": "3.6.0", |       "version": "3.6.7", | ||||||
|       "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", |       "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.7.tgz", | ||||||
|       "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==", |       "integrity": "sha512-4sXQDzmdnoXiO+xvmTzQsfIiwrjUCSA95rSP4SEd8tDb51W2TiDOlL76Hl+Kw0Ie42PSItCW8/t6pBNCF2R48A==", | ||||||
|       "dev": true, |       "dev": true, | ||||||
|       "optional": true, |       "optional": true, | ||||||
|       "requires": { |       "requires": { | ||||||
|         "commander": "~2.20.0", |         "commander": "~2.20.3", | ||||||
|         "source-map": "~0.6.1" |         "source-map": "~0.6.1" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "cache", |   "name": "cache", | ||||||
|   "version": "0.0.2", |   "version": "1.0.1", | ||||||
|   "private": true, |   "private": true, | ||||||
|   "description": "Cache dependencies and build outputs", |   "description": "Cache dependencies and build outputs", | ||||||
|   "main": "dist/restore/index.js", |   "main": "dist/restore/index.js", | ||||||
|  | |||||||
| @ -20,7 +20,10 @@ async function run() { | |||||||
|         const primaryKey = core.getInput(Inputs.Key, { required: true }); |         const primaryKey = core.getInput(Inputs.Key, { required: true }); | ||||||
|         core.saveState(State.CacheKey, primaryKey); |         core.saveState(State.CacheKey, primaryKey); | ||||||
|  |  | ||||||
|         const restoreKeys = core.getInput(Inputs.RestoreKeys).split("\n"); |         const restoreKeys = core | ||||||
|  |             .getInput(Inputs.RestoreKeys) | ||||||
|  |             .split("\n") | ||||||
|  |             .filter(x => x !== ""); | ||||||
|         const keys = [primaryKey, ...restoreKeys]; |         const keys = [primaryKey, ...restoreKeys]; | ||||||
|  |  | ||||||
|         core.debug("Resolved Keys:"); |         core.debug("Resolved Keys:"); | ||||||
| @ -52,7 +55,7 @@ async function run() { | |||||||
|             const cacheEntry = await cacheHttpClient.getCacheEntry(keys); |             const cacheEntry = await cacheHttpClient.getCacheEntry(keys); | ||||||
|             if (!cacheEntry) { |             if (!cacheEntry) { | ||||||
|                 core.info( |                 core.info( | ||||||
|                     `Cache not found for input keys: ${JSON.stringify(keys)}.` |                     `Cache not found for input keys: ${keys.join(", ")}.` | ||||||
|                 ); |                 ); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -54,12 +54,12 @@ async function run() { | |||||||
|         core.debug(`Tar Path: ${tarPath}`); |         core.debug(`Tar Path: ${tarPath}`); | ||||||
|         await exec(`"${tarPath}"`, args); |         await exec(`"${tarPath}"`, args); | ||||||
|  |  | ||||||
|         const fileSizeLimit = 200 * 1024 * 1024; // 200MB |         const fileSizeLimit = 400 * 1024 * 1024; // 400MB | ||||||
|         const archiveFileSize = fs.statSync(archivePath).size; |         const archiveFileSize = fs.statSync(archivePath).size; | ||||||
|         core.debug(`File Size: ${archiveFileSize}`); |         core.debug(`File Size: ${archiveFileSize}`); | ||||||
|         if (archiveFileSize > fileSizeLimit) { |         if (archiveFileSize > fileSizeLimit) { | ||||||
|             core.warning( |             core.warning( | ||||||
|                 `Cache size of ${archiveFileSize} bytes is over the 200MB limit, not saving cache.` |                 `Cache size of ${archiveFileSize} bytes is over the 400MB limit, not saving cache.` | ||||||
|             ); |             ); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	