machines: enable the use of a more compact labels format#25
Draft
hnez wants to merge 5 commits intoforrest-runner:mainfrom
Draft
machines: enable the use of a more compact labels format#25hnez wants to merge 5 commits intoforrest-runner:mainfrom
hnez wants to merge 5 commits intoforrest-runner:mainfrom
Conversation
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
commented
Jun 30, 2025
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(), | ||
| ); |
Member
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR allows using:
Instead of:
Or, more importantly:
Instead of:
This is a early draft, lacking polish, splitting into commits and commit messages.