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

.github: refactor job matrix generation into YAML files #26019

Merged
merged 1 commit into from
Jun 9, 2023

Conversation

aanm
Copy link
Member

@aanm aanm commented Jun 8, 2023

This commit addresses two main issues and introduces a more streamlined approach to generating job matrices for GitHub Actions. By migrating the job matrix definition into YAML files, we gain the ability to separate scheduled jobs and pull requests (PRs) into specific files, ensuring comprehensive testing coverage similar to what we have with Jenkins.

The first benefit of this approach is the improved organization of job definitions. With separate files for scheduled jobs and PRs, it becomes easier to manage and maintain testing configurations independently. This modular structure allows us to make changes to specific job types without impacting others, enhancing overall maintainability.

The second advantage is with help of jq, we can define kernel versions for all desired Kubernetes (k8s) versions to be tested without manually commenting out unwanted versions. Previously, when using the "include" mechanism, certain k8s versions like 1.24 had to be commented out to prevent their execution. However, with jq, we can selectively include only the desired k8s versions by mapping them with the definitions in main-prs.yaml or main-scheduled.yaml.

Lastly, this refactor enables per-branch configuration through prefixed filenames. By structuring configuration files with branch-specific prefixes, we can easily define and manage job configurations tailored to stable branches.

This commit addresses two main issues and introduces a more streamlined
approach to generating job matrices for GitHub Actions. By migrating the job
matrix definition into YAML files, we gain the ability to separate scheduled
jobs and pull requests (PRs) into specific files, ensuring comprehensive
testing coverage similar to what we have with Jenkins.

The first benefit of this approach is the improved organization of job
definitions. With separate files for scheduled jobs and PRs, it becomes easier
to manage and maintain testing configurations independently. This modular
structure allows us to make changes to specific job types without impacting
others, enhancing overall maintainability.

The second advantage is with help of jq, we can define kernel versions for
all desired Kubernetes (k8s) versions to be tested without manually commenting
out unwanted versions. Previously, when using the "include" mechanism, certain
k8s versions like 1.24 had to be commented out to prevent their execution.
However, with jq, we can selectively include only the desired k8s versions by
mapping them with the definitions in main-prs.yaml or main-scheduled.yaml.

Lastly, this refactor enables per-branch configuration through prefixed
filenames. By structuring configuration files with branch-specific prefixes, we
can easily define and manage job configurations tailored to stable branches.

Signed-off-by: André Martins <andre@cilium.io>
@aanm aanm requested review from a team as code owners June 8, 2023 08:38
@aanm aanm requested review from brlbil and nebril June 8, 2023 08:38
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jun 8, 2023
@aanm aanm added area/CI Continuous Integration testing issue or flake area/CI-improvement Topic or proposal to improve the Continuous Integration workflow release-note/misc This PR makes changes that have no direct user impact. labels Jun 8, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jun 8, 2023
ref: ${{ needs.check_changes.outputs.matrix_sha }}
persist-credentials: false

- name: Convert YAML to JSON
Copy link
Member

Choose a reason for hiding this comment

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

Is this done because we need jq-specific features that yq is lacking?

Copy link
Member Author

Choose a reason for hiding this comment

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

@nebril no, it's because of the there isn't a fromYaml function, similar to the fromJson on GitHub as documented https://docs.github.com/en/enterprise-cloud@latest/actions/learn-github-actions/expressions#fromjson

Copy link
Member

@nebril nebril left a comment

Choose a reason for hiding this comment

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

This is awesome! I think one thing missing would be adding some kind of yaml schema for new branch-*.yaml files, that would validate their structure. I think that debugging errors made in these files would be pretty painful, so it might make sense to make these as obvious as possible.

I don't think it's blocking though, it could be tracked in a new issue.

@aanm aanm merged commit 17c3eff into cilium:main Jun 9, 2023
47 of 48 checks passed
@aanm aanm deleted the pr/use-yaml-matrix branch June 9, 2023 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/CI Continuous Integration testing issue or flake area/CI-improvement Topic or proposal to improve the Continuous Integration workflow release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants