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

[TEP-0100] Prepare for testing of minimal status implementation #4734

Merged
merged 1 commit into from
Apr 6, 2022

Conversation

abayer
Copy link
Contributor

@abayer abayer commented Apr 4, 2022

Changes

This change is to minimize the size of the actual implementation. We need to change a number of
tests in pkg/reconciler/pipelinerun/pipelinerun_test.go to be table-based, so that we can test
behavior under each possible value for the new embedded-status feature flag. Here, we just
modify the relevant tests to be table-based and use a parameterized helper function for the actual
execution, with a test case for each value.

It also adds helper functions for checking the relevant fields in the PipelineRun status, which
are hard-coded to always handle the current, "full" embedded status approach.

This also splits out TestUpdatePipelineRunStatusFromTaskRuns and TestUpdatePipelineRunStatusFromRuns
into a separate file, pipelinerun_updatestatus_test.go. When the TEP-0100 implementation lands,
this will also contain additional tests for updating via child references. Splitting like this helps
keep pipelinerun_test.go from getting even more bloated than it is currently.

Until the implementation, these table-based tests are purely duplicative - they're going to run the
same and check the same things for any value of embedded-status, but the implementation PR will be
cleaner, only adding the implementation and changing the helper functions to take all of the
possible "embedded-status" values into account. The changes which need to be made in the
implementation PR are all marked with // TODO(abayer): ... in pipelinerun_test.go and
pipelinerun_updatestatus_test.go.

/kind tep

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in
    (if there are no user facing changes, use release note "NONE")

Release Notes

NONE

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. kind/tep Categorizes issue or PR as related to a TEP (or needs a TEP). labels Apr 4, 2022
@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 4, 2022
@abayer
Copy link
Contributor Author

abayer commented Apr 4, 2022

/assign @lbernick

Copy link
Member

@lbernick lbernick left a comment

Choose a reason for hiding this comment

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

Thanks Andrew! I'm still wondering if a pattern like the following could work?

func verifyPipelineRunStatus(t *testing.T, embeddedStatus string, prs *PipelineRunStatus, expectedChildStatuses map[string]ChildStatusReference) {
 //pseudocode
 taskRunStatuses := filter(expectedChildStatuses, status.value.kind == "TaskRun")
 runStatuses := filter(expectedChildStatuses, status.value.kind == "Run")
 if embeddedStatus == "full" {
   // verify all taskRuns in pipelineRunStatus have status, conditions, and when expressions matching those in taskRunStatuses, and likewise for runs
   // verify that childRefs has no entries
 }
 // do something similar for both/minimal
}

@@ -238,6 +238,36 @@ func getPipelineRunUpdates(t *testing.T, actions []ktesting.Action) []*v1beta1.P
}

func TestReconcile(t *testing.T) {
testCases := []struct {
Copy link
Member

Choose a reason for hiding this comment

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

I see a lot of tests with these same test cases. They could probably be combined into one, e.g.

testSuites := []func(*testing.T){testReconcileWithEmbeddedStatus, testReconcileWithCustomTask...}
for _, testCase := range testCases {
   for _, testClass := range testSuites {
      t.Run(tc.Name, testClass(t, tc.embeddedStatus))
   }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. I’d lean against this for clarity and ease of running individual test cases in an IDE.

Copy link
Member

Choose a reason for hiding this comment

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

at the very least maybe the test cases struct can be defined only once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered that, but at least in Goland/IntelliJ, if you don't have the test case structs defined in the test function, you can't launch them individually.

// with one Custom Task reference that has not been run yet, and each possible
// value for the "embedded-status" feature flag. It verifies that the Run is
// created, it checks the resulting API actions, status and events.
func TestReconcile_CustomTaskWithEmbeddedStatus(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

can this follow the same pattern as Test_Reconcile above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean the separate function thingie? I didn’t bother splitting this one because it’s entirely new, so the diff would have been just as large either way. I guess there is value in consistency, though!

Copy link
Member

Choose a reason for hiding this comment

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

yeah I think absent a strong reason to prefer either approach, let's keep things consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

}

func verifyTaskRunStatusesCount(t *testing.T, embeddedStatus string, prStatus v1beta1.PipelineRunStatus, taskCount int) {
if shouldHaveFullEmbeddedStatus(embeddedStatus) && len(prStatus.TaskRuns) != taskCount {
Copy link
Member

Choose a reason for hiding this comment

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

rather than creating these functions "shouldhavefullembeddedstatus" etc I think it might be cleaner to not have these branches at all, and just add them when the embedded status functionality is enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’m not sure what you mean? The point of this PR is to cut down on the size of the implementation PR, so if we don’t add the new test behavior for the embedded status functionality here, we have to do it in the implementation PR instead.

Copy link
Member

Choose a reason for hiding this comment

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

ok-- whatever you think is best here, although my intention isn't specifically to reduce number of lines of code but number of "things" that a given PR is doing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough. =) I guess I just feel like stubbing shouldHaveFullEmbeddedStatus and shouldHaveMinimalEmbeddedStatus here with the TODOs, and full implementations of verify... is clearer on the intent, particularly since there (hopefully!) will not be a long gap between this PR landing and the implementation PR landing.

@abayer
Copy link
Contributor Author

abayer commented Apr 5, 2022

@lbernick Re that pattern - I feel like that would end up bloating the tests more than it would shrink them, since we’d have to define the full expected statuses for each case, while the existing tests don’t actually check the full statuses currently, just certain aspects. But I’ll give it another shot and see if a smooth enough approach reveals itself.

// return embeddedVal == config.MinimalEmbeddedStatus || embeddedVal == config.BothEmbeddedStatus
}

func verifyTaskRunStatusesCount(t *testing.T, embeddedStatus string, prStatus v1beta1.PipelineRunStatus, taskCount int) {
Copy link
Member

Choose a reason for hiding this comment

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

just one more comment-- t.Helper() would be useful here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

We should make sure we aim for readability in our tests, no matter the size of the PR. I'd rather have a very readable set of tests in 2000 lines than a not-that-readable set of tests in 1000 lines.

Few things:

  • Can we use the test/pars package and inline yaml definitions, it's usually easier to read ? Closer to what we "see" in real life.
  • If we don't have those for some types (status, …), we could "enhance" that library
  • "duplication is far cheaper than the wrong abstraction", especially on tests that we have to maintain over time.

@jerop jerop added this to the Pipelines v0.35 milestone Apr 5, 2022
simple map[string]*v1beta1.PipelineRunTaskRunStatus
}

func getUpdateStatusTaskRunsData() updateStatusTaskRunsData {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I should note that this as a separate function/struct makes more sense if you see the tests added in my WIP branch for the implementation - there, we want to be able to test the function that calls either updatePipelineRunStatusFromTaskRuns and updatePipelineRunStatusFromRuns or the added-in-the-impl updatePipelineRunStatusFromChildRefs (or all of 'em, for embedded-status=both). It didn't make sense to me to copy-paste the structs I end up using in both the existing test and the new one when I could just generate them in a function both the tests can call. I went with a struct as the return from that function rather than a map just because I thought it'd be more clear, but I'm not married to that choice. =)

@abayer
Copy link
Contributor Author

abayer commented Apr 5, 2022

@vdemeester I'm probably going to come back later and see what makes sense to switch to parsed YAML, but I don't want to make this PR any more sprawling/confusing than it already is. =)

@lbernick
Copy link
Member

lbernick commented Apr 5, 2022

/test pull-tekton-pipeline-alpha-integration-tests

})
}
}

func runTestReconcileCustomTaskWithEmbeddedStatus(t *testing.T, embeddedStatus string) {
Copy link
Member

Choose a reason for hiding this comment

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

it looks like this function may accidentally have been duplicated with the one above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yeah, I think I added this one while initially prototyping, before the table-based changes. I'm gonna remove this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check that - I've got TestReconcile_CustomTaskWithEmbeddedStatus and TestReconcile_CustomTask because TestReconcile_CustomTask is already a table-based test and I really didn't want to nest it even further. Lemme think on what's the best way to rearrange these two tests to get the right coverage but not be so duplicative.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, how does https://github.com/tektoncd/pipeline/pull/4734/files#diff-a64a19b939f791920d235cbf5bf2e4905d4814af06f21401b27af11351afbd0bR730 look? I've got it in a separate commit right now so that I can just nuke it easily if it doesn't feel right. =) I decided to skip testing both here because...well, it felt a little redundant.

Copy link
Member

Choose a reason for hiding this comment

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

I can't tell where that links to, but I think the pattern you have going of func TestReconcile(t *testing.T) + func runTestReconcileWithEmbeddedStatus(t *testing.T, embeddedStatus string) works well, and it would also be nice to use it here for consistency. can you explain a bit more about the concern with doing it that way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yeah, you have to expand the diff to see it.

So TestReconcile_CustomTask is already a table-based test - I didn't want to do the matrix-y thing of running each of its testcases once for each embedded-status value, so instead I added two new test cases to TestReconcile_CustomTask, using the same input PipelineRun/expected Run as the existing "custom task with taskref" test case, but with embedded-status=full and embedded-status=minimal. So it doesn't fit exactly the same pattern as the runTest... ones, but I think it's a better fit for this particular test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, in practice, we could probably skip having test cases in TestReconcile_CustomTask for different embedded-status values, since we test reconciliation of a Run with the different embedded-status values in runTestUpdatePipelineRunStatusFromInformer now anyway.

return newCM
}

