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

enhance(yaml)!: allow for users to parse pipelines using old library #1220

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ecrupper
Copy link
Contributor

@ecrupper ecrupper commented Nov 5, 2024

Background

It is imperative that the platform moves away from the buildkite YAML library, as it is archived.

This has been attempted and reverted a couple times:

(2024, go-yaml v3) go-vela/types#386 —> go-vela/types#392

(2020, goccy) go-vela/types#118 —> go-vela/types#144

This PR ensures that we will not have to revert this important change, as it will allow for users to immediately set

version: "legacy"

At the top level of their pipeline file (or template file) if they are encountering unexpected YAML issues.

This will also allow for troubleshooting / triaging for the Vela admins to cover all of our bases when shifting to this new library while having low impact.

The goal is to revert this change in a later release so that the entire platform uses only one YAML parser throughout the code base.

However, one of the most common patterns that will now produce errors is the use of multiple <<: in a single YAML map. This pattern will compile correctly with this change but produce warnings. These warnings will be attached to the pipeline object and will be rendered in the UI.

What's in the PR

  • new packages compiler/types/yaml/yaml and compiler/types/yaml/buildkite in place of the single compiler/types/yaml
  • all the buildkite YAML types have a ToYAML() method that will convert to the go-yaml version. Once the pipelines have been unmarshaled, these two objects should be identical sans their type.
  • an internal/yaml.go file that grabs the version from the pipeline file and verifies the library we should use.
  • a new warnings field in the pipelines table to track warnings.

@ecrupper ecrupper marked this pull request as ready for review November 5, 2024 22:05
@ecrupper ecrupper requested a review from a team as a code owner November 5, 2024 22:05
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 73.10726% with 341 lines in your changes missing coverage. Please review.

Project coverage is 57.50%. Comparing base (aa973fe) to head (ef30880).

Files with missing lines Patch % Lines
compiler/types/yaml/buildkite/secret.go 72.72% 49 Missing and 2 partials ⚠️
compiler/types/yaml/buildkite/template.go 43.75% 36 Missing ⚠️
compiler/types/yaml/buildkite/step.go 65.68% 34 Missing and 1 partial ⚠️
compiler/types/yaml/buildkite/service.go 65.90% 28 Missing and 2 partials ⚠️
compiler/types/yaml/buildkite/ruleset.go 81.81% 28 Missing ⚠️
compiler/template/starlark/render.go 38.46% 24 Missing ⚠️
compiler/types/yaml/buildkite/stage.go 19.23% 21 Missing ⚠️
compiler/types/yaml/buildkite/metadata.go 66.10% 20 Missing ⚠️
internal/yaml.go 81.48% 15 Missing and 5 partials ⚠️
compiler/types/yaml/buildkite/ulimit.go 80.61% 19 Missing ⚠️
... and 9 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1220      +/-   ##
==========================================
+ Coverage   56.91%   57.50%   +0.58%     
==========================================
  Files         599      611      +12     
  Lines       32904    34085    +1181     
==========================================
+ Hits        18727    19600     +873     
- Misses      13541    13835     +294     
- Partials      636      650      +14     
Files with missing lines Coverage Δ
api/types/pipeline.go 100.00% <100.00%> (ø)
api/types/string.go 80.64% <ø> (ø)
compiler/native/clone.go 100.00% <ø> (ø)
compiler/native/compile.go 71.29% <100.00%> (+0.13%) ⬆️
compiler/native/environment.go 86.75% <ø> (ø)
compiler/native/initialize.go 100.00% <ø> (ø)
compiler/native/script.go 95.23% <ø> (ø)
compiler/native/substitute.go 70.00% <ø> (ø)
compiler/native/transform.go 95.34% <ø> (ø)
compiler/native/validate.go 96.93% <ø> (ø)
... and 33 more

@plyr4 plyr4 force-pushed the enhance/yaml-parser-flag branch from 3fe3d3b to 23205cd Compare November 8, 2024 20:57
@ecrupper ecrupper changed the title enhance(yaml): allow for users to parse pipelines using old library enhance(yaml)!: allow for users to parse pipelines using old library Dec 3, 2024
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