Skip to content

Conversation

@hnez
Copy link
Member

@hnez hnez commented May 21, 2025

This PR allows using:

jobs:
  build:
    runs-on: self-hosted/forrest/build

Instead of:

jobs:
  build:
    runs-on: ["self-hosted", "forrest", "build"]

Or, more importantly:

jobs:
  build:
    runs-on: ${{ github.repository == 'rauc/meta-rauc' && 'self-hosted/forrest/build' || 'ubuntu-22.04' }}

Instead of:

jobs:
  build:
    runs-on: >-
      ${{
        (github.repository == 'rauc/meta-rauc' && fromJSON('["self-hosted", "forrest", "build"]')) ||
        'ubuntu-22.04'
      }}

This is a early draft, lacking polish, splitting into commits and commit messages.

hnez added 5 commits June 27, 2025 13:24
This makes it easier to tell which information from the Machine struct
`RunDir::new()` actually uses.
A triplet, in forrest speek, is the combination of a username, repository
and machine type.
This is about to change, because another kind of triplet will be added,
containing username, repository and labels.

Rename the module to indicate that it contains different kinds of
triplets. The old and now name are still not good though, because it is
very non-descriptive and because the file also contains e.g. the
OwnerAndRepo struct, which only has two components.

Leave proper naming to future us.
This is more descriptive of what it actually contains, and it prepares us
for the addition of a `OwnerRepoLabels` struct in the next step.
This is only slightly different from the `OwnerRepoMachine` struct.
It does not care if the contained Labels actually correspond to what we
expect in forrest (e.g. `runs-on: [self-hosted, forrest, machine-name]`)
and just preserves them as-is.

Why add this struct if `Triplet`/`OwnerRepoMachines` worked fine until
now?

We have to register runners with exactly the same set of labels as those
specified by the job and given to us via the API or webhooks, otherwise
the job will not be assigned to the runer.

This is much easier if we do not have to reproduce the labels from the
machine name and will allow us to accept the labels in different formats
in the future.
This allows using the following format in a workflow file:

    jobs:
      build:
        runs-on: self-hosted/forrest/build

In addition to the previous format:

    jobs:
      build:
        runs-on: ["self-hosted", "forrest", "build"]

In this simple example the more compact nature of this format does not
benefit us too much, but it becomes more relevant when `runs-on` is the
result of some computation:

    jobs:
      build:
        runs-on: ${{ github.repository == 'forrest-runner/forrest' && 'self-hosted/forrest/build' || 'ubuntu-22.04' }}

versus:

    jobs:
      build:
        runs-on: >-
          ${{
            (github.repository == 'forrest-runner/forrest' && fromJSON('["self-hosted", "forrest", "build"]')) ||
            'ubuntu-22.04'
          }}
@hnez hnez force-pushed the compact-runs-on branch from 46c94bf to 386ecf6 Compare June 27, 2025 11:39
Comment on lines -214 to +222
if let Some(triplet) = oar.into_triplet_via_labels(&workflow_job.labels) {
self.job_manager.status_feedback(
&triplet,
workflow_job.id,
workflow_job.run_id,
workflow_job.status,
workflow_job.runner_name.as_deref(),
);
}
let orl = oar.into_orl(workflow_job.labels);

self.job_manager.status_feedback(
&orl,
workflow_job.id,
workflow_job.run_id,
workflow_job.status,
workflow_job.runner_name.as_deref(),
);
Copy link
Member Author

Choose a reason for hiding this comment

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

This removes the "does this job name look like we should handle it?" test e.g. is it runs-on: [self-hosted, forrest, machine] instead of e.g. runs-on: ubuntu-latest.
The jobs will still be discarded later on (like jobs that have a machine type the is not available in the config file), but I think we should have a basic early check nevertheless.

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.

1 participant