func TestReconcileOnCancelledPipelineRunFullEmbeddedStatus(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

This test case could likely also use the pattern you're establishing (parameterizing the embedded status), because it doesn't really check any parts of the child statuses

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, good catch.

@@ -702,67 +730,68 @@ func TestReconcile_CustomTask(t *testing.T) {
const pipelineRunName = "test-pipelinerun"
const pipelineTaskName = "custom-task"
const namespace = "namespace"

simpleCustomTaskPRYAML := `metadata:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This and simpleCustomTaskWantRunYAML are here so that we can use the same input PipelineRun and expected Run for test cases with different embedded-status values without duplicating everything.

@lbernick
Copy link
Member

lbernick commented Apr 6, 2022

/lgtm

don't forget to squash the commits

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 6, 2022
This change is to minimize the size of the actual implementation. We need to change a number of
tests in `pkg/reconciler/pipelinerun/pipelinerun_test.go` to be table-based, so that we can test
behavior under each possible value for the new `embedded-status` feature flag. Here, we just
modify the relevant tests to be table-based and use a parameterized helper function for the actual
execution, with a test case for each value.

It also adds helper functions for checking the relevant fields in the `PipelineRun` status, which
are hard-coded to always handle the current, "full" embedded status approach.

This also splits out `TestUpdatePipelineRunStatusFromTaskRuns` and `TestUpdatePipelineRunStatusFromRuns`
into a separate file, `pipelinerun_updatestatus_test.go`. When the TEP-0100 implementation lands,
this will also contain additional tests for updating via child references. Splitting like this helps
keep `pipelinerun_test.go` from getting even more bloated than it is currently.

Until the implementation, these table-based tests are purely duplicative - they're going to run the
same and check the same things for any value of `embedded-status`, but the implementation PR will be
cleaner, only adding the implementation and changing the helper functions to take all of the
possible "embedded-status" values into account. The changes which need to be made in the
implementation PR are all marked with `// TODO(abayer): ...` in `pipelinerun_test.go` and
`pipelinerun_updatestatus_test.go`.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Apr 6, 2022
@abayer
Copy link
Contributor Author

abayer commented Apr 6, 2022

Thanks, @lbernick! Squashed! =)

@lbernick
Copy link
Member

lbernick commented Apr 6, 2022

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 6, 2022
abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 6, 2022
…pelineRuns

See:
* https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
* tektoncd#4705
* tektoncd#4734
* tektoncd#3140

This implements TEP-0100, building on top of the flags/fields/docs changes in tektoncd#4705 and the test
changes in tektoncd#4734.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
@vdemeester
Copy link
Member

/approve

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 6, 2022
@tekton-robot tekton-robot merged commit e46259e into tektoncd:main Apr 6, 2022
abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 6, 2022
…pelineRuns

See:
* https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
* tektoncd#4705
* tektoncd#4734
* tektoncd#3140

This implements TEP-0100, building on top of the flags/fields/docs changes in tektoncd#4705 and the test
changes in tektoncd#4734.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 6, 2022
…pelineRuns

See:
* https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
* tektoncd#4705
* tektoncd#4734
* tektoncd#3140

This implements TEP-0100, allowing for choosing between the original full embedded `TaskRun` and
`Run` statuses in `PipelineRun` statuses, minimal child references to the underlying `TaskRun` and
`Run`s, or both, building on top of the flags/fields/docs changes in tektoncd#4705 and the test changes in

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 8, 2022
…pelineRuns

See:
* https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
* tektoncd#4705
* tektoncd#4734
* tektoncd#3140

This implements TEP-0100, allowing for choosing between the original full embedded `TaskRun` and
`Run` statuses in `PipelineRun` statuses, minimal child references to the underlying `TaskRun` and
`Run`s, or both, building on top of the flags/fields/docs changes in tektoncd#4705 and the test changes in

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 11, 2022
…pelineRuns

See:
* https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
* tektoncd#4705
* tektoncd#4734
* tektoncd#3140

This implements TEP-0100, allowing for choosing between the original full embedded `TaskRun` and
`Run` statuses in `PipelineRun` statuses, minimal child references to the underlying `TaskRun` and
`Run`s, or both, building on top of the flags/fields/docs changes in tektoncd#4705 and the test changes in

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 13, 2022
…d status

This builds on tektoncd#4694, tektoncd#4734, and tektoncd#4753. It will feed into a revamped tektoncd#4739, all as part
of https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
and tektoncd#3140.

Specifically, this adds functionality to `pkg/reconciler/pipelinerun/resources` in
`pipelinerunresolution.go` and `pipelinerunstate.go` which will be needed for the
full implementation. These changes won't have any effects in the current situation,
because `pr.Status.ChildReferences` is never populated, so can be made independently
of the rest of the implementation, thus also shrinking the size of the rest of the
implementation PR(s) for easier review.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 13, 2022
…d status

This builds on tektoncd#4694, tektoncd#4734, and tektoncd#4753. It will feed into a revamped tektoncd#4739, all as part
of https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
and tektoncd#3140.

Specifically, this adds functionality to `pkg/reconciler/pipelinerun/resources` in
`pipelinerunresolution.go` and `pipelinerunstate.go` which will be needed for the
full implementation. These changes won't have any effects in the current situation,
because `pr.Status.ChildReferences` is never populated, so can be made independently
of the rest of the implementation, thus also shrinking the size of the rest of the
implementation PR(s) for easier review.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 13, 2022
…pelineRuns

See:
* https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
* tektoncd#4705
* tektoncd#4734
* tektoncd#3140

This implements TEP-0100, allowing for choosing between the original full embedded `TaskRun` and
`Run` statuses in `PipelineRun` statuses, minimal child references to the underlying `TaskRun` and
`Run`s, or both, building on top of the flags/fields/docs changes in tektoncd#4705 and the test changes in

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 13, 2022
…pelineRuns

See:
* https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
* tektoncd#4705
* tektoncd#4734
* tektoncd#3140

This implements TEP-0100, allowing for choosing between the original full embedded `TaskRun` and
`Run` statuses in `PipelineRun` statuses, minimal child references to the underlying `TaskRun` and
`Run`s, or both, building on top of the flags/fields/docs changes in tektoncd#4705 and the test changes in

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
tekton-robot pushed a commit that referenced this pull request Apr 14, 2022
…d status

This builds on #4694, #4734, and #4753. It will feed into a revamped #4739, all as part
of https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
and #3140.

Specifically, this adds functionality to `pkg/reconciler/pipelinerun/resources` in
`pipelinerunresolution.go` and `pipelinerunstate.go` which will be needed for the
full implementation. These changes won't have any effects in the current situation,
because `pr.Status.ChildReferences` is never populated, so can be made independently
of the rest of the implementation, thus also shrinking the size of the rest of the
implementation PR(s) for easier review.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 14, 2022
…pelineRuns

See:
* https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
* tektoncd#4705
* tektoncd#4734
* tektoncd#3140

This implements TEP-0100, allowing for choosing between the original full embedded `TaskRun` and
`Run` statuses in `PipelineRun` statuses, minimal child references to the underlying `TaskRun` and
`Run`s, or both, building on top of the flags/fields/docs changes in tektoncd#4705 and the test changes in

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 14, 2022
And of course, this is part of https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md,
building on a pile of other PRs (tektoncd#4705, tektoncd#4734, tektoncd#4753, tektoncd#4757).

This adds a new function to `pkg/reconciler/pipelinerun/pipelinerun.go`,
specifically for updating `pr.Status.ChildReferences` during reconciliation. It's
analogous to the existing `updatePipelineRunStatusFromTaskRuns` and
`updatePipelineRunStatusFromRuns` functions. This PR doesn't actually call the
new function - behavior is exactly the same. But it adds the new function,
along with other functions it depends on. In the final step of the
implementation, these other functions will also be used in `...FromTaskRuns`
and/or `...FromRuns`.

I also reworked `pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go`
to improve its test fixtures, so that they're easier to reuse and instantiated
via YAML parsing as much as possible.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 14, 2022
And of course, this is part of https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md,
building on a pile of other PRs (tektoncd#4705, tektoncd#4734, tektoncd#4753, tektoncd#4757).

This adds a new function to `pkg/reconciler/pipelinerun/pipelinerun.go`,
specifically for updating `pr.Status.ChildReferences` during reconciliation. It's
analogous to the existing `updatePipelineRunStatusFromTaskRuns` and
`updatePipelineRunStatusFromRuns` functions. This PR doesn't actually call the
new function - behavior is exactly the same. But it adds the new function,
along with other functions it depends on. In the final step of the
implementation, these other functions will also be used in `...FromTaskRuns`
and/or `...FromRuns`.

I also reworked `pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go`
to improve its test fixtures, so that they're easier to reuse and instantiated
via YAML parsing as much as possible.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
tekton-robot pushed a commit that referenced this pull request Apr 14, 2022
And of course, this is part of https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md,
building on a pile of other PRs (#4705, #4734, #4753, #4757).

This adds a new function to `pkg/reconciler/pipelinerun/pipelinerun.go`,
specifically for updating `pr.Status.ChildReferences` during reconciliation. It's
analogous to the existing `updatePipelineRunStatusFromTaskRuns` and
`updatePipelineRunStatusFromRuns` functions. This PR doesn't actually call the
new function - behavior is exactly the same. But it adds the new function,
along with other functions it depends on. In the final step of the
implementation, these other functions will also be used in `...FromTaskRuns`
and/or `...FromRuns`.

I also reworked `pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go`
to improve its test fixtures, so that they're easier to reuse and instantiated
via YAML parsing as much as possible.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 14, 2022
…pelineRuns

See:
* https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
* tektoncd#4705
* tektoncd#4734
* tektoncd#4753
* tektoncd#4757
* tektoncd#4760
* tektoncd#3140

This implements TEP-0100, allowing for choosing between the original full embedded `TaskRun` and
`Run` statuses in `PipelineRun` statuses, minimal child references to the underlying `TaskRun` and
`Run`s, or both, building on top of all the other PRs referenced above.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
tekton-robot pushed a commit that referenced this pull request Apr 15, 2022
…pelineRuns

See:
* https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
* #4705
* #4734
* #4753
* #4757
* #4760
* #3140

This implements TEP-0100, allowing for choosing between the original full embedded `TaskRun` and
`Run` statuses in `PipelineRun` statuses, minimal child references to the underlying `TaskRun` and
`Run`s, or both, building on top of all the other PRs referenced above.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
chitrangpatel pushed a commit to chitrangpatel/pipeline that referenced this pull request May 3, 2022
…d status

This builds on tektoncd#4694, tektoncd#4734, and tektoncd#4753. It will feed into a revamped tektoncd#4739, all as part
of https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
and tektoncd#3140.

Specifically, this adds functionality to `pkg/reconciler/pipelinerun/resources` in
`pipelinerunresolution.go` and `pipelinerunstate.go` which will be needed for the
full implementation. These changes won't have any effects in the current situation,
because `pr.Status.ChildReferences` is never populated, so can be made independently
of the rest of the implementation, thus also shrinking the size of the rest of the
implementation PR(s) for easier review.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
chitrangpatel pushed a commit to chitrangpatel/pipeline that referenced this pull request May 3, 2022
And of course, this is part of https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md,
building on a pile of other PRs (tektoncd#4705, tektoncd#4734, tektoncd#4753, tektoncd#4757).

This adds a new function to `pkg/reconciler/pipelinerun/pipelinerun.go`,
specifically for updating `pr.Status.ChildReferences` during reconciliation. It's
analogous to the existing `updatePipelineRunStatusFromTaskRuns` and
`updatePipelineRunStatusFromRuns` functions. This PR doesn't actually call the
new function - behavior is exactly the same. But it adds the new function,
along with other functions it depends on. In the final step of the
implementation, these other functions will also be used in `...FromTaskRuns`
and/or `...FromRuns`.

I also reworked `pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go`
to improve its test fixtures, so that they're easier to reuse and instantiated
via YAML parsing as much as possible.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
chitrangpatel pushed a commit to chitrangpatel/pipeline that referenced this pull request May 3, 2022
…pelineRuns

See:
* https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
* tektoncd#4705
* tektoncd#4734
* tektoncd#4753
* tektoncd#4757
* tektoncd#4760
* tektoncd#3140

This implements TEP-0100, allowing for choosing between the original full embedded `TaskRun` and
`Run` statuses in `PipelineRun` statuses, minimal child references to the underlying `TaskRun` and
`Run`s, or both, building on top of all the other PRs referenced above.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/tep Categorizes issue or PR as related to a TEP (or needs a TEP). lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesnt merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants