mirror of
https://code.forgejo.org/actions/checkout
synced 2024-11-22 00:50:39 +00:00
Improve checkout performance on Windows runners by upgrading @actions/github dependency (#1246)
* Improve checkout performance on Windows runners by upgrading @actions/github dependency Re: https://github.com/actions/checkout/issues/1186 @dscho discovered that the checkout action could stall for a considerable amount of time on Windows runners waiting for PowerShell invocations made from 'windows-release' npm package to complete. Then I studied the dependency chain to figure out where 'windows-release' was imported: '@actions/checkout'@main <- '@actions/github'@2.2.0 <- '@octokit/endpoint'@6.0.1 <- '@octokit/graphql'@4.3.1 <- '@octokit/request'@5.4.2 <- '@octokit/rest'@16.43.1 <- 'universal-user-agent'@4.0.1 <- 'os-name'@3.1.0 <- 'windows-release'@3.1.0 'universal-user-agent' package dropped its dependency on 'os-name' in https://github.com/gr2m/universal-user-agent/releases/tag/v6.0.0 . '@actions/github' v3 removed dependency on '@octokit/rest'@16.43.1 and allows users to move away from the old 'universal-user-agent' v4. (https://github.com/actions/toolkit/pull/453) This pull request attempts to update the version of '@actions/github' used in the checkout action to avoid importing 'windows-release'. Based on testing in my own repositories, I can see an improvement in reduced wait time between entering the checkout action and git actually starts to do useful work. * Update .licenses * Rebuild index.js
This commit is contained in:
parent
8f4b7f8486
commit
40a16ebeed
54 changed files with 2474 additions and 23225 deletions
BIN
.licenses/npm/@actions/github.dep.yml
generated
BIN
.licenses/npm/@actions/github.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/http-client-1.0.8.dep.yml
generated
BIN
.licenses/npm/@actions/http-client-1.0.8.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@octokit/auth-token.dep.yml
generated
BIN
.licenses/npm/@octokit/auth-token.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@octokit/endpoint.dep.yml
generated
BIN
.licenses/npm/@octokit/endpoint.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/graphql.dep.yml
generated
BIN
.licenses/npm/@octokit/graphql.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@octokit/plugin-paginate-rest.dep.yml
generated
BIN
.licenses/npm/@octokit/plugin-paginate-rest.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/plugin-request-log.dep.yml
generated
BIN
.licenses/npm/@octokit/plugin-request-log.dep.yml
generated
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@octokit/request.dep.yml
generated
BIN
.licenses/npm/@octokit/request.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/rest.dep.yml
generated
BIN
.licenses/npm/@octokit/rest.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/types.dep.yml
generated
BIN
.licenses/npm/@octokit/types.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@types/node.dep.yml
generated
BIN
.licenses/npm/@types/node.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/atob-lite.dep.yml
generated
BIN
.licenses/npm/atob-lite.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/before-after-hook.dep.yml
generated
BIN
.licenses/npm/before-after-hook.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/btoa-lite.dep.yml
generated
BIN
.licenses/npm/btoa-lite.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/cross-spawn.dep.yml
generated
BIN
.licenses/npm/cross-spawn.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/end-of-stream.dep.yml
generated
BIN
.licenses/npm/end-of-stream.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/get-stream.dep.yml
generated
BIN
.licenses/npm/get-stream.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/is-plain-object.dep.yml
generated
BIN
.licenses/npm/is-plain-object.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/is-stream.dep.yml
generated
BIN
.licenses/npm/is-stream.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/isexe.dep.yml
generated
BIN
.licenses/npm/isexe.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/isobject.dep.yml
generated
BIN
.licenses/npm/isobject.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/lodash.get.dep.yml
generated
BIN
.licenses/npm/lodash.get.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/lodash.set.dep.yml
generated
BIN
.licenses/npm/lodash.set.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/lodash.uniq.dep.yml
generated
BIN
.licenses/npm/lodash.uniq.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/macos-release.dep.yml
generated
BIN
.licenses/npm/macos-release.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/nice-try.dep.yml
generated
BIN
.licenses/npm/nice-try.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/node-fetch.dep.yml
generated
BIN
.licenses/npm/node-fetch.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/npm-run-path.dep.yml
generated
BIN
.licenses/npm/npm-run-path.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/octokit-pagination-methods.dep.yml
generated
BIN
.licenses/npm/octokit-pagination-methods.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/os-name.dep.yml
generated
BIN
.licenses/npm/os-name.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/p-finally.dep.yml
generated
BIN
.licenses/npm/p-finally.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/path-key.dep.yml
generated
BIN
.licenses/npm/path-key.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/pump.dep.yml
generated
BIN
.licenses/npm/pump.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/semver-5.7.1.dep.yml
generated
BIN
.licenses/npm/semver-5.7.1.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/shebang-command.dep.yml
generated
BIN
.licenses/npm/shebang-command.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/shebang-regex.dep.yml
generated
BIN
.licenses/npm/shebang-regex.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/signal-exit.dep.yml
generated
BIN
.licenses/npm/signal-exit.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/strip-eof.dep.yml
generated
BIN
.licenses/npm/strip-eof.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/universal-user-agent-5.0.0.dep.yml
generated
BIN
.licenses/npm/universal-user-agent-5.0.0.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/which.dep.yml
generated
BIN
.licenses/npm/which.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/windows-release.dep.yml
generated
BIN
.licenses/npm/windows-release.dep.yml
generated
Binary file not shown.
24393
dist/index.js
vendored
24393
dist/index.js
vendored
File diff suppressed because one or more lines are too long
872
package-lock.json
generated
872
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -30,7 +30,7 @@
|
|||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/exec": "^1.0.1",
|
||||
"@actions/github": "^2.2.0",
|
||||
"@actions/github": "^5.0.0",
|
||||
"@actions/io": "^1.1.3",
|
||||
"@actions/tool-cache": "^1.1.2",
|
||||
"uuid": "^3.3.3"
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import * as assert from 'assert'
|
||||
import * as core from '@actions/core'
|
||||
import * as fs from 'fs'
|
||||
import * as github from '@actions/github'
|
||||
import * as io from '@actions/io'
|
||||
import * as path from 'path'
|
||||
import * as retryHelper from './retry-helper'
|
||||
import * as toolCache from '@actions/tool-cache'
|
||||
import {default as uuid} from 'uuid/v4'
|
||||
import {getOctokit, Octokit} from './octokit-provider'
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32'
|
||||
|
||||
|
@ -84,11 +84,11 @@ export async function getDefaultBranch(
|
|||
): Promise<string> {
|
||||
return await retryHelper.execute(async () => {
|
||||
core.info('Retrieving the default branch name')
|
||||
const octokit = getOctokit(authToken, {baseUrl: baseUrl})
|
||||
const octokit = github.getOctokit(authToken, {baseUrl: baseUrl})
|
||||
let result: string
|
||||
try {
|
||||
// Get the default branch from the repo info
|
||||
const response = await octokit.repos.get({owner, repo})
|
||||
const response = await octokit.rest.repos.get({owner, repo})
|
||||
result = response.data.default_branch
|
||||
assert.ok(result, 'default_branch cannot be empty')
|
||||
} catch (err) {
|
||||
|
@ -125,19 +125,14 @@ async function downloadArchive(
|
|||
commit: string,
|
||||
baseUrl?: string
|
||||
): Promise<Buffer> {
|
||||
const octokit = getOctokit(authToken, {baseUrl: baseUrl})
|
||||
const params: Octokit.ReposGetArchiveLinkParams = {
|
||||
const octokit = github.getOctokit(authToken, {baseUrl: baseUrl})
|
||||
const download = IS_WINDOWS
|
||||
? octokit.rest.repos.downloadZipballArchive
|
||||
: octokit.rest.repos.downloadTarballArchive
|
||||
const response = await download({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
archive_format: IS_WINDOWS ? 'zipball' : 'tarball',
|
||||
ref: commit || ref
|
||||
}
|
||||
const response = await octokit.repos.getArchiveLink(params)
|
||||
if (response.status != 200) {
|
||||
throw new Error(
|
||||
`Unexpected response from GitHub API. Status: ${response.status}, Data: ${response.data}`
|
||||
)
|
||||
}
|
||||
|
||||
return Buffer.from(response.data) // response.data is ArrayBuffer
|
||||
})
|
||||
return Buffer.from(response.data as ArrayBuffer) // response.data is ArrayBuffer
|
||||
}
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
import * as github from '@actions/github'
|
||||
import {Octokit} from '@octokit/rest'
|
||||
import {getServerApiUrl} from './url-helper'
|
||||
|
||||
// Centralize all Octokit references by re-exporting
|
||||
export {Octokit} from '@octokit/rest'
|
||||
|
||||
export type OctokitOptions = {
|
||||
baseUrl?: string
|
||||
userAgent?: string
|
||||
}
|
||||
|
||||
export function getOctokit(authToken: string, opts: OctokitOptions) {
|
||||
const options: Octokit.Options = {
|
||||
baseUrl: getServerApiUrl(opts.baseUrl)
|
||||
}
|
||||
|
||||
if (opts.userAgent) {
|
||||
options.userAgent = opts.userAgent
|
||||
}
|
||||
|
||||
return new github.GitHub(authToken, options)
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
import {IGitCommandManager} from './git-command-manager'
|
||||
import * as core from '@actions/core'
|
||||
import * as github from '@actions/github'
|
||||
import {getOctokit} from './octokit-provider'
|
||||
import {isGhes} from './url-helper'
|
||||
|
||||
export const tagsRefSpec = '+refs/tags/*:refs/tags/*'
|
||||
|
@ -245,7 +244,7 @@ export async function checkCommitInfo(
|
|||
core.debug(
|
||||
`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`
|
||||
)
|
||||
const octokit = getOctokit(token, {
|
||||
const octokit = github.getOctokit(token, {
|
||||
baseUrl: baseUrl,
|
||||
userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload(
|
||||
'number'
|
||||
|
@ -253,7 +252,10 @@ export async function checkCommitInfo(
|
|||
process.env['GITHUB_RUN_ID']
|
||||
};expected_head_sha=${expectedHeadSha};actual_head_sha=${actualHeadSha})`
|
||||
})
|
||||
await octokit.repos.get({owner: repositoryOwner, repo: repositoryName})
|
||||
await octokit.rest.repos.get({
|
||||
owner: repositoryOwner,
|
||||
repo: repositoryName
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
core.debug(
|
||||
|
|
Loading…
Reference in a new issue