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

Add support for matching PipelineRuns to Pull Request labels #1854

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

chmouel
Copy link
Member

@chmouel chmouel commented Dec 6, 2024

Implement annotation-based PipelineRun label matching functionality:

  • Add pipelinesascode.tekton.dev/on-label annotation for label-based PipelineRun triggers
  • Support label matching on GitHub, Gitea, and GitLab providers
  • Implement immediate PipelineRun triggering when labels are added
  • Enable re-triggering of PipelineRuns on commit updates with existing labels
  • Provide access to Pull Request labels via {{ pull_request_labels }} dynamic variable

Supported providers:

  • GitHub
  • Gitea
  • GitLab

Limitations:

  • Not supported on Bitbucket Cloud and Bitbucket Server

Demo:

2024-12-11.16-48-26.mp4

https://issues.redhat.com/browse/SRVKP-5950

Changes

Submitter Checklist

  • 📝 Please ensure your commit message is clear and informative. For guidance on crafting effective commit messages, refer to the How to write a git commit message guide. We prefer the commit message to be included in the PR body itself rather than a link to an external website (ie: Jira ticket).

  • ♽ Before submitting a PR, run make test lint to avoid unnecessary CI processing. For an even more efficient workflow, consider installing pre-commit and running pre-commit install in the root of this repository.

  • ✨ We use linters to maintain clean and consistent code. Please ensure you've run make lint before submitting a PR. Some linters offer a --fix mode, which can be executed with the command make fix-linters (ensure markdownlint and golangci-lint tools are installed first).

  • 📖 If you're introducing a user-facing feature or changing existing behavior, please ensure it's properly documented.

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

  • 🎁 If feasible, please check if an end-to-end test can be added. See README for more details.

  • 🔎 If there's any flakiness in the CI tests, don't necessarily ignore it. It's better to address the issue before merging, or provide a valid reason to bypass it if fixing isn't possible (e.g., token rate limitations).

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 62.63736% with 34 lines in your changes missing coverage. Please review.

Project coverage is 65.64%. Comparing base (0315a46) to head (cb6e218).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
pkg/matcher/annotation_matcher.go 68.42% 4 Missing and 2 partials ⚠️
pkg/provider/gitea/parse_payload.go 0.00% 6 Missing ⚠️
pkg/provider/github/parse_payload.go 0.00% 4 Missing and 2 partials ⚠️
pkg/provider/gitlab/parse_payload.go 40.00% 4 Missing and 2 partials ⚠️
pkg/provider/gitlab/gitlab.go 20.00% 2 Missing and 2 partials ⚠️
pkg/provider/github/github.go 0.00% 2 Missing and 1 partial ⚠️
pkg/provider/github/status.go 57.14% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1854      +/-   ##
==========================================
- Coverage   65.74%   65.64%   -0.11%     
==========================================
  Files         178      178              
  Lines       13840    13889      +49     
==========================================
+ Hits         9099     9117      +18     
- Misses       4126     4148      +22     
- Partials      615      624       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chmouel
Copy link
Member Author

chmouel commented Dec 11, 2024

/test go-testing

@chmouel chmouel force-pushed the match-on-label branch 2 times, most recently from 15a87e1 to 9acf54c Compare December 11, 2024 15:26
@chmouel chmouel changed the title Allow matching on Pull Request labels Add support for matching PipelineRuns to Pull Request labels Dec 11, 2024
@chmouel chmouel marked this pull request as ready for review December 11, 2024 15:31
@chmouel chmouel force-pushed the match-on-label branch 3 times, most recently from 4d44daf to cb6e218 Compare December 12, 2024 13:09
@chmouel
Copy link
Member Author

chmouel commented Dec 12, 2024

/test go-testing

@zakisk
Copy link
Contributor

zakisk commented Dec 19, 2024

@chmouel I've copied same PR that you're using in video example but in output I'm getting:

Labels on PR: 
{{
labels
}}

@chmouel
Copy link
Member Author

chmouel commented Dec 19, 2024

Yeah I need to update the video😅 it's called pull_requests_labels now since can only apply there , see the doc and e2e

@chmouel chmouel force-pushed the match-on-label branch 2 times, most recently from 81decdd to b9cff91 Compare December 20, 2024 09:04
@chmouel
Copy link
Member Author

chmouel commented Dec 20, 2024

/retest

Implement annotation-based PipelineRun to label matching functionality:

- Add `pipelinesascode.tekton.dev/on-label` annotation for label-based
  PipelineRun triggers
- Support label matching on GitHub, Gitea, and GitLab providers
- Implement immediate PipelineRun triggering when labels are added
- Enable re-triggering of PipelineRuns on commit updates with existing labels
- Provide access to Pull Request labels via `{{ pull_request_labels }}`
  dynamic variable

Supported providers:
- GitHub
- Gitea
- GitLab

Limitations:
- Not supported on Bitbucket Cloud and Bitbucket Server

Signed-off-by: Chmouel Boudjnah <[email protected]>
@zakisk
Copy link
Contributor

zakisk commented Dec 20, 2024

@chmouel now I see

Labels on PR: 
bug

@chmouel
Copy link
Member Author

chmouel commented Dec 20, 2024

Is it a question ?@zakisk

@zakisk
Copy link
Contributor

zakisk commented Dec 20, 2024

@chmouel No, just saying that I am able to print labels with pull_request_labels variabl.

Implement annotation-based PipelineRun to label matching functionality:

- Add `pipelinesascode.tekton.dev/on-label` annotation for label-based
  PipelineRun triggers
- Support label matching on GitHub, Gitea, and GitLab providers
- Implement immediate PipelineRun triggering when labels are added
- Enable re-triggering of PipelineRuns on commit updates with existing labels
- Provide access to Pull Request labels via `{{ pull_request_labels }}`
  dynamic variable

Supported providers:
- GitHub
- Gitea
- GitLab

Limitations:
- Not supported on Bitbucket Cloud and Bitbucket Server

https://issues.redhat.com/browse/SRVKP-5950

Signed-off-by: Chmouel Boudjnah <[email protected]>
@chmouel
Copy link
Member Author

chmouel commented Dec 20, 2024

only add the support_matrix documentation tag, merging it due of @zakisk previous review

@chmouel chmouel merged commit e0d0ad7 into openshift-pipelines:main Dec 20, 2024
7 checks passed
@chmouel chmouel deleted the match-on-label branch December 20, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants