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

Make require relative to GitHub workspace #116

Conversation

robyoung
Copy link
Contributor

Change to the GITHUB_WORKSPACE directory before running the script so that callers do not have to explicitly use the GITHUB_WORKSPACE environment variable when requiring script files.

Workflow run steps are run within the GITHUB_WORKSPACE so this seems like the expected default.

@robyoung robyoung requested a review from a team February 22, 2021 11:08
@robyoung robyoung force-pushed the make-require-relative-to-github-workspace branch from 78916ad to 076d4a8 Compare March 2, 2021 07:16
@joshmgross
Copy link
Member

@robyoung could this break existing uses of this action that assume the require isn't relative?

@robyoung
Copy link
Contributor Author

robyoung commented Mar 4, 2021

Not that I can think of if they assume the require isn't relative. If an absolute path is provided it still works as expected because in those cases the current working directory is irrelevant.

Uses that depend on whatever the current working directory is now would break (assuming that is different to GITHUB_WORKSPACE) but I think that's ok as it's explicitly unsupported in the README.

@robyoung
Copy link
Contributor Author

@joshmgross is there anything else you need before this can be merged?

@joshmgross
Copy link
Member

👋 Hey @robyoung, sorry for the delay. I'll try to test this out next week and get it merged.

Change to the GITHUB_WORKSPACE directory before running the script so
that callers do not have to exlicitly use the GITHUB_WORKSPACE
environment variable when requiring script files.

Workflow run steps are run within the GITHUB_WORKSPACE so this seems
like the expected default.
This is a non breaking change as the documented approach still works as
expected.
@robyoung robyoung force-pushed the make-require-relative-to-github-workspace branch from 076d4a8 to 3d4b500 Compare April 8, 2021 13:18
@robyoung
Copy link
Contributor Author

robyoung commented Apr 8, 2021

Just rebased to resolve a conflict with the updated version. Any idea when this may get reviewed @joshmgross

@joshmgross joshmgross self-assigned this Apr 20, 2021
@joshmgross
Copy link
Member

👋 Hey @robyoung, apologies again for the delay. The changes look good to me but I need to run through a few test scenarios to make sure we're not breaking any existing uses.

@jclem
Copy link
Contributor

jclem commented Apr 21, 2021

Unfortunately, relative requires not working isn't because of the working directory (actions run by default in the GITHUB_WORKSPACE, as it is). Instead, it's because require resolves paths relative to the module—in this case, the module location is where the actions/github-script action was downloaded to on the runner.

This is why although tests pass in this fork, calls to require relative to the workspace still will not function. We're still searching for a way to resolve this.

I'm going to close this issue, but @robyoung please feel free to follow up if you have any other questions!

@jclem jclem closed this Apr 21, 2021
@joshmgross
Copy link
Member

joshmgross commented Apr 21, 2021

#135 should fix this

Edit: Published in V4 https://github.com/actions/github-script/releases/tag/v4.0.0

@robyoung robyoung deleted the make-require-relative-to-github-workspace branch April 28, 2021 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants