mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-29 10:54:24 +00:00
Add self-hosted runners v2 (#4506)
## 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 <anton@delaruelle.net>
This commit is contained in:
@@ -22,6 +22,7 @@ use watch::{
|
||||
};
|
||||
|
||||
use log::error;
|
||||
use std::env;
|
||||
use std::net::SocketAddr;
|
||||
use std::time::Duration;
|
||||
use tokio::{runtime, task::JoinHandle};
|
||||
@@ -36,6 +37,11 @@ const VALIDATOR_COUNT: usize = 32;
|
||||
const SLOTS_PER_EPOCH: u64 = 32;
|
||||
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
|
||||
/// Set this environment variable to use a different hostname for connecting to
|
||||
/// the database. Can be set to `host.docker.internal` for docker-in-docker
|
||||
/// setups.
|
||||
const WATCH_HOST_ENV_VARIABLE: &str = "WATCH_HOST";
|
||||
|
||||
fn build_test_config(config: &DatabaseConfig) -> PostgresConfig {
|
||||
let mut postgres_config = PostgresConfig::new();
|
||||
postgres_config
|
||||
@@ -71,6 +77,10 @@ pub async fn create_test_database(config: &DatabaseConfig) {
|
||||
.expect("Database creation failed");
|
||||
}
|
||||
|
||||
pub fn get_host_from_env() -> String {
|
||||
env::var(WATCH_HOST_ENV_VARIABLE).unwrap_or_else(|_| "localhost".to_string())
|
||||
}
|
||||
|
||||
struct TesterBuilder {
|
||||
pub harness: BeaconChainHarness<EphemeralHarnessType<E>>,
|
||||
pub config: Config,
|
||||
@@ -107,6 +117,7 @@ impl TesterBuilder {
|
||||
database: DatabaseConfig {
|
||||
dbname: random_dbname(),
|
||||
port: database_port,
|
||||
host: get_host_from_env(),
|
||||
..Default::default()
|
||||
},
|
||||
server: ServerConfig {
|
||||
|
||||
Reference in New Issue
Block a user