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

Listen to checkout instead of on started. #13

Merged
merged 4 commits into from
Aug 21, 2020
Merged

Conversation

XiongKezhi
Copy link
Contributor

Listen to checkout instead of on started can benefit the implementations since onCheckout, implementations can resolve the commit from the run instead of remote repository.

Related jenkinsci/github-checks-plugin#21 and jenkinsci/github-checks-plugin#27

@XiongKezhi XiongKezhi added the enhancement New feature or request label Aug 16, 2020
@XiongKezhi XiongKezhi requested a review from a team August 16, 2020 16:27
@XiongKezhi XiongKezhi self-assigned this Aug 16, 2020
@codecov
Copy link

codecov bot commented Aug 16, 2020

Codecov Report

Merging #13 into master will increase coverage by 0.78%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #13      +/-   ##
============================================
+ Coverage     82.54%   83.33%   +0.78%     
  Complexity       49       49              
============================================
  Files            10       10              
  Lines           212      210       -2     
  Branches          7        6       -1     
============================================
  Hits            175      175              
+ Misses           37       35       -2     
Impacted Files Coverage Δ Complexity Δ
...ins/plugins/checks/BuildStatusChecksPublisher.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4901341...cbeae0e. Read the comment docs.

@XiongKezhi XiongKezhi requested a review from uhafner August 17, 2020 12:45
public void onStarted(final Run run, final TaskListener listener) {
publish(ChecksPublisherFactory.fromRun(run, listener),
ChecksStatus.IN_PROGRESS, ChecksConclusion.NONE);
public void onCheckout(final Run<?, ?> run, final SCM scm, final FilePath workspace,
Copy link
Member

Choose a reason for hiding this comment

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

Is it a problem if this method will be invoked multiple times in a job? E.g., a job may have several SCM checkouts. I'm not sure how our CI is configured, but from https://ci.jenkins.io/job/Plugins/job/analysis-model/job/master/984/ it looks like we have 2 checkouts for each job.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is there a way to inject an extension to Jenkins in integration 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.

I wonder why there are two checkouts so that I can reproduce that and test.

Copy link
Member

Choose a reason for hiding this comment

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

Yes you can have a static inner class annotated with TestExtension.

Our jobs should be just checking out the shared library and the repo.

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 didn't find a better way to test the listeners than adding log information (maybe fine level) and then check the log, but I don't know if this is a good practice to add such log information for tests.

Our jobs should be just checking out the shared library and the repo.

I don't understand this, should we do any other works (check whether the checkout is about the shared library or the repo) in this onCheckout method?

Copy link
Member

Choose a reason for hiding this comment

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

should be fine.

re: testing,

I wouldn't worry about testing listeners get invoked that's tested by Jenkins, if there's logic in it you should test that separately by just passing required params and checking it does what is expected

publish(ChecksPublisherFactory.fromJob((Job)wi.task, null),
ChecksStatus.QUEUED, ChecksConclusion.NONE);
publish(ChecksPublisherFactory.fromJob((Job) wi.task, TaskListener.NULL), ChecksStatus.QUEUED,
ChecksConclusion.NONE);
Copy link
Member

Choose a reason for hiding this comment

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

The Codecov annotation is really nice 🥰

I think this is a good topic for a thesis for one of my students that can be based on the new Coverage and Checks API plugins...

@XiongKezhi XiongKezhi merged commit 350f0f4 into master Aug 21, 2020
@XiongKezhi XiongKezhi deleted the listen-to-checkout branch August 21, 2020 01:54
XiongKezhi added a commit that referenced this pull request Oct 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants