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

Updated self-hosted guidelines for Linux and Mac #90

Merged
merged 4 commits into from
May 11, 2020

Conversation

konradpabjan
Copy link
Collaborator

@konradpabjan konradpabjan commented May 8, 2020

Automatic self-hosted setup with v2 will not work out of the box on Mac and Linux unless users perform some extra steps on their machines.

This updates the README so users know what they have to do.

🎨 Rendered🖌

@@ -136,14 +136,34 @@ You should specify only a major and minor version if you are okay with the most

# Using `setup-python` with a self hosted runner

If you would like to use `setup-python` and a self-hosted runner, there isn't much that you need to do. When `setup-python` is run for the first time with a version of Python that it doesn't have, it will download the appropriate version, and set up the tools cache on your machine. Any subsequent runs will use the Python versions that were previously downloaded.
If you would like to use `setup-python` and a self-hosted runner, there are a few extra things you need to make sure are set up so that new versions of Python can be downloaded and configured on your runner.
Copy link
Contributor

@brcrista brcrista May 8, 2020

Choose a reason for hiding this comment

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

make sure are set up

+1 👍

README.md Outdated Show resolved Hide resolved
README.md Outdated
### Linux

- The Python packages that are downloaded from `actions/python-versions` are originally compiled from source in `/opt/hostedtoolcache/` with the [--enable-shared](https://github.com/actions/python-versions/blob/94f04ae6806c6633c82db94c6406a16e17decd5c/builders/ubuntu-python-builder.psm1#L35) flag which makes them non portable.
- Create an environment variable called `AGENT_TOOLSDIRECTORY` and set it to `/opt/hostedtoolcache`. This is used to control where Python gets set up and installed.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better if we could use RUNNER_TOOLSDIRECTORY. I think it would be easiest just to shim it in the action -- have setup-python set AGENT_TOOLSDIRECTORY to the value of RUNNER_TOOLSDIRECTORY.

Copy link
Collaborator Author

@konradpabjan konradpabjan May 11, 2020

Choose a reason for hiding this comment

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

We got rid of the RUNNER_TOOLSDIRECTORY env variable, see the comment here: #85 (comment)

If you search through this repo, there are no more references to it.

Also, nix-template-setup.sh doesn't have any references to RUNNER_TOOLSDIRECTORY so we should just stick to AGENT_TOOLSDIRECTORY

README.md Outdated Show resolved Hide resolved
README.md Outdated
- Create an environment variable called `AGENT_TOOLSDIRECTORY` and set it to `/opt/hostedtoolcache`. This is used to control where Python gets set up and installed.
- In the same shell that your runner is using, type `AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache`
- A more permanent way of setting the environment variable is to create a `.env` file in the same directory as your runner and to add `AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache`. This ensures the variable is always set if your runner is configured as a service.
- It is not possible to start the Linux runner with `sudo` and the `/opt` directory usually requires root privileges to write to. To get around this you can change certain permissions.
Copy link
Contributor

@brcrista brcrista May 8, 2020

Choose a reason for hiding this comment

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

More generally, "the user starting the runner must have write permission to the /opt directory." This can be accomplished in different ways:

  • Runner user is the owner, and owner has write permission
  • Runner user is in the owning group, and owning group has write permission
  • All users have write permission

Copy link
Contributor

@brcrista brcrista May 8, 2020

Choose a reason for hiding this comment

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

Also, I'm not sure what the implications are for configuring the runner as a service. I know Windows services have a different set of users instead of running as the logged-on user (by definition, this is what makes them services).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So on Linux and Mac we should be fine. Doing sudo ./svc.sh install shows the user the service will run on (at least for me it's showing the same thing, konradpabjan): https://help.github.com/en/actions/hosting-your-own-runners/configuring-the-self-hosted-runner-application-as-a-service

On Windows, you need to be running as admin to configure the runner as a service:
image

Even when running as admin, it asks for the user account that you would like the service to run as, I'll add a note to make sure users watch out for this:
image

README.md Outdated Show resolved Hide resolved
README.md Outdated

- The Python packages that are downloaded from `actions/python-versions` are originally compiled from source in `/opt/hostedtoolcache/` with the [--enable-shared](https://github.com/actions/python-versions/blob/94f04ae6806c6633c82db94c6406a16e17decd5c/builders/ubuntu-python-builder.psm1#L35) flag which makes them non portable.
- Create an environment variable called `AGENT_TOOLSDIRECTORY` and set it to `/opt/hostedtoolcache`. This is used to control where Python gets set up and installed.
- In the same shell that your runner is using, type `AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache`
Copy link
Contributor

Choose a reason for hiding this comment

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

don't they have to export?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If it's in the same shell I had the runner pick it up without export. Regardless, I added export to the example

konradpabjan and others added 2 commits May 11, 2020 09:50
Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@brcrista brcrista left a comment

Choose a reason for hiding this comment

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

Looks good! Left a few more small comments.

Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>
@konradpabjan konradpabjan merged commit ee653cd into master May 11, 2020
@konradpabjan konradpabjan deleted the konradpabjan/self-hosted-linux-mac branch May 11, 2020 13:15
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.

2 participants