Thursday 23 July 2020

HelixCheck - GitHub action

Recently I've prepared a GitHub action that checks solution structure to see if it is Helix compliant and follow guidelines of folders structure.

It is available on GitHub marketplace and ready to be used with Sitecore projects following Helix principles - https://github.com/marketplace/actions/helix-check.


If you're not familiar with GitHub actions you can read more about it here https://github.com/features/actions or in technical documentation - https://docs.github.com/en/actions.

General rules

Action tries to reflect Helix rules from documentation - https://helix.sitecore.net/

Projects references:
  • Feature layer projects can only reference Foundation
  • Foundation layer projects can only reference other Foundations
  • Project layer projects can reference Feature and Foundation but not other Projects
Folders structure and naming convention:
  • There are layer folders specified in the solution
    • Feature
    • Foundation
    • Project
  • Projects are placed in correct folders, for example:
    • src\Feature\ORM\website\Helixbase.Foundation.ORM.csproj - incorrect
    • src\Foundation\ORM\website\Helixbase.Foundation.ORM.csproj - correct

    Configuration

    Example workflow:

    name: Helix Check
    
    on:
      push:
        branches: [ develop, master ]
      pull_request:
        branches: [ develop, master ]
    
    jobs:
      check_job:
        name: Helix check
        runs-on: ubuntu-latest
    
        steps:
          - name: Checkout
            uses: actions/checkout@v2
    
          - name: Helix Check
            uses: ethisysltd/helix-check@v1.0
            id: check
            with:
              solution-file: 'Helixbase.sln'
              project-name: 'Helixbase'
              website-folder: 'website'
          
          - name: Get the check result
            run: echo "Check result - ${{ steps.check.outputs.result }}"
          
          - name: Get the output time
            run: echo "The time was - ${{ steps.check.outputs.time }}"

    It should be placed inside folder .github\workflows\ and named something like helix-check.yml

    Action is configured by these inputs:

    Input Description Usage
    solution-file Path to the solution that will be analyzed. Required
    project-name The name of your project. Required
    website-folder The name of the folder that always contain website project file.
    Default "website", earlier "code" was used.
    Optional

    While using the action makes sure you've checked the readme.md inside repo, as it will always be most up to date - https://github.com/ethisysltd/helix-check.

    In the action repository I've put example Helix solutions for tests - Helixbase by Neil Shack.
    If there are no issues found, simple log message is shown.

    Solution file: example-solution/valid/Helixbase.sln
    Project name: Helixbase
    Solution file exists.
    
    Solution is Helix compliant.


    I've managed to add a copy of that one and mess it up really badly so you can see result of analysis:

    Solution file: example-solution/invalid/Helixbase-Invalid.sln
    Project name: Helixbase
    Solution file exists.
    
    ##[warning]Issues with project Helixbase.Foundation.ORM
     Folder incorrect: src\Feature\ORM\code\Helixbase.Foundation.ORM.csproj
    
    ##[warning]Issues with project Helixbase.Feature.Hero
     Folder incorrect: src\Foundation\Hero\code\Helixbase.Feature.Hero.csproj
    
    ##[warning]Issues with project Helixbase.Project.Helixbase
     Incorrect references:
      - Helixbase.Project.Common
    
    ##[warning]Issues with project Helixbase.Feature.VersionTrim
     Incorrect references:
      - Helixbase.Project.Common
      - Helixbase.Feature.ShowTitles
    
    ##[warning]Issues with project Helixbase.Foundation.Core
     Incorrect references:
      - Helixbase.Feature.Redirects
      - Helixbase.Project.Common

    ##[error]Solution is not Helix compliant.

    Action is released to the Marketplace under https://github.com/marketplace/actions/helix-check. I will be adding additional checks soon, feel free to give me a shout if you find any issues or bugs.

    Cheers!

    Share it:

    Radosław Kozłowski - Senior Sitecore Developer Radoslaw Kozlowski

    Author & Editor

    Sitecore MVP, passionate Sitecore & .NET developer and architect. Sitecore Community evangelist.

    0 comments:

    Post a Comment