mirror of
				https://kkgithub.com/actions/cache.git
				synced 2025-11-04 12:41:50 +08:00 
			
		
		
		
	Compare commits
	
		
			5 Commits
		
	
	
		
			v3.1.0-bet
			...
			master
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 0769f2e443 | |||
| 515d10b4fd | |||
| 669e7536d9 | |||
| 29dbbce762 | |||
| ea5981db97 | 
							
								
								
									
										1
									
								
								.github/workflows/check-dist.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.github/workflows/check-dist.yml
									
									
									
									
										vendored
									
									
								
							@ -27,7 +27,6 @@ jobs:
 | 
			
		||||
        uses: actions/setup-node@v3
 | 
			
		||||
        with:
 | 
			
		||||
          node-version: 16.x
 | 
			
		||||
          cache: npm
 | 
			
		||||
      - name: Install dependencies
 | 
			
		||||
        run: npm ci
 | 
			
		||||
      - name: Rebuild the dist/ directory
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							@ -25,7 +25,17 @@ jobs:
 | 
			
		||||
      uses: actions/setup-node@v3
 | 
			
		||||
      with:
 | 
			
		||||
        node-version: 16.x
 | 
			
		||||
        cache: npm
 | 
			
		||||
    - name: Determine npm cache directory
 | 
			
		||||
      id: npm-cache
 | 
			
		||||
      run: |
 | 
			
		||||
        echo "::set-output name=dir::$(npm config get cache)"
 | 
			
		||||
    - name: Restore npm cache
 | 
			
		||||
      uses: actions/cache@v3
 | 
			
		||||
      with:
 | 
			
		||||
        path: ${{ steps.npm-cache.outputs.dir }}
 | 
			
		||||
        key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
 | 
			
		||||
        restore-keys: |
 | 
			
		||||
          ${{ runner.os }}-node-
 | 
			
		||||
    - run: npm ci
 | 
			
		||||
    - name: Prettier Format Check
 | 
			
		||||
      run: npm run format-check
 | 
			
		||||
 | 
			
		||||
@ -40,9 +40,3 @@
 | 
			
		||||
### 3.0.11
 | 
			
		||||
- Update toolkit version to 3.0.5 to include `@actions/core@^1.10.0`
 | 
			
		||||
- Update `@actions/cache` to use updated `saveState` and `setOutput` functions from `@actions/core@^1.10.0`
 | 
			
		||||
 | 
			
		||||
### 3.1.0-beta.1
 | 
			
		||||
- Update `@actions/cache` on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. ([issue](https://github.com/actions/cache/issues/984))
 | 
			
		||||
 | 
			
		||||
### 3.1.0-beta.2
 | 
			
		||||
- Added support for fallback to gzip to restore old caches on windows.
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										947
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										947
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										947
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										947
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										21
									
								
								examples.md
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								examples.md
									
									
									
									
									
								
							@ -309,29 +309,14 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
 | 
			
		||||
For npm, cache files are stored in `~/.npm` on Posix, or `~\AppData\npm-cache` on Windows, but it's possible to use `npm config get cache` to find the path on any platform. See [the npm docs](https://docs.npmjs.com/cli/cache#cache) for more details.
 | 
			
		||||
 | 
			
		||||
If using `npm config` to retrieve the cache directory, ensure you run [actions/setup-node](https://github.com/actions/setup-node) first to ensure your `npm` version is correct.
 | 
			
		||||
After [deprecation](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/) of save-state and set-output commands, the correct way to set output is using `${GITHUB_OUTPUT}`. For linux, we can use `${GITHUB_OUTPUT}` whereas for windows we need to use `${env:GITHUB_OUTPUT}` due to two different default shells in these two different OS ie `bash` and `pwsh` respectively.
 | 
			
		||||
 | 
			
		||||
>Note: It is not recommended to cache `node_modules`, as it can break across Node versions and won't work with `npm ci`
 | 
			
		||||
 | 
			
		||||
### **Get npm cache directory using same shell**
 | 
			
		||||
### Bash shell
 | 
			
		||||
```yaml
 | 
			
		||||
- name: Get npm cache directory
 | 
			
		||||
  id: npm-cache
 | 
			
		||||
  shell: bash
 | 
			
		||||
  run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### PWSH shell
 | 
			
		||||
```yaml
 | 
			
		||||
- name: Get npm cache directory
 | 
			
		||||
  id: npm-cache
 | 
			
		||||
  shell: pwsh
 | 
			
		||||
  run: echo "dir=$(npm config get cache)" >> ${env:GITHUB_OUTPUT}
 | 
			
		||||
```
 | 
			
		||||
`Get npm cache directory` step can then be used with `actions/cache` as shown below
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
  id: npm-cache-dir
 | 
			
		||||
  run: |
 | 
			
		||||
    echo "::set-output name=dir::$(npm config get cache)"
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
  id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
 | 
			
		||||
  with:
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										6530
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6530
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										28
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								package.json
									
									
									
									
									
								
							@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "cache",
 | 
			
		||||
  "version": "3.1.0-beta.2",
 | 
			
		||||
  "version": "3.0.11",
 | 
			
		||||
  "private": true,
 | 
			
		||||
  "description": "Cache dependencies and build outputs",
 | 
			
		||||
  "main": "dist/restore/index.js",
 | 
			
		||||
@ -23,29 +23,29 @@
 | 
			
		||||
  "author": "GitHub",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@actions/cache": "3.1.0-beta.2",
 | 
			
		||||
    "@actions/cache": "^3.0.5",
 | 
			
		||||
    "@actions/core": "^1.10.0",
 | 
			
		||||
    "@actions/exec": "^1.1.1",
 | 
			
		||||
    "@actions/io": "^1.1.2"
 | 
			
		||||
  },
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@types/jest": "^27.5.2",
 | 
			
		||||
    "@types/jest": "^27.5.0",
 | 
			
		||||
    "@types/nock": "^11.1.0",
 | 
			
		||||
    "@types/node": "^16.18.3",
 | 
			
		||||
    "@typescript-eslint/eslint-plugin": "^5.45.0",
 | 
			
		||||
    "@typescript-eslint/parser": "^5.45.0",
 | 
			
		||||
    "@types/node": "^16.11.33",
 | 
			
		||||
    "@typescript-eslint/eslint-plugin": "^5.22.0",
 | 
			
		||||
    "@typescript-eslint/parser": "^5.22.0",
 | 
			
		||||
    "@zeit/ncc": "^0.20.5",
 | 
			
		||||
    "eslint": "^8.28.0",
 | 
			
		||||
    "eslint": "^8.14.0",
 | 
			
		||||
    "eslint-config-prettier": "^8.5.0",
 | 
			
		||||
    "eslint-plugin-import": "^2.26.0",
 | 
			
		||||
    "eslint-plugin-jest": "^26.9.0",
 | 
			
		||||
    "eslint-plugin-prettier": "^4.2.1",
 | 
			
		||||
    "eslint-plugin-jest": "^26.1.5",
 | 
			
		||||
    "eslint-plugin-prettier": "^4.0.0",
 | 
			
		||||
    "eslint-plugin-simple-import-sort": "^7.0.0",
 | 
			
		||||
    "jest": "^28.1.3",
 | 
			
		||||
    "jest": "^28.0.3",
 | 
			
		||||
    "jest-circus": "^27.5.1",
 | 
			
		||||
    "nock": "^13.2.9",
 | 
			
		||||
    "prettier": "^2.8.0",
 | 
			
		||||
    "ts-jest": "^28.0.8",
 | 
			
		||||
    "typescript": "^4.9.3"
 | 
			
		||||
    "nock": "^13.2.4",
 | 
			
		||||
    "prettier": "^2.6.2",
 | 
			
		||||
    "ts-jest": "^28.0.2",
 | 
			
		||||
    "typescript": "^4.6.4"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -77,20 +77,19 @@ export function getInputAsInt(
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function isCacheFeatureAvailable(): boolean {
 | 
			
		||||
    if (cache.isFeatureAvailable()) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (isGhes()) {
 | 
			
		||||
        logWarning(
 | 
			
		||||
            `Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.
 | 
			
		||||
    if (!cache.isFeatureAvailable()) {
 | 
			
		||||
        if (isGhes()) {
 | 
			
		||||
            logWarning(
 | 
			
		||||
                `Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.
 | 
			
		||||
Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/enterprise-server@3.5/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`
 | 
			
		||||
        );
 | 
			
		||||
            );
 | 
			
		||||
        } else {
 | 
			
		||||
            logWarning(
 | 
			
		||||
                "An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions."
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    logWarning(
 | 
			
		||||
        "An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions."
 | 
			
		||||
    );
 | 
			
		||||
    return false;
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user