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

[Merged by Bors] - Add self-hosted runners v2 #4506

Closed
wants to merge 37 commits into from

Conversation

paulhauner
Copy link
Member

@paulhauner paulhauner commented Jul 14, 2023

Issue Addressed

NA

Proposed Changes

Carries on from #4115, with the following modifications:

  1. Self-hosted runners are only enabled if github.repository == sigp/lighthouse.
    • This allows forks to still have Github-hosted CI.
    • This gives us a method to switch back to Github-runners if we have extended downtime on self-hosted.
  2. Does not remove any existing dependency builds for Github-hosted runners (e.g., installing the latest Rust).
  3. Adds the WATCH_HOST environment variable which defines where we expect to find the postgres db in the watch tests. This should be set to host.docker.internal for the tests to pass on self-hosted runners.

Additional Info

NA

@paulhauner paulhauner changed the base branch from stable to unstable July 14, 2023 02:50
@paulhauner
Copy link
Member Author

A list of things that are different between Github-runners and our self-hosted runners for future reference:

  1. Self-hosted runners don't have sudo.
  2. Self-hosted runners fail rustup update with error: could not rename component file from '/opt/rust/toolchains/stable-x86_64-unknown-linux-gnu/etc/bash_completion.d' to '/opt/rust/tmp/bsq3a_35gvhrh01r_dir/bk': Invalid cross-device link (os error 18) (failed CI run)

@paulhauner
Copy link
Member Author

We're now using github.repository == 'sigp/lighthouse' to enable/disable self-hosted runners. I originally wanted to use a repository variable for this purpose, however they "... are not passed to workflows that are triggered by a pull request from a fork.". This means that a PR from paulhauner/lighthouse to sigp/lighthouse wouldn't use self-hosted runners.

I would have liked to set an env variable at the top of the play that could have been used to de-duplicate some of the runs_on values. But alas, using env variables in runs_on is not supported (relevant issue actions/runner#480).

@antondlr
Copy link
Member

if these additions differ from the GitHub-hosted runners (i.e., install 7zip), I'll add them to the runner image.
ideally, we keep the self-hosted and GitHub-hosted runners hot-swappable.

I'll document where and how to update the images Real Soon™️, too.

Comment on lines 67 to 71
- name: Install apt dependencies
if: env.SELF_HOSTED_RUNNERS
run: |
sudo apt-get update
sudo apt-get install libpq-dev # Required for Postgres in ./watch.
Copy link
Member

Choose a reason for hiding this comment

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

we could probably remove this once this is baked into the self hosted runner image

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed!

@paulhauner paulhauner added the ready-for-review The code is ready for review label Jul 21, 2023
@paulhauner
Copy link
Member Author

This is ready for review! 🎉

@@ -61,14 +65,15 @@ jobs:
- name: Install Foundry (anvil)
uses: foundry-rs/foundry-toolchain@v1
- name: Run tests in release
run: make test-release
run: WATCH_HOST=host.docker.internal make test-release
Copy link
Member

Choose a reason for hiding this comment

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

I think this may not work on GitHub hosted runners if they're not running in docker containers, perhaps we can leave it empty if env.SELF_HOSTED_RUNNERS == false so it defaults to localhost?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call, I had a shot at fixing this in ce4ed6e.

@@ -143,7 +153,7 @@ jobs:
- name: Install Foundry (anvil)
uses: foundry-rs/foundry-toolchain@v1
- name: Run tests in debug
run: make test-debug
run: WATCH_HOST=host.docker.internal make test-debug
Copy link
Member

Choose a reason for hiding this comment

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

same as above

@@ -83,6 +88,7 @@ jobs:
- name: Install make
run: choco install -y make
- uses: KyleMayes/install-llvm-action@v1
if: env.SELF_HOSTED_RUNNERS == false
Copy link
Member

Choose a reason for hiding this comment

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

I think we're good with this but just something worth thinking - Is there any benefit of leaving these conditionals out?

There are a few benefits:

  • CI be always the same dep versions on self-hosted / github-hosted runners
  • For Rust, the workflow will automatically update to latest version as soon as it's released, it could take an extra 15s or more to install. But then we'll know we need to update our runner image.

Downside:

  • it could be a bit slower, but AFAIK rustup update stable just returns immediately if we're already on the same version.

Copy link
Member Author

Choose a reason for hiding this comment

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

IIRC the self-hosted runners fail if we run that llvm install action.

Copy link
Member Author

Choose a reason for hiding this comment

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

Same with the Rust update ones.

Copy link
Member

Choose a reason for hiding this comment

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

ahh privileges! happy to leave it as it is 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

IMO it would be ideal if we can have the images perform exactly the same. Perhaps we can make an issue to come back for it.

I suspect that we're going to eventually drift into the territory of Github-hosted runners failing, though. If we're not actually testing on the Github-hosted ones they're bound to bit-rot.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that's a good point - I'm hesitant to make the workflow more complicated, but if we really want to run GitHub-hosted runners, we could still run them on PRs, and use the self-hosted ones on staging 😛 , but perhaps something to think about later down the line.

Copy link
Member

@jimmygchen jimmygchen left a comment

Choose a reason for hiding this comment

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

LGTM! Woot, excited to have this merged 🔥 🚀 🎉 ⏩ ⏩ ⏩

@paulhauner
Copy link
Member Author

I'll merge this when CI passes 🎉

@jimmygchen jimmygchen added infra-ci ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Jul 21, 2023
@paulhauner
Copy link
Member Author

Yay, CI passed 🎉

bors r+

bors bot pushed a commit that referenced this pull request Jul 21, 2023
## Issue Addressed

NA

## Proposed Changes

Carries on from #4115, with the following modifications:

1. Self-hosted runners are only enabled if `github.repository == sigp/lighthouse`.
    - This allows forks to still have Github-hosted CI.
    - This gives us a method to switch back to Github-runners if we have extended downtime on self-hosted. 
1. Does not remove any existing dependency builds for Github-hosted runners (e.g., installing the latest Rust).
1. Adds the `WATCH_HOST` environment variable which defines where we expect to find the postgres db in the `watch` tests. This should be set to `host.docker.internal` for the tests to pass on self-hosted runners.

## Additional Info

NA


Co-authored-by: antondlr <[email protected]>
@bors
Copy link

bors bot commented Jul 21, 2023

Pull request successfully merged into unstable.

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title Add self-hosted runners v2 [Merged by Bors] - Add self-hosted runners v2 Jul 21, 2023
@bors bors bot closed this Jul 21, 2023
Woodpile37 pushed a commit to Woodpile37/lighthouse that referenced this pull request Jan 6, 2024
## Issue Addressed

NA

## Proposed Changes

Carries on from sigp#4115, with the following modifications:

1. Self-hosted runners are only enabled if `github.repository == sigp/lighthouse`.
    - This allows forks to still have Github-hosted CI.
    - This gives us a method to switch back to Github-runners if we have extended downtime on self-hosted. 
1. Does not remove any existing dependency builds for Github-hosted runners (e.g., installing the latest Rust).
1. Adds the `WATCH_HOST` environment variable which defines where we expect to find the postgres db in the `watch` tests. This should be set to `host.docker.internal` for the tests to pass on self-hosted runners.

## Additional Info

NA


Co-authored-by: antondlr <[email protected]>
Woodpile37 pushed a commit to Woodpile37/lighthouse that referenced this pull request Jan 6, 2024
## Issue Addressed

NA

## Proposed Changes

Carries on from sigp#4115, with the following modifications:

1. Self-hosted runners are only enabled if `github.repository == sigp/lighthouse`.
    - This allows forks to still have Github-hosted CI.
    - This gives us a method to switch back to Github-runners if we have extended downtime on self-hosted. 
1. Does not remove any existing dependency builds for Github-hosted runners (e.g., installing the latest Rust).
1. Adds the `WATCH_HOST` environment variable which defines where we expect to find the postgres db in the `watch` tests. This should be set to `host.docker.internal` for the tests to pass on self-hosted runners.

## Additional Info

NA


Co-authored-by: antondlr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infra-ci ready-for-merge This PR is ready to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants