Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: Report validation errors on pull requests as comment #1963

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chmouel
Copy link
Member

@chmouel chmouel commented Feb 26, 2025

Changes

This commit introduces the capability to report PipelineRun validation errors as comments on pull requests. This functionality is triggered when validation errors are detected and the event type is a pull request. The errors are formatted into a markdown table and posted as a comment on the pull request, allowing users to easily identify and address issues in their PipelineRun templates.

The commit also includes updates to the provider interfaces to include a CreateComment function, and implementations for GitHub, GitLab, Bitbucket Cloud, Bitbucket Server and Gitea providers.

Jira: https://issues.redhat.com/browse/SRVKP-7075

Submitter Checklist

  • 📝 Ensure your commit message is clear and informative. Refer to the How to write a git commit message guide. Include the commit message in the PR body rather than linking to an external site (e.g., Jira ticket).

  • ♽ Run make test lint before submitting a PR to avoid unnecessary CI processing. Consider installing pre-commit and running pre-commit install in the repository root for an efficient workflow.

  • ✨ We use linters to maintain clean and consistent code. Run make lint before submitting a PR. Some linters offer a --fix mode, executable with make fix-linters (ensure markdownlint and golangci-lint are installed).

  • 📖 Document any user-facing features or changes in behavior.

  • 🧪 While 100% coverage isn't required, we encourage unit tests for code changes where possible.

  • 🎁 If feasible, add an end-to-end test. See README for details.

  • 🔎 Address any CI test flakiness before merging, or provide a valid reason to bypass it (e.g., token rate limitations).

  • If adding a provider feature, fill in the following details:

Git Provider Supported
GitHub App ✅️
GitHub Webhook ✅️
Gitea ✅️
GitLab ✅️
Bitbucket Cloud ❌️
Bitbucket Server ❌️

@chmouel chmouel changed the title feat: Report validation errors on pull requests feat: Report validation errors on pull requests as comment Feb 26, 2025
@chmouel chmouel force-pushed the report-yaml-error-properly-as-comment branch from feea987 to a38ec46 Compare February 27, 2025 12:57
This commit introduces the capability to report PipelineRun
validation errors as comments on pull requests. This functionality
is triggered when validation errors are detected and the event
type is a pull request. The errors are formatted into a
markdown table and posted as a comment on the pull request,
allowing users to easily identify and address issues in their
PipelineRun templates.

The commit also includes updates to the provider interfaces to
include a CreateComment function, and implementations for
GitHub, GitLab, Bitbucket Cloud, Bitbucket Server and Gitea
providers.

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
@chmouel chmouel force-pushed the report-yaml-error-properly-as-comment branch from 1a30d06 to b63beda Compare February 27, 2025 16:08
@chmouel chmouel requested a review from sm43 February 27, 2025 16:08
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.

👼🏼

@chmouel chmouel requested a review from Copilot March 1, 2025 15:21
Copy link

@Copilot 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.

PR Overview

This PR adds functionality to report PipelineRun validation errors as comments on pull requests and introduces a new provider interface function CreateComment. Key changes include:

  • Reporting PipelineRun YAML validation errors as a markdown-formatted comment on pull requests.
  • Adding a CreateComment function implementation across multiple provider packages (GitHub, GitLab, Gitea, Bitbucket Cloud, Bitbucket Server).
  • Updating tests and documentation to reflect the new error reporting behavior.

Reviewed Changes

File Description
test/testdata/failures/pipeline-validation.yaml New invalid PipelineRun template for testing validation errors
test/gitea_test.go Added tests for reporting bad YAML errors on pull requests
docs/content/docs/guide/running.md Added documentation for YAML parsing error reporting
pkg/provider/github/github.go Added CreateComment implementation for GitHub
pkg/pipelineascode/match.go Enhanced error reporting by creating a markdown comment with YAML errors
pkg/provider/gitlab/gitlab.go, gitea.go, etc. Added CreateComment implementations for other providers
pkg/provider/interface.go Updated provider interface to include CreateComment

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants