Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14f28534ef | ||
|
|
ae026cf7c6 | ||
|
|
3d0da1ea1a |
Vendored
-3
@@ -115,6 +115,3 @@
|
|||||||
|
|
||||||
### 3.1.3
|
### 3.1.3
|
||||||
- Fix to prevent from setting MYSYS environement variable globally [#1329](https://github.com/actions/toolkit/pull/1329).
|
- Fix to prevent from setting MYSYS environement variable globally [#1329](https://github.com/actions/toolkit/pull/1329).
|
||||||
|
|
||||||
### 3.1.4
|
|
||||||
- Fix zstd not being used due to `zstd --version` output change in zstd 1.5.4 release. See [#1353](https://github.com/actions/toolkit/pull/1353).
|
|
||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/cache",
|
"name": "@actions/cache",
|
||||||
"version": "3.1.4",
|
"version": "3.1.3",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@actions/cache",
|
"name": "@actions/cache",
|
||||||
"version": "3.1.4",
|
"version": "3.1.3",
|
||||||
"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.1.4",
|
"version": "3.1.3",
|
||||||
"preview": true,
|
"preview": true,
|
||||||
"description": "Actions cache lib",
|
"description": "Actions cache lib",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
+11
-11
@@ -71,15 +71,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 +94,18 @@ 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'])
|
const versionOutput = await getVersion('zstd')
|
||||||
const version = semver.clean(versionOutput)
|
const version = semver.clean(versionOutput)
|
||||||
core.debug(`zstd version: ${version}`)
|
|
||||||
|
|
||||||
if (versionOutput === '') {
|
if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
|
||||||
|
// zstd is not installed
|
||||||
return CompressionMethod.Gzip
|
return CompressionMethod.Gzip
|
||||||
} else {
|
} 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+26
-1
@@ -10,7 +10,7 @@ import * as util from 'util'
|
|||||||
import * as utils from './cacheUtils'
|
import * as utils from './cacheUtils'
|
||||||
import {SocketTimeout} from './constants'
|
import {SocketTimeout} from './constants'
|
||||||
import {DownloadOptions} from '../options'
|
import {DownloadOptions} from '../options'
|
||||||
import {retryHttpClientResponse} from './requestUtils'
|
import {retryHttpClientResponse, sleep} from './requestUtils'
|
||||||
|
|
||||||
import {AbortController} from '@azure/abort-controller'
|
import {AbortController} from '@azure/abort-controller'
|
||||||
|
|
||||||
@@ -161,6 +161,28 @@ export class DownloadProgress {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function displayDownloadProgress(message: any, startTime: number): Promise<void> {
|
||||||
|
const socket = message.socket
|
||||||
|
while(!message.complete) {
|
||||||
|
const byteRead = socket.bytesRead
|
||||||
|
const totalBytes = 100000
|
||||||
|
const percentage = (100 * (byteRead / totalBytes)).toFixed(
|
||||||
|
1
|
||||||
|
)
|
||||||
|
const elapsedTime = Date.now() - startTime
|
||||||
|
const downloadSpeed = (
|
||||||
|
byteRead /
|
||||||
|
(1024 * 1024) /
|
||||||
|
(elapsedTime / 1000)
|
||||||
|
).toFixed(1)
|
||||||
|
|
||||||
|
core.info(
|
||||||
|
`Received ${byteRead} of ${totalBytes} (${percentage}%), ${downloadSpeed} MBs/sec`
|
||||||
|
)
|
||||||
|
sleep(100)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download the cache using the Actions toolkit http-client
|
* Download the cache using the Actions toolkit http-client
|
||||||
*
|
*
|
||||||
@@ -171,6 +193,7 @@ export async function downloadCacheHttpClient(
|
|||||||
archiveLocation: string,
|
archiveLocation: string,
|
||||||
archivePath: string
|
archivePath: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
const startTime = Date.now()
|
||||||
const writeStream = fs.createWriteStream(archivePath)
|
const writeStream = fs.createWriteStream(archivePath)
|
||||||
const httpClient = new HttpClient('actions/cache')
|
const httpClient = new HttpClient('actions/cache')
|
||||||
const downloadResponse = await retryHttpClientResponse(
|
const downloadResponse = await retryHttpClientResponse(
|
||||||
@@ -184,6 +207,8 @@ export async function downloadCacheHttpClient(
|
|||||||
core.debug(`Aborting download, socket timed out after ${SocketTimeout} ms`)
|
core.debug(`Aborting download, socket timed out after ${SocketTimeout} ms`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await displayDownloadProgress(downloadResponse.message, startTime)
|
||||||
|
|
||||||
await pipeResponseToStream(downloadResponse, writeStream)
|
await pipeResponseToStream(downloadResponse, writeStream)
|
||||||
|
|
||||||
// Validate download size.
|
// Validate download size.
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ export function isRetryableStatusCode(statusCode?: number): boolean {
|
|||||||
return retryableStatusCodes.includes(statusCode)
|
return retryableStatusCodes.includes(statusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sleep(milliseconds: number): Promise<void> {
|
export async function sleep(milliseconds: number): Promise<void> {
|
||||||
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,44 +145,6 @@ describe('proxy', () => {
|
|||||||
expect(bypass).toBeFalsy()
|
expect(bypass).toBeFalsy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('checkBypass returns true if host with subdomain in no_proxy', () => {
|
|
||||||
process.env['no_proxy'] = 'myserver.com'
|
|
||||||
const bypass = pm.checkBypass(new URL('https://sub.myserver.com'))
|
|
||||||
expect(bypass).toBeTruthy()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('checkBypass returns false if no_proxy is subdomain', () => {
|
|
||||||
process.env['no_proxy'] = 'myserver.com'
|
|
||||||
const bypass = pm.checkBypass(new URL('https://myserver.com.evil.org'))
|
|
||||||
expect(bypass).toBeFalsy()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('checkBypass returns false if no_proxy is part of domain', () => {
|
|
||||||
process.env['no_proxy'] = 'myserver.com'
|
|
||||||
const bypass = pm.checkBypass(new URL('https://evilmyserver.com'))
|
|
||||||
expect(bypass).toBeFalsy()
|
|
||||||
})
|
|
||||||
|
|
||||||
// Do not strip leading dots as per https://github.com/actions/runner/blob/97195bad5870e2ad0915ebfef1616083aacf5818/docs/adrs/0263-proxy-support.md
|
|
||||||
it('checkBypass returns false if host with leading dot in no_proxy', () => {
|
|
||||||
process.env['no_proxy'] = '.myserver.com'
|
|
||||||
const bypass = pm.checkBypass(new URL('https://myserver.com'))
|
|
||||||
expect(bypass).toBeFalsy()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('checkBypass returns true if host with subdomain in no_proxy defined with leading "."', () => {
|
|
||||||
process.env['no_proxy'] = '.myserver.com'
|
|
||||||
const bypass = pm.checkBypass(new URL('https://sub.myserver.com'))
|
|
||||||
expect(bypass).toBeTruthy()
|
|
||||||
})
|
|
||||||
|
|
||||||
// Do not match wildcard ("*") as per https://github.com/actions/runner/blob/97195bad5870e2ad0915ebfef1616083aacf5818/docs/adrs/0263-proxy-support.md
|
|
||||||
it('checkBypass returns true if no_proxy is "*"', () => {
|
|
||||||
process.env['no_proxy'] = '*'
|
|
||||||
const bypass = pm.checkBypass(new URL('https://anything.whatsoever.com'))
|
|
||||||
expect(bypass).toBeFalsy()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('HttpClient does basic http get request through proxy', async () => {
|
it('HttpClient does basic http get request through proxy', async () => {
|
||||||
process.env['http_proxy'] = _proxyUrl
|
process.env['http_proxy'] = _proxyUrl
|
||||||
const httpClient = new httpm.HttpClient()
|
const httpClient = new httpm.HttpClient()
|
||||||
|
|||||||
@@ -51,15 +51,7 @@ export function checkBypass(reqUrl: URL): boolean {
|
|||||||
.split(',')
|
.split(',')
|
||||||
.map(x => x.trim().toUpperCase())
|
.map(x => x.trim().toUpperCase())
|
||||||
.filter(x => x)) {
|
.filter(x => x)) {
|
||||||
if (
|
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
||||||
upperReqHosts.some(
|
|
||||||
x =>
|
|
||||||
x === upperNoProxyItem ||
|
|
||||||
x.endsWith(`.${upperNoProxyItem}`) ||
|
|
||||||
(upperNoProxyItem.startsWith('.') &&
|
|
||||||
x.endsWith(`${upperNoProxyItem}`))
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user