Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,6 @@ jobs:
# Check the `calculate_matrix` job to see how is the matrix defined.
include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}
steps:
- name: Install cargo in AWS CodeBuild
if: matrix.codebuild
run: |
# Check if cargo is installed
if ! command -v cargo &> /dev/null; then
echo "Cargo not found, installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
# Make cargo available in PATH
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
fi
- name: disable git crlf conversion
run: git config --global core.autocrlf false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Those images are pushed to ghcr.io by this job.
#
# While Docker Hub rate limit *shouldn't* be an issue on GitHub Actions,
# it certainly is for AWS codebuild.
# it may be for external self-hosted runners (e.g., EC2 runners).
#
# Note that authenticating to DockerHub or other registries isn't possible
# for PR jobs, because forks can't access secrets.
Expand Down
11 changes: 2 additions & 9 deletions src/ci/citool/src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ pub struct Job {
pub free_disk: Option<bool>,
/// Documentation link to a resource that could help people debug this CI job.
pub doc_url: Option<String>,
/// Whether the job is executed on AWS CodeBuild.
pub codebuild: Option<bool>,
/// Which Python version (if any) is required. On Windows, this is typically required to run
/// LLDB.
#[serde(default)]
Expand Down Expand Up @@ -170,7 +168,6 @@ fn validate_job_database(db: &JobDatabase) -> anyhow::Result<()> {
only_on_channel,
free_disk,
doc_url,
codebuild,
required_python_version,

// Carve-out configs allowed to be different.
Expand All @@ -183,7 +180,6 @@ fn validate_job_database(db: &JobDatabase) -> anyhow::Result<()> {
&& *only_on_channel == auto_job.only_on_channel
&& *free_disk == auto_job.free_disk
&& *doc_url == auto_job.doc_url
&& *codebuild == auto_job.codebuild
&& *required_python_version == auto_job.required_python_version
{
Ok(())
Expand Down Expand Up @@ -249,14 +245,12 @@ struct GithubActionsJob {
#[serde(skip_serializing_if = "Option::is_none")]
doc_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
codebuild: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
required_python_version: Option<String>,
}

/// Replace GitHub context variables with environment variables in job configs.
/// Used for codebuild jobs like
/// `codebuild-ubuntu-22-8c-$github.run_id-$github.run_attempt`
///
/// This is used for self-hosted runner jobs to loosely tie an instance to a particular GHA job.
fn substitute_github_vars(jobs: Vec<Job>) -> anyhow::Result<Vec<Job>> {
let run_id = load_env_var("GITHUB_RUN_ID")?;
let run_attempt = load_env_var("GITHUB_RUN_ATTEMPT")?;
Expand Down Expand Up @@ -382,7 +376,6 @@ fn calculate_jobs(
continue_on_error: job.continue_on_error,
free_disk: job.free_disk,
doc_url: job.doc_url,
codebuild: job.codebuild,
required_python_version: job.required_python_version,
}
})
Expand Down
67 changes: 0 additions & 67 deletions src/ci/citool/src/jobs/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,73 +81,6 @@ fn check_pattern(db: &JobDatabase, pattern: &str, expected: &[&str]) {
assert_eq!(jobs, expected);
}

/// Validate that CodeBuild jobs use Docker images from ghcr.io registry.
/// This is needed because otherwise from CodeBuild we get rate limited by Docker Hub.
fn validate_codebuild_image(job: &Job) -> anyhow::Result<()> {
let is_job_on_codebuild = job.codebuild.unwrap_or(false);
if !is_job_on_codebuild {
// Jobs in GitHub Actions don't get rate limited by Docker Hub.
return Ok(());
}

let image_name = job.image();
// we hardcode host-x86_64 here, because in codebuild we only run jobs for this architecture.
let dockerfile_path =
Path::new(DOCKER_DIRECTORY).join("host-x86_64").join(&image_name).join("Dockerfile");

if !dockerfile_path.exists() {
return Err(anyhow::anyhow!(
"Dockerfile not found for CodeBuild job '{}' at path: {}",
job.name,
dockerfile_path.display()
));
}

let dockerfile_content = utils::read_to_string(&dockerfile_path)?;

// Check if all FROM statement uses ghcr.io registry
let has_ghcr_from = dockerfile_content
.lines()
.filter(|line| line.trim_start().to_lowercase().starts_with("from "))
.all(|line| line.contains("ghcr.io"));

if !has_ghcr_from {
return Err(anyhow::anyhow!(
"CodeBuild job '{}' must use ghcr.io registry in its Dockerfile FROM statement. \
Dockerfile path: {dockerfile_path:?}",
job.name,
));
}

Ok(())
}

#[test]
fn validate_jobs() {
let db = {
let default_jobs_file = Path::new(JOBS_YML_PATH);
let db_str = utils::read_to_string(default_jobs_file).unwrap();
load_job_db(&db_str).expect("Failed to load job database")
};

let all_jobs = db
.pr_jobs
.iter()
.chain(db.try_jobs.iter())
.chain(db.auto_jobs.iter())
.chain(db.optional_jobs.iter())
.collect::<Vec<_>>();

let errors: Vec<anyhow::Error> =
all_jobs.into_iter().filter_map(|job| validate_codebuild_image(job).err()).collect();

if !errors.is_empty() {
let error_messages =
errors.into_iter().map(|e| format!("- {e}")).collect::<Vec<_>>().join("\n");
panic!("Job validation failed:\n{error_messages}");
}
}

#[test]
fn pr_job_implies_auto_job() {
let db = load_job_db(
Expand Down
2 changes: 1 addition & 1 deletion src/ci/scripts/free-disk-space-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ isX86() {
}

# Check if we're on a GitHub hosted runner.
# In aws codebuild, the variable RUNNER_ENVIRONMENT is "self-hosted".
# In self hosted runners, the variable RUNNER_ENVIRONMENT is "self-hosted".
isGitHubRunner() {
# `:-` means "use the value of RUNNER_ENVIRONMENT if it exists, otherwise use an empty string".
if [[ "${RUNNER_ENVIRONMENT:-}" == "github-hosted" ]]; then
Expand Down
Loading