enbl-4519 updating code to use relative paths that are parent paths of the workspace

This commit is contained in:
Kenneth Garza 2021-06-29 11:28:31 -04:00
parent 25a956c84d
commit e6a424882a
8 changed files with 13062 additions and 12835 deletions

View file

@ -1,5 +1,8 @@
# Changelog
## v2.3.1.1
- Adding paramater for specifying specific working directory on the runner. This is useful for windows runners in which the working directory is too long and causing issues with npm and other build tools.
## v2.3.1
- [Fix default branch resolution for .wiki and when using SSH](https://github.com/actions/checkout/pull/284)

View file

@ -1,8 +1,6 @@
<p align="center">
<a href="https://github.com/actions/checkout"><img alt="GitHub Actions status" src="https://github.com/actions/checkout/workflows/test-local/badge.svg"></a>
</p>
# GitCheckout V2 (forked off of @actions/checkout@v2)
# Checkout V2
In the examples below, use ***LexisNexis-GHA-Public/GitCheckout@v2.3.1.1*** instead.
This action checks-out your repository under `$GITHUB_WORKSPACE`, so your workflow can access it.
@ -12,6 +10,22 @@ The auth token is persisted in the local git config. This enables your scripts t
When Git 2.18 or higher is not in your PATH, falls back to the REST API to download the files.
## A note about your `$GITHUB_WORKSPACE`
On windows runner's this path is the working directory of your github runner + repo name x2. The issue is that long repo names may result in exceeding the windows file name length restrictions, expecially if you count adding npm installers and other package management systems. The naming format is the same for linux/macOS runners, however they do not have the same limitations Windows has.
d:\gh\01\_work\very-long-repo-name\very-long-repo-name\
This particular codebase has been modified to allow the `path` parameter to use parent folder structure.
path: '..\..\repo-workingdir'
allow_parent_path: true
Results in a working directory:
d:\gh\01\_work\repo-workingdir
In the end this is better than what we had before. However the original working directory will still be required. Also note it's possible this can be dangerous so be careful using this feature.
# What's new
- Improved performance
@ -82,9 +96,14 @@ Refer [here](https://github.com/actions/checkout/blob/v1/README.md) for previous
# Default: true
persist-credentials: ''
# Relative path under $GITHUB_WORKSPACE to place the repository
# Relative path under the workspace folder to place the repository
path: ''
# allows path option to result in a path that is a parent of the working
# directory. This may have unforseen consequences.
# Default: false
allow_parent_path: ''
# Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching
# Default: true
clean: ''

View file

@ -110,6 +110,29 @@ describe('input-helper tests', () => {
)
})
it('parent path failure', () => {
inputs.path = '../../testdir'
try {
let test = inputHelper.getInputs()
assert.fail("Test should have thrown an exception")
} catch {
// empty, if it throws its good
}
})
it('parent path success', () => {
inputs.path = '../../testdir'
inputs.allow_parent_path = true
const settings: IGitSourceSettings = inputHelper.getInputs()
expect(settings.repositoryPath).toBe(
path.join(gitHubWorkspace, '..', '..', 'testdir')
)
})
it('sets ref to empty when explicit sha', () => {
inputs.ref = '1111111111222222222233333333334444444444'
const settings: IGitSourceSettings = inputHelper.getInputs()

View file

@ -1,4 +1,4 @@
name: 'Checkout'
name: 'GitCheckout'
description: 'Checkout a Git repository at a particular version'
inputs:
repository:
@ -49,7 +49,10 @@ inputs:
description: 'Whether to configure the token or SSH key with the local git config'
default: true
path:
description: 'Relative path under $GITHUB_WORKSPACE to place the repository'
description: 'Relative path under the workspace folder to place the repository'
allow_parent_path:
description: 'allows path option to result in a path that is a parent of the working directory. This may have unforseen consequences.'
default: false
clean:
description: 'Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching'
default: true

25808
dist/index.js vendored

File diff suppressed because it is too large Load diff

15
package-lock.json generated
View file

@ -971,11 +971,10 @@
}
}
},
"@zeit/ncc": {
"version": "0.20.5",
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.20.5.tgz",
"integrity": "sha512-XU6uzwvv95DqxciQx+aOLhbyBx/13ky+RK1y88Age9Du3BlA4mMPCy13BGjayOrrumOzlq1XV3SD/BWiZENXlw==",
"dev": true
"@vercel/ncc": {
"version": "0.28.6",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.28.6.tgz",
"integrity": "sha512-t4BoSSuyK8BZaUE0gV18V6bkFs4st7baumtFGa50dv1tMu2GDBEBF8sUZaKBdKiL6DzJ2D2+XVCwYWWDcQOYdQ=="
},
"abab": {
"version": "2.0.3",
@ -6734,9 +6733,9 @@
}
},
"typescript": {
"version": "3.6.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.4.tgz",
"integrity": "sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg==",
"version": "3.9.10",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz",
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==",
"dev": true
},
"uglify-js": {

View file

@ -31,6 +31,7 @@
"@actions/github": "^2.2.0",
"@actions/io": "^1.0.1",
"@actions/tool-cache": "^1.1.2",
"@vercel/ncc": "^0.28.6",
"uuid": "^3.3.3"
},
"devDependencies": {
@ -38,7 +39,6 @@
"@types/node": "^12.7.12",
"@types/uuid": "^3.4.6",
"@typescript-eslint/parser": "^2.8.0",
"@zeit/ncc": "^0.20.5",
"eslint": "^5.16.0",
"eslint-plugin-github": "^2.0.0",
"eslint-plugin-jest": "^22.21.0",
@ -47,6 +47,6 @@
"js-yaml": "^3.13.1",
"prettier": "^1.19.1",
"ts-jest": "^24.2.0",
"typescript": "^3.6.4"
"typescript": "^3.9.10"
}
}

View file

@ -40,11 +40,12 @@ export function getInputs(): IGitSourceSettings {
githubWorkspacePath,
result.repositoryPath
)
if (
!(result.repositoryPath + path.sep).startsWith(
githubWorkspacePath + path.sep
)
) {
const allowParentPath = core.getInput('allow_parent_path')
? core.getInput('allow_parent_path').toString().toLowerCase() === 'true'
: false
if (!allowParentPath && !(result.repositoryPath + path.sep).startsWith(githubWorkspacePath + path.sep)) {
throw new Error(
`Repository path '${result.repositoryPath}' is not under '${githubWorkspacePath}'`
)
@ -114,6 +115,7 @@ export function getInputs(): IGitSourceSettings {
result.sshStrict =
(core.getInput('ssh-strict') || 'true').toUpperCase() === 'TRUE'
// Persist credentials
result.persistCredentials =
(core.getInput('persist-credentials') || 'false').toUpperCase() === 'TRUE'