Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow relative paths to be parent of workspace path #548

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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>
# LNRSCheckout V2 (forked off of @actions/checkout@v2)

# Checkout V2
In the examples below, use ***LexisNexis-GHA-Public/LNRSCheckout@v2.3.4.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: ''
23 changes: 23 additions & 0 deletions __test__/input-helper.test.ts
Original file line number Diff line number Diff line change
@@ -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()
12 changes: 9 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Checkout'
description: 'Checkout a Git repository at a particular version'
name: 'LNRSCheckout'
description: 'Checkout a Git repository at a particular version - LNRS version'
inputs:
repository:
description: 'Repository name with owner. For example, actions/checkout'
@@ -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
@@ -68,6 +71,9 @@ inputs:
When the `ssh-key` input is not provided, SSH URLs beginning with `git@github.com:` are
converted to HTTPS.
default: false
outputs:
WORKSPACE_DIR:
description: working directory for the project
runs:
using: node12
main: dist/index.js
Loading
Oops, something went wrong.