Github checks API vs check runs vs check suites - github-api

I want to understand Github Checks API so that I can use them to retrieve data. On following Github documentation https://docs.github.com/en/rest/guides/getting-started-with-the-checks-api I am able to derive that check runs are associated with the sha of the change and at each commit on branch check suite is created. Checks API helps in getting all this information. But I want more clarity on three of them in terms of differences. Can anyone please explain these three terms using simple example and terms?

So, first of all, the GitHub Commit Statuses API is separate from the GitHub
Checks API (includes suites & runs), so let's look at them individually first then I'll explain the differences.
Before we get into it, I want to differentiate a PR Check from a Check Run, to avoid confusion. A PR Check describes the current state (trying not to say status here 😉) of a given job or task running in CI or elsewhere on a specific PR commit. These can be created via either a Commit Status or a Check Run. All the items in the pink box below are PR Checks, notice the Hide all checks button.
GitHub statuses - API
I see this as the simple, all-purpose API for reporting PR Checks for a given commit. It's easy and doesn't require jumping through hoops to just display a simple result of a PR Check for a given commit. This API also came before the check API so it's a little less powerful.
Pros
Simple and easy API
Simple relation with context as the identifier.
Can have a fully customizable text description on the PR Checks UI.
You can create statuses as a user with a Personal Access Token (aka PAT) without needing to create a GitHub App, though does work with GitHub Apps too!
Cons
Limited status options, only allow error, failure, pending, success, no conclusion subset option to define completed jobs like Check Runs.
No concept of job timing or duration.
No grouping of statuses, like Check Runs are grouped into Check Suites by their GitHub App
No annotations
No detailed output logs. This is not too important as you could just link to the URL where the actual PR Check was run such as in CircleCI, Jenkins, etc. But the user is not always authorized to view these runs so the output could be helpful for open source repos that have non-public CI.
GitHub Checks - API
The Checks API is the latest and greatest tool for displaying task results on commits, which can essentially do everything the Commit Statuses API can do and more. Check Runs belong to one Check Suite, one Check Suite can have many Check Runs. You can only have one Check suite per commit (i.e. head_sha) per GitHub App, attempting to create another for a given App will just return the previously created Check Suite. Thus, a new Check Run is automatically assigned to the Check Suite based on the authenticated GitHub App, you cannot manually assign Run to Suites.
Contrary to statuses, Check runs are identified by an auto-generated check_run_id and not a context string.
I haven't touched too much on the Check Suites API because they are really just a grouping of Check Runs which is pretty self-explanatory and they don't affect any of the PR Checks UI, only the grouping of Check Runs in the checks tab. One thing to note is that by default you can create a Check Run without having to first create a Check suite and GitHub will just create a new Check Suite for you.
Pros
Greater granularity of status/conclusion for a run.
A lot of power to display the result of a PR Check.
Can provide run context via output summary in Markdown.
Can create annotations for specific lines of code to add information about the analysis performed, like linting error for a given line of code. These will show up in the PR files tab UI similar to PR code comments as well as in the PR Checks tab with any other Check Run output.
Has time awareness to report on durations automatically with little effort.
Cons
A little more complicated API and relationships to manage.
Part of the description in the PR UI is auto-generated based on the status conclusion and duration of the check run task.
Cannot be created via a user PAT, must be created from an authenticated GitHub App. Read access to this API does not require authenticating as a GitHub App.
One edge case you likely won't come across but is good to know: If you are creating a new Check Run with the exact same name of an existing check run under the same authenticated app. The resulting behavior is a little strange but doing this will create the new Check Run under the same name, but will not delete the existing Check Run. However, the Check Suite will not see or link to the existing Check Run, even in the PR UI. BUT!! If you change the name of either such that the runs now have unique names, it will be linked up again. It seems GitHub just does a sort by date and then filters by unique names when looking up Check Runs in a Check Suite. This does not apply with identical names from different authenticated apps.
Comparisons
Below is a mapping of sorts to compare similar options between the Commit Statuses API and the Check Runs API. They are not exactly 1:1 but similar.
Commit Status
Check Run
Option Desciption
sha
head_sha
These are equivalent with the minor exception that the Commit Status is linked to the sha directly, whereas the head_sha is linked to the Check Suite that the Check Run belongs to.
context
name
The context is used as an identifier but both define the title of the PR Check in the PR UI. Because Check Runs are tracked by the check_run_id the name option may change without creating a new Check Run. This is not the case for context, changing the context will always create a new Commit Status. You may not have duplicate names for Check Runs created with the same GitHub App, see note above.
context*
external_id
The external_id is meant for keeping track of Check Runs without having to store ids or always keep the name constant. This is only somewhat similar to the context option but only for the purpose of identifying the Check Run.
description
output.title
The main difference here is that description gives you the full space to work with, where output.title will be displayed after the auto-generated status string.
target_url
details_url
These are somewhat equivalent, the first difference is that target_url will not show unless defined whereas details_url will default to the check run URL in the PR UI. The other difference is the Check Runs Details button on the PR Checks UI will always link the the Checks page which will present a link to the details_url if defined.
state
status
These are very similar but have slightly different allowed values but effectively appear the same in the PR UI.
N/A
conclusion
This just shows the increased power of the PR Checks API where you have more granular control over the PR Check status, though not a big difference in the UI, see example variations below.
N/A
started_at
No comparable option for Commit Statuses.
N/A
completed_at
No comparable option for Commit Statuses.
N/A
actions
No comparable option for Commit Statuses.
N/A
output
No comparable option for Commit Statuses.
N/A
output.annotations
No comparable option for Commit Statuses.
* Only somewhat similar, not a direct equivalent.
PR Checks UI Component mappings
I've taken a simple PR Check and highlighted the differences between the elements of the UI between the Commit Status API and the Check Runs API. Very similar but slight differences.
Below are example variations to relate the options to their impact on the
PR Checks UI.
Commit status variations
Check Run variations
If a check run is in an incomplete state for more than 14 days, then the Check Run's conclusion becomes stale. Only GitHub can mark Check Runs as stale.
Checks Tab in PR UI
The Checks Tab in the PR UI will display all created Check Suites and their child Check Runs and allows you to set the output option to control the content of this page. This page would also show images and annotations if you defined those too.
One final note: You cannot DELETE any Commit Status, Check Run or Check Suite once created, only updating is allowed. With these statuses being so ephemeral this is not that big of a deal but in case you were wondering.
Update (6/21/2022)
I found two more quirks to explain. First, the details_url for Check Runs does not set the value of the Details button, instead the Details button actually always redirects to the Checks page which has a link to the details_url if defined.
Second, once a Check Run status is set to 'completed', there is not way to un-complete the Check run. But you can get around this by creating a new Check Run with the same name and set that status to something other than 'completed'. See this edge case with duplicate-named Check Runs explained above in detail.
Update (6/29/2022)
As mentioned above, the Check Runs API keeps track of the duration of the run. It is important to note that the started_at time is set only once whenever a check run is created, regardless of the defined status. For example, if I trigger a CI build and set all jobs status to queued, the jobs run duration will be inaccurate. A good way to fix this is to always set the started_at time whenever you set the status to in_progress. Something as simple as const started_at = new Date().toISOString() (javascript) will do the trick.

Related

How to use a list column value as a flag to resolve infinite loop problems in a Power Automate flow?

I am trying to resolve this error in Power Automate:
Actions in this flow may result in an infinite trigger loop.
Please ensure you add appropriate conditional checks to prevent this flow from triggering itself.
This seems to be a common problem when using this trigger:
When an item is created or modified
where the associated flow contains this action:
Update item
The dynamic is succinctly explained in these videos here and here.
Desired Behaviour
The desired behaviour is that the flow:
Runs when a list item is created or modified by a user (and updates the item accordingly)
But not when the flow itself updates the item
Actual Behaviour
The actual behaviour is that the flow:
Runs when a list item is created or modified by a user (and updates the item accordingly)
Also runs when the flow itself updates the item (causing an infinite loop)
What I've Tried
Some posts suggest using a Service Account to run the flow and then apply the logic:
If the flow was triggered by a Service Account, terminate the flow
But I do not have access to a service account in this scenario.  
The simplest solution seems to be answers like this one and this one.
They suggest creating a column in the SharePoint List to store a 'flag'.  
I understand the concept of using flags to indicate:
DO run the flow if SOME_FLAG is false
DO NOT run the flow if SOME_FLAG is true
But I am having trouble when it comes to implementing them properly in this scenario. 
Specifically, I have added a Yes/No column to my List called LastModifedByFlow.  
The default value is No (i.e. false).
My flow is structured like this:
01)  TRIGGER:  When an item is created or modified
02)  I have added this Trigger Condition
#equals(triggerBody()?['LastModifiedByFlow'],false)
03)  This means the flow will run when LastModifiedByFlow is false
04)  Create some variables  
05)  ACTION: Update the item - this includes setting the LastModifedByFlow value to true
Question
The first time the flow runs, it works great:
the item is updated
the item's LastModifedByFlow value is set to true so the flow doesn't run again
But how and where in the flow do I set the LastModifedByFlow value back to false?
So that the flow will run each time a user subsequently modifies the list item?
  
