Skip to content

chore: test all our yaml against CRDs#15009

Merged
Joibel merged 1 commit intomainfrom
crd-test
Nov 11, 2025
Merged

chore: test all our yaml against CRDs#15009
Joibel merged 1 commit intomainfrom
crd-test

Conversation

@Joibel
Copy link
Copy Markdown
Member

@Joibel Joibel commented Nov 7, 2025

To complement #15003

The examples validation test didn't catch everything this one did, and doesn't test test/e2e but is someways overlapping. Neither take long to run.

Motivation

We have quite a lot of example YAML files - so lets prove that our full CRDs don't violate them.

Will be followed by an update to the CRDs to add some CEL validation (kubebuilder rules) for validation rules that can easily happen at that level.

Modifications

Add pkg/apis/workflow/v1alpha1/crd_examples_test.go which runs through all /examples YAML files and most of them in test/e2e (ignoring some which are marked as invalid). This file already does CEL validation tests, but doesn't introduce CEL rules.

It performs strict validation.

What did this discover and get fixed here:

  • ConfigMapKeySelector for memoization Cache is just the name of the ConfigMap, the key is in the parent object so we only want this to be the LocalObjectReference to find the ConfigMap. There are no other code changes around this, which validates this is the correct fix.
  • ArtifactPlugins did have required name and configuration. Configuration is "obviously" optional. Name is also optional in the case where we're just specifying a key and using a pre-configured artifact repository. Made both omitempty to make them optional.
  • We are now stricter with a number of things, which will make upgrading painful for people who've not been as strict as we wanted:
    • String fields won't accept [] and plain numbers without quotes. e.g. []->"[]" and 9->"9"
    • Empty lists and maps are not acceptable e.g. labels: -> labels: {}
  • test/e2e/testdata/artifact-workflow-azure.yaml is not tested in e2e any more, so I deleted it. It fails to validate because the azure blocks don't have non-optional fields.
  • Slightly icky: test/e2e/testdata/data-transformation.yaml has the name added. The right fix would be to make artifactPaths (which is weirdly plural when the content is singular) only contain artifactLocation (+maybe some other fields) as Name isn't important here. I tried fixing this and it got out of hand, and this is rarely used I believe, so left it for another time.

Verification

This is a new test.

Documentation

None here.

Signed-off-by: Alan Clucas <alan@clucas.org>
@Joibel Joibel force-pushed the crd-test branch 2 times, most recently from 73ed4d2 to e9c207a Compare November 10, 2025 08:43
@Joibel Joibel marked this pull request as ready for review November 10, 2025 15:42
@Joibel Joibel requested a review from Copilot November 10, 2025 16:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR makes breaking changes to the Argo Workflows API to improve flexibility and correctness:

  • Makes PluginArtifact fields name and configuration optional instead of required
  • Changes Cache.ConfigMap from ConfigMapKeySelector to LocalObjectReference (removing the unused key field)
  • Adds +kubebuilder:pruning:PreserveUnknownFields directive to Plugin type to allow arbitrary plugin configurations
  • Adds comprehensive CRD validation tests for all example and test YAML files
  • Updates test data and examples to comply with the new schemas

Reviewed Changes

Copilot reviewed 47 out of 49 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/apis/workflow/v1alpha1/workflow_types.go Made PluginArtifact.Name and Configuration optional; changed Cache.ConfigMap to LocalObjectReference
pkg/apis/workflow/v1alpha1/plugin_types.go Added PreserveUnknownFields directive to Plugin type
pkg/apis/workflow/v1alpha1/crd_examples_test.go New comprehensive test to validate all examples against CRD schemas
test/e2e/testdata/*.yaml Fixed test files to comply with updated schemas (added required fields, converted integer params to strings)
examples/*.yaml Updated examples to remove unused ConfigMap key field and fix parameter types
manifests/base/crds/ Regenerated CRD manifests reflecting API changes
sdks/ Regenerated SDK documentation and code for Python and Java clients
go.mod, go.sum Added dependencies for CRD validation (apiextensions-apiserver, cel-go, etc.)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Joibel Joibel merged commit b20c264 into main Nov 11, 2025
78 of 81 checks passed
@Joibel Joibel deleted the crd-test branch November 11, 2025 08:17
guanguxiansheng pushed a commit to guanguxiansheng/argo-workflows that referenced this pull request Dec 15, 2025
Signed-off-by: Alan Clucas <alan@clucas.org>
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.

3 participants