Skip to content

Fix action when using self-hosted runnners #54

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

Merged
merged 2 commits into from
Jun 9, 2020
Merged

Conversation

robertbrignull
Copy link
Contributor

@robertbrignull robertbrignull commented Jun 4, 2020

This makes the action work on a self-hosted runner for me.

First, I was able to reproduce the action failing on the second build because of directories not being cleared. Switching to this branch fixed it and I could run the action repeatedly.

This PR moves all files that we create to the RUNNER_TEMP directory instead of placing them relative to RUNNER_WORKSPACE. This means that files get cleaned between action runs.

Merge / deployment checklist

  • Run test builds as necessary. Can be on this repository or elsewhere as needed in order to test the change - please include links to tests in other repos!
    • CodeQL using init/analyze actions
    • 3rd party tool using upload action
  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.

@aibaars
Copy link
Collaborator

aibaars commented Jun 5, 2020

These environment variables are not mentioned in https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables

Could you point at the documentation of those environment variables? Have you considered using GITHUB_WORKSPACE instead? I would consider it a bug in Actions if that folder is not cleared between runs. It would make little sense for unrelated jobs to leave "surprises" for the next job in the workspace folder.

Do you know if RUNNER_TEMP is "private" to each runner process. If not then there might be problems if a single machine runs several self-hosted runner processes.

@robertbrignull
Copy link
Contributor Author

For info, here are all the relevant environment variables available on my self-hosted runner

PWD=/actions-runner/_work/robertbrignull-self-hosted/robertbrignull-self-hosted
RUNNER_TOOL_CACHE=/actions-runner/_work/_tool
RUNNER_TEMP=/actions-runner/_work/_temp
RUNNER_WORKSPACE=/actions-runner/_work/robertbrignull-self-hosted
GITHUB_EVENT_PATH=/actions-runner/_work/_temp/_github_workflow/event.json
GITHUB_WORKSPACE=/actions-runner/_work/robertbrignull-self-hosted/robertbrignull-self-hosted

You're right GITHUB_WORKSPACE is cleared between runs because otherwise checkouts would overlap and it would be chaos. The RUNNER_WORKSPACE dir isn't and this is the issue we're running into. It is not documented but we have confirmation from the actions team that the RUNNER_TEMP dir is also cleared.

As you can see from the directory paths, the temp dir is private to the runner process as you have to give each runner a _work directory.

I think the main downside with putting stuff in the GITHUB_WORKSPACE directory is you have to worry about clashing with files from the repository. Obviously this can be worked around by generating random names or appending numbers as necessary. I think the question is whether this is better or worse than placing the files in a "hidden" directory like this where the user won't otherwise find them.

@aibaars
Copy link
Collaborator

aibaars commented Jun 5, 2020

The documentation of GITHUB_WORKSPACE is quite confusing. The documentation suggests the repository is checked out in a subdirectory of GITHUB_WORKSPACE while in fact GITHUB_WORKSPACE is the repository folder.

From the docs:

The GitHub workspace directory path. The workspace directory contains a subdirectory with a copy of your repository ...

RUNNER_TEMP looks like good place indeed.

It might be worth asking whether RUNNER_WORKSPACE is supposed to be cleared by the worker. It sounds like a bug if it isn't.

@robertbrignull
Copy link
Contributor Author

@rneatherway, does it make sense for you to review this as you've done the research into this area?

@rneatherway
Copy link
Contributor

Happy to ✋

@rneatherway
Copy link
Contributor

The documentation of GITHUB_WORKSPACE is quite confusing. The documentation suggests the repository is checked out in a subdirectory of GITHUB_WORKSPACE while in fact GITHUB_WORKSPACE is the repository folder.

I agree, this seems simply wrong. @robertbrignull could you raise an issue with the relevant doc team? I think that you could find the right place using #product-documentation

Copy link
Contributor

@rneatherway rneatherway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a perfectly sensible way of addressing the issue.

@github github deleted a comment from rneatherway Jun 9, 2020
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