You are currently viewing Automatic Code Review of Power Platform Canvas App with Power Platform Pipelines

Automatic Code Review of Power Platform Canvas App with Power Platform Pipelines

A few weeks ago, I was reading on some strategies to do “code” reviews for power platform solutions. My goal was to figure how to review a solution that was being pushed via Power Platform Pipelines and give the developer and project lead a scoring for how it performed. This got me reading more into Power Apps Code Review tool created by Power CAT powerapps-tools/Tools/Apps/Microsoft.PowerApps.CodeReview at master · microsoft/powerapps-tools · GitHub. This provided a framework for getting Canvas apps reviewed and ranked but wanted to automate the reviews so that it would do the review as it was being promoted in the pipeline.

The basic architecture will be like this

flowchart TD subgraph Tennant B[1.2.1 - Start App Review] --> |Solution Name & Solution Version & Canvas App Score & Link to Report| C direction TB subgraph Pipeline Orchestrator A[1.2 - When a push to test happens] -->|Solution Name & Solution Version & Stage Run ID & ArtifactID| B end subgraph Production C[Solution History Table] end end

 

When a new push to test occurs, a review of the solution will occur. After the review, the output is sent to the PPPM Solution History table. From here we can add the score to the notification sent to the project lead before approving the solution into production.

Solution History Table

Within the PPPM solution, create a new table called Power Platform Solutions History

--- title: Power Platform Solution History --- erDiagram Solution_History}| -- || PPPM_Solution_Tracking:contains Solution_History { string Solution_Version_Name PK url Link_to_report float App_Review_Score float Review_Score GUID PPPM_Solution FK }

 

 

Power Apps Code Review Tool

The Power Apps Code Review tool is comprised of two apps (MDA and a canvas). The MDA is where all the rules and the reviews can be reviewed. The canvas app is where the an amazing showcase for what a canvas app can do. It provides a great interface for Code Reviews Checklists, App Checker, App Overview, Code Review, and Review Results

 

 

Within the app I made an update to help with deep linking.

  1. Within the AppOnStart I set the AppID to the environment variable the equals the environment variable andy_PowerAppsReviewAppID
    Set(
        AppID,
        LookUp('Environment Variable Values', 'Schema Name' = "andy_PowerAppsReviewAppID").Value
    );

     

  2. Within the AppStartScreen I updated the If statement to navigate to the SolutionDetailsScreen
    If(!IsBlank(Param("reviewid")), SolutionDetailsScreen)

     

  3. Within the OnVisible of the SolutionDetailsScreen, add an if statement that will set the variable ActiveSolutionReviewID to be either reviewid or SolutionReviewID. Then update the var SelectedSolutionReview and collection SolutionReviewApps.
    // Set ActiveSolutionReviewID based on whether the parameter is blank
    Set(
        ActiveSolutionReviewID,
        If(
            IsBlank(Param("reviewid")),
            SolutionReviewID,
            Param("reviewid")
        )
    );
    
    // Set SelectedSolutionReview using ActiveSolutionReviewID
    Set(
        SelectedSolutionReview,
        LookUp(
            PatchedSolutionReviews,
            Rev_SolutionReview = GUID(ActiveSolutionReviewID)
        )
    );
    
    // Populate SolutionReviewApps using ActiveSolutionReviewID
    ClearCollect(
        SolutionReviewApps,
        Filter(
            Rev_Apps,
            Rev_Apps_SolutionReview.Rev_SolutionReview = GUID(ActiveSolutionReviewID) &&
            Chx_AppType <> AppType.'Model Driven App'
        )
    );
    

     

  4. The Solution score button in the upper right needs to be updated as well to use the new variable
    Round(
        LookUp(
            Rev_SolutionReview,
            Rev_SolutionReview = GUID(ActiveSolutionReviewID)
        ).Nb_SolutionScore * 100,
        0
    ) & "%"

     

  5. I also updated the header back button to be hidden if the review is not blank. This way the user can only navigate to the report they were sent.

Pipeline Flow Configuration

1.2 - When a push to test happens

The trigger for the flow will be When an action is performed

To ensure that the trigger only occurs when a push to test occurs, a trigger condition needs to be set. For me, it is the deploy to test stage

@equals(triggerOutputs()?['body/OutputParameters/DeploymentStageName'], 'STAGENAME')

 

Next will be a Scope with two Dataverse Get row ID actions

 

The first will get the stage run information using the stage run id from the trigger

triggerOutputs()?['body/InputParameters/StageRunId']

 

 

The other will get the Deployment Artifact from the action above

outputs('Get_a_row_by_ID_-_Deployment_Stage_Runs')?['body/_artifactid_value']

 

 

A child flow will be triggered that starts the actual app review

 

 

A scope with a condition based on the review status of the app review

 

Within the True side, add two Dataverse Actions.

 

The first will get the GUID of the solutions tracking table in the production environment using the name of the Artifact

 

The second adds a row to the Solution History table in Production table

 

1.2.1 - Start App Review

The 1.2.1 flow is the child flow called from the 1.2.1 flow and start the actual app review

  1. The trigger will be a manual trigger that asks for the StageRunID, ArtifactID, ArtifactName, ArtifactVersion
  2. Next, add a Boolean variable called varStatus
  3. To get the artifact out of the pipeline a HTTP action
  4. Within a Scope action four Dataverse Actions are added
  5. The first will add a new row to the Solution Review table
  6. The second will upload the file to the Solution Review table
  7. The third adds a new row to the Review Request table
  8. The fourth will set the review status of In Progress
  9. After the Scope another scope is added with a Do Until Action and a Dataverse Action
  10. The Do until will keep running until varStatus is equal to true
    1. Within the Do until add a delay action, this will give the review time to run
    2. Next add a Get row by ID of the Solution Review table
    3. Add a condition that checks to see if the status of the review is done
    4. If it equals Done or Error and not In Progress then it will set the variable varStatus to true
  11. The last action within the scope will get the Solution Review record via ID
  12. The last action within the flow will be to respond to the parent flow with the app review score, the review status, and the reviewid

 


This was a really interesting post to write. I have always wanted to do “reviews” with my teams that do not have ADO or another connected system. In the next post, I will go over how I build a method for doing reviews on Power Automate flows using Power Platform Pipelines.

Leave a Reply