It is recommended that you set a default value of “Yes” for the Yes/No column first. When the item is created, the flow will be triggered. After the flow is completed, the value of the column "Yes" will become "No". When the item is modified, it is recommended to manually change "No" to "Yes" to trigger the flow. Here is a post for your reference.

Detect an Invalid User Attribute Field entry in OIM and send email notification based on the user type

I am required to create a Java Script but unable to figure on how to proceed as I don't have that much of coding idea in OIM, can someone assist(below I have mentioned the scenario)
Scenario:
In OIM User Attribute Page, there is a User Field: 'Job Code' now we have experienced that there are some issues we are facing.
From the trusted source we are getting the correct data but as soon as it reaches OIM for few users we are getting random incorrect value. Value should be numbers (123456) which is present in the Database too and valid but for few we are receiving values like E?401#q something like this.
We are required to place a check to find users who are having these invalid Job Code entry.
Once detected, we need to trigger a email to the concerned team based on the User Type (Employee or Contractor) for employee it should trigger an email to a respective team and for Contractor we have to trigger to a different team to take action.
So, I believe we have to place two conditions here, can someone assist.
If you believe it only happens during trusted source reconciliation, then you can create Post-Process Handler on User Create/Modify operation to check the value which was posted into the DB as a result of recon event.
From this handler you can do all the things you need to do: mailing, fixing, etc.
For notification purposes I'd recommend to use built-in NotificationService, though it might be bit daunting, if you have little experience in OIM development. As an alternative you can do java mailing.
If you are not sure about the moment, when this "spoiling" happens, you can create a scheduled task, to be executed periodically, which will check JobCode values, to report invalid ones.

Microsoft Flow Execution Order

I have created a bunch of short flows that act on a single SharePoint list item to reduce complexity, but I've run into a problem with the order in which they execute. I think I could best explain this with an example, so please see below:
Let's say there are three flows, SetTitle, SetPermissions, and SendEmail (sends an email based on the new value after a column changes). Ideally, SetPermissions would run first, then SendEmail, and finally SetTitle since it modifies the item. That modification is a problem because it adds a version to Version History, which I am checking in the SendEmail flow to see if the value of a column changed.
Currently, however, SetTitle sometimes runs first, which breaks SendEmail because now the most recently displaced version does not contain a record of the column change that happened two versions ago.
I would like to avoid creating additional columns in the item to track column changes or emails sent, because we're creating these flows to avoid that messy complexity.
I'm hoping that there is some hidden execution order option somewhere, because as I said, I don't really want to create extra columns or trigger flows based on HTTP calls. Of course, what I'm doing now isn't working, so I understand that I may have to compromise.
I do not think what you are looking for is possible tbh.
I know you said you do not want to create more columns, but the only solution that I can think of requires only 1 extra column to be created. Use that to run the flows in the right order.
For example, if there are two flows: f1 and f2, set the default value of the new column(let's call it 'stage') to 0. Then, add a condition to f1 so it only runs when the stage is 0 and also updates the column to 1. Then f2 also has an initial condition check and runs only when 'Stage' is '1' and also sets 'Stage' to '2'.
Hope this helps.

Create Empty Form In Jdeveloper 12c

I am using J Developer 12 c. I want to create form but without any data fetched in.I want user to enter detail in form for submission.I have tried all online solution but they are for J Developer 11.I am not able to fetch an empty form.
When I run my form it automatically fetch record from the table.I have tried use create insert but i want form to be automatically fetched with new record every time page is run.
Add a CreateInsert action in your task flow on the way into you page. This will clear the fields for data entry. Look here.
You need to understand the difference between commit and submit. You want to submit the pages - clicking a submit button - and then the page is processed and the EO/VOs are updated in memory.
The Commit operation writes the in-memory changes to the datasource (database). So, you can submit pages 1-3 then using the same data control the fields will be populated with the entered data on page 4. Now the user can commit the changes. The Commit action is located in the operations for the AppModule-DataControl.
This is the power of the ADF Data Control. Changes to fields are cached in memory and are available to any page and then those changes can be committed when you choose. Note, the Task Flow can control the transaction itself.
Sounds like you need to learn the basics of ADF. I suggest this book and this set of resources I maintain for my students and these.
And, if you will be doing a lot of ADF development, it is well worth your time to take our ADF course.
(It also seems you are unaware of how stack overflow works. When you get an response that answers you question, you up-vote the answer, so it encourages those of us taking our time to answer you question for free to continue doing so. Please note that I answered your original question and Shay reinforced that answer.
And I have now answered your second question, and provided links to resources to help you go further.
I already marked the correct answer however my second question where i was unable to commit on review page which fetch data from 3 vo i got solution thanks to http://www.baigzeeshan.com/2010/11/avoiding-jbo-26048-during-commit-in.html.Actually the first Eo is master for rest 2 Eo so it would ideally allow me to commit detail data only after i commit the master.Now i found the blog and it suggested me to do changes in association and add behaviour for composite association and cascade update for key attribute.Now i can directly commit on my last review page and navigate through task flow easily without using commit on eac individual page.thanks all who helped me.

How can I restrict the status reasons a user can select depending on the current status reason of a case?

I am designing a workflow that uses the status reason to route cases to a variety of queues within our organisation.
In order to enforce the process within the workflow (and to reduce the number of status reasons the user needs to select from), I would like to restrict which status reasons can be selected based upon the case's current status reason. We have 12 status reasons.
E.g. I would like to ensure that a if a case is in a "Ready for Report Creation" status reason, users can only set the status reason to "Cancelled", "On Hold" or "Draft Report Completed" - but they should not be able to set the status reason to "Report Approved".
I have given some thought to the issue and the current solution I am considering is to:
Hide the status reason field on the case.
Create a CRM dialog process, which provides the user with the relevant status reasons to choose from, based upon the current status reason for the case.
Whilst this solution is effective, a lot of configuration is required as a page is required for each status reason - within the CRM dialog process.
Does anyone have any suggestions as to less unwieldy solution to this problem?
NOTE: This is an on-premise installation so we have complete flexibility w.r.t. types of solution we can deploy.
Couple of ways to do this.
A dialog would certainly give you a codeless option.
If you are happy to use JavaScript, you could add & remove options dynamically using functions like adoption, clearOptions and removeOption from Xrm.Page.ui Control Methods. Which would give a more fluid user experience.
If you want to enforce the business rules you could also add a plugin which throws exceptions when the wrong status is set, to prevent any data imports or other processes from setting the value incorrectly.

Resources