Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4efc4b9e06 | ||
|
|
b680ef8e68 | ||
|
|
fe8c762d61 | ||
|
|
79886daf63 | ||
|
|
1a1d5e3792 |
@@ -10,13 +10,8 @@ describe('isGhes', () => {
|
|||||||
expect(config.isGhes()).toBe(false)
|
expect(config.isGhes()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return false when the request domain ends with ghe.com', () => {
|
it('should return false when the request has ACTIONS_RESULTS_URL set', () => {
|
||||||
process.env.GITHUB_SERVER_URL = 'https://my.domain.ghe.com'
|
process.env.ACTIONS_RESULTS_URL = 'my.results.url'
|
||||||
expect(config.isGhes()).toBe(false)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should return false when the request domain ends with ghe.localhost', () => {
|
|
||||||
process.env.GITHUB_SERVER_URL = 'https://my.domain.ghe.localhost'
|
|
||||||
expect(config.isGhes()).toBe(false)
|
expect(config.isGhes()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,11 @@ export function isGhes(): boolean {
|
|||||||
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||||
)
|
)
|
||||||
|
|
||||||
const hostname = ghUrl.hostname.trimEnd().toUpperCase()
|
const isGitHubHost = ghUrl.hostname.trimEnd().toUpperCase() === 'GITHUB.COM'
|
||||||
const isGitHubHost = hostname === 'GITHUB.COM'
|
const isResultsServiceRequest =
|
||||||
const isGheHost =
|
process.env['ACTIONS_RESULTS_URL'] != undefined
|
||||||
hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST')
|
|
||||||
|
|
||||||
return !isGitHubHost && !isGheHost
|
return !isGitHubHost && !isResultsServiceRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGitHubWorkspaceDir(): string {
|
export function getGitHubWorkspaceDir(): string {
|
||||||
|
|||||||
Vendored
-4
@@ -168,7 +168,3 @@
|
|||||||
### 3.2.3
|
### 3.2.3
|
||||||
|
|
||||||
- Fixed a bug that mutated path arguments to `getCacheVersion` [#1378](https://github.com/actions/toolkit/pull/1378)
|
- Fixed a bug that mutated path arguments to `getCacheVersion` [#1378](https://github.com/actions/toolkit/pull/1378)
|
||||||
|
|
||||||
### 3.2.4
|
|
||||||
|
|
||||||
- Updated `isGhes` check to include `.ghe.com` and `.ghe.localhost` as accepted hosts
|
|
||||||
-10
@@ -48,17 +48,7 @@ test('isGhes returns false for github.com', async () => {
|
|||||||
expect(cacheUtils.isGhes()).toBe(false)
|
expect(cacheUtils.isGhes()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('isGhes returns false for ghe.com', async () => {
|
|
||||||
process.env.GITHUB_SERVER_URL = 'https://somedomain.ghe.com'
|
|
||||||
expect(cacheUtils.isGhes()).toBe(false)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('isGhes returns true for enterprise URL', async () => {
|
test('isGhes returns true for enterprise URL', async () => {
|
||||||
process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'
|
process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'
|
||||||
expect(cacheUtils.isGhes()).toBe(true)
|
expect(cacheUtils.isGhes()).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('isGhes returns false for ghe.localhost', () => {
|
|
||||||
process.env.GITHUB_SERVER_URL = 'https://my.domain.ghe.localhost'
|
|
||||||
expect(cacheUtils.isGhes()).toBe(false)
|
|
||||||
})
|
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/cache",
|
"name": "@actions/cache",
|
||||||
"version": "3.2.4",
|
"version": "3.2.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@actions/cache",
|
"name": "@actions/cache",
|
||||||
"version": "3.2.4",
|
"version": "3.2.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/cache",
|
"name": "@actions/cache",
|
||||||
"version": "3.2.4",
|
"version": "3.2.3",
|
||||||
"preview": true,
|
"preview": true,
|
||||||
"description": "Actions cache lib",
|
"description": "Actions cache lib",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
+22
-35
@@ -7,11 +7,7 @@ import * as path from 'path'
|
|||||||
import * as semver from 'semver'
|
import * as semver from 'semver'
|
||||||
import * as util from 'util'
|
import * as util from 'util'
|
||||||
import {v4 as uuidV4} from 'uuid'
|
import {v4 as uuidV4} from 'uuid'
|
||||||
import {
|
import {CacheFilename, CompressionMethod} from './constants'
|
||||||
CacheFilename,
|
|
||||||
CompressionMethod,
|
|
||||||
GnuTarPathOnWindows
|
|
||||||
} from './constants'
|
|
||||||
|
|
||||||
// From https://github.com/actions/toolkit/blob/main/packages/tool-cache/src/tool-cache.ts#L23
|
// From https://github.com/actions/toolkit/blob/main/packages/tool-cache/src/tool-cache.ts#L23
|
||||||
export async function createTempDirectory(): Promise<string> {
|
export async function createTempDirectory(): Promise<string> {
|
||||||
@@ -56,13 +52,8 @@ export async function resolvePaths(patterns: string[]): Promise<string[]> {
|
|||||||
.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
|
.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
|
||||||
core.debug(`Matched: ${relativeFile}`)
|
core.debug(`Matched: ${relativeFile}`)
|
||||||
// Paths are made relative so the tar entries are all relative to the root of the workspace.
|
// Paths are made relative so the tar entries are all relative to the root of the workspace.
|
||||||
if (relativeFile === '') {
|
|
||||||
// path.relative returns empty string if workspace and file are equal
|
|
||||||
paths.push('.')
|
|
||||||
} else {
|
|
||||||
paths.push(`${relativeFile}`)
|
paths.push(`${relativeFile}`)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return paths
|
return paths
|
||||||
}
|
}
|
||||||
@@ -71,15 +62,11 @@ export async function unlinkFile(filePath: fs.PathLike): Promise<void> {
|
|||||||
return util.promisify(fs.unlink)(filePath)
|
return util.promisify(fs.unlink)(filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getVersion(
|
async function getVersion(app: string): Promise<string> {
|
||||||
app: string,
|
core.debug(`Checking ${app} --version`)
|
||||||
additionalArgs: string[] = []
|
|
||||||
): Promise<string> {
|
|
||||||
let versionOutput = ''
|
let versionOutput = ''
|
||||||
additionalArgs.push('--version')
|
|
||||||
core.debug(`Checking ${app} ${additionalArgs.join(' ')}`)
|
|
||||||
try {
|
try {
|
||||||
await exec.exec(`${app}`, additionalArgs, {
|
await exec.exec(`${app} --version`, [], {
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
silent: true,
|
silent: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
@@ -98,14 +85,23 @@ async function getVersion(
|
|||||||
|
|
||||||
// Use zstandard if possible to maximize cache performance
|
// Use zstandard if possible to maximize cache performance
|
||||||
export async function getCompressionMethod(): Promise<CompressionMethod> {
|
export async function getCompressionMethod(): Promise<CompressionMethod> {
|
||||||
const versionOutput = await getVersion('zstd', ['--quiet'])
|
if (process.platform === 'win32' && !(await isGnuTarInstalled())) {
|
||||||
const version = semver.clean(versionOutput)
|
// Disable zstd due to bug https://github.com/actions/cache/issues/301
|
||||||
core.debug(`zstd version: ${version}`)
|
|
||||||
|
|
||||||
if (versionOutput === '') {
|
|
||||||
return CompressionMethod.Gzip
|
return CompressionMethod.Gzip
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
const versionOutput = await getVersion('zstd')
|
||||||
|
const version = semver.clean(versionOutput)
|
||||||
|
|
||||||
|
if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
|
||||||
|
// zstd is not installed
|
||||||
|
return CompressionMethod.Gzip
|
||||||
|
} else if (!version || semver.lt(version, 'v1.3.2')) {
|
||||||
|
// zstd is installed but using a version earlier than v1.3.2
|
||||||
|
// v1.3.2 is required to use the `--long` options in zstd
|
||||||
return CompressionMethod.ZstdWithoutLong
|
return CompressionMethod.ZstdWithoutLong
|
||||||
|
} else {
|
||||||
|
return CompressionMethod.Zstd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,12 +111,9 @@ export function getCacheFileName(compressionMethod: CompressionMethod): string {
|
|||||||
: CacheFilename.Zstd
|
: CacheFilename.Zstd
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getGnuTarPathOnWindows(): Promise<string> {
|
export async function isGnuTarInstalled(): Promise<boolean> {
|
||||||
if (fs.existsSync(GnuTarPathOnWindows)) {
|
|
||||||
return GnuTarPathOnWindows
|
|
||||||
}
|
|
||||||
const versionOutput = await getVersion('tar')
|
const versionOutput = await getVersion('tar')
|
||||||
return versionOutput.toLowerCase().includes('gnu tar') ? io.which('tar') : ''
|
return versionOutput.toLowerCase().includes('gnu tar')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function assertDefined<T>(name: string, value?: T): T {
|
export function assertDefined<T>(name: string, value?: T): T {
|
||||||
@@ -135,11 +128,5 @@ export function isGhes(): boolean {
|
|||||||
const ghUrl = new URL(
|
const ghUrl = new URL(
|
||||||
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||||
)
|
)
|
||||||
|
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'
|
||||||
const hostname = ghUrl.hostname.trimEnd().toUpperCase()
|
|
||||||
const isGitHubHost = hostname === 'GITHUB.COM'
|
|
||||||
const isGheHost =
|
|
||||||
hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST')
|
|
||||||
|
|
||||||
return !isGitHubHost && !isGheHost
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user