mirror of https://github.com/actions/setup-go.git
				
				
				
			add GOTMPDIR override for Windows workflow
add validation for GOCACHE, GOMODCACHE, and GOTMPDIR on Windows Signed-off-by: Anton Troshin <anton@diagrid.io>
This commit is contained in:
		
							parent
							
								
									bda02de888
								
							
						
					
					
						commit
						fdd38598b9
					
				|  | @ -134,3 +134,40 @@ jobs: | |||
|         with: | ||||
|           go-version: ${{ matrix.go }} | ||||
|           cache: ${{ matrix.cache }} | ||||
| 
 | ||||
|   go-mod-cache-and-tmp-location: | ||||
|     name: 'Validate if GOCACHE, GOMODCACHE, GOTMPDIR is set to drive D:' | ||||
|     runs-on: windows-latest | ||||
|     strategy: | ||||
|       matrix: | ||||
|         cache: [false] | ||||
|         go: [1.20.1] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
| 
 | ||||
|       - name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}' | ||||
|         uses: ./ | ||||
|         with: | ||||
|           go-version: ${{ matrix.go }} | ||||
|           cache: ${{ matrix.cache }} | ||||
| 
 | ||||
|       - name: 'Check if go mod cache and tmp location is set correctly' | ||||
|         run: | | ||||
|           go env GOCACHE | ||||
|           go env GOMODCACHE | ||||
|           go env GOTMPDIR | ||||
| 
 | ||||
|           if [ $(go env GOCACHE) != 'D:\Users\runneradmin\AppData\Local\go-build' ];then | ||||
|             echo 'go env GOCACHE should return "D:\Users\runneradmin\AppData\Local\go-build"' | ||||
|             exit 1 | ||||
|           fi | ||||
|           if [ $(go env GOMODCACHE) != 'D:\Users\runneradmin\go\pkg\mod' ];then | ||||
|             echo 'go env GOMODCACHE should return "D:\Users\runneradmin\go\pkg\mod"' | ||||
|             exit 1 | ||||
|           fi | ||||
|           if [ $(go env GOTMPDIR) != 'D:\gotmp' ];then | ||||
|             echo 'go env GOTMPDIR should return "D:\gotmp"' | ||||
|             exit 1 | ||||
|           fi | ||||
| 
 | ||||
|         shell: bash | ||||
|  |  | |||
|  | @ -88091,6 +88091,18 @@ const setWindowsCacheDirectories = () => __awaiter(void 0, void 0, void 0, funct | |||
|     } | ||||
|     const setModOutput = yield (0, cache_utils_1.getCommandOutput)(`go env -w GOMODCACHE=${goModCache}`); | ||||
|     core.info(`go env -w GOMODCACHE output: ${setModOutput}`); | ||||
|     let goTmpDir = yield (0, cache_utils_1.getCommandOutput)(`go env GOTMPDIR`); | ||||
|     core.info(`GOTMPDIR: ${goTmpDir}`); | ||||
|     if (!goTmpDir || goTmpDir === '') { | ||||
|         goTmpDir = 'D:\\gotmp'; | ||||
|     } | ||||
|     goTmpDir = goTmpDir.replace('C:', 'D:').replace('c:', 'd:'); | ||||
|     if (!fs_1.default.existsSync(goTmpDir)) { | ||||
|         core.info(`${goTmpDir} does not exist. Creating`); | ||||
|         fs_1.default.mkdirSync(goTmpDir, { recursive: true }); | ||||
|     } | ||||
|     const setGoTmpOutput = yield (0, cache_utils_1.getCommandOutput)(`go env -w GOTMPDIR=${goTmpDir}`); | ||||
|     core.info(`go env -w GOTMPDIR output: ${setGoTmpOutput}`); | ||||
| }); | ||||
| exports.setWindowsCacheDirectories = setWindowsCacheDirectories; | ||||
| const findDependencyFile = (packageManager) => { | ||||
|  |  | |||
|  | @ -6,8 +6,12 @@ import fs from 'fs'; | |||
| 
 | ||||
| import {Outputs, State} from './constants'; | ||||
| import {PackageManagerInfo} from './package-managers'; | ||||
| import {getCacheDirectoryPath, getCommandOutput, getPackageManagerInfo} from './cache-utils'; | ||||
| import os from "os"; | ||||
| import { | ||||
|   getCacheDirectoryPath, | ||||
|   getCommandOutput, | ||||
|   getPackageManagerInfo | ||||
| } from './cache-utils'; | ||||
| import os from 'os'; | ||||
| 
 | ||||
| export const restoreCache = async ( | ||||
|   versionSpec: string, | ||||
|  | @ -75,8 +79,27 @@ export const setWindowsCacheDirectories = async () => { | |||
|     fs.mkdirSync(goModCache, {recursive: true}); | ||||
|   } | ||||
| 
 | ||||
|   const setModOutput = await getCommandOutput(`go env -w GOMODCACHE=${goModCache}`); | ||||
|   const setModOutput = await getCommandOutput( | ||||
|     `go env -w GOMODCACHE=${goModCache}` | ||||
|   ); | ||||
|   core.info(`go env -w GOMODCACHE output: ${setModOutput}`); | ||||
| 
 | ||||
|   let goTmpDir = await getCommandOutput(`go env GOTMPDIR`); | ||||
|   core.info(`GOTMPDIR: ${goTmpDir}`); | ||||
|   if (!goTmpDir || goTmpDir === '') { | ||||
|     goTmpDir = 'D:\\gotmp'; | ||||
|   } | ||||
|   goTmpDir = goTmpDir.replace('C:', 'D:').replace('c:', 'd:'); | ||||
| 
 | ||||
|   if (!fs.existsSync(goTmpDir)) { | ||||
|     core.info(`${goTmpDir} does not exist. Creating`); | ||||
|     fs.mkdirSync(goTmpDir, {recursive: true}); | ||||
|   } | ||||
| 
 | ||||
|   const setGoTmpOutput = await getCommandOutput( | ||||
|     `go env -w GOTMPDIR=${goTmpDir}` | ||||
|   ); | ||||
|   core.info(`go env -w GOTMPDIR output: ${setGoTmpOutput}`); | ||||
| }; | ||||
| 
 | ||||
| const findDependencyFile = (packageManager: PackageManagerInfo) => { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Anton Troshin
						Anton Troshin