HodorNV / ALOps

ALOps
59 stars 24 forks source link

ALOpsAppCompiler@2 - Ruleset not being applied #493

Closed Joerio closed 2 years ago

Joerio commented 2 years ago

Describe the bug No matter how I input a ruleset, a ruleset never seems to be applied in the pipeline. Maybe I'm passing the ruleset incorrectly, but it seems even if I pass some random string I don't get any feedback.

the used yaml I tried multiple variations of the 'ruleset' parameter, none seem to work:

          - task: ALOpsAppCompiler@2
            inputs:
              artifacttype: 'Sandbox'
              artifactcountry: 'nl'
              ruleset: '.\Pipelines\Rulesets\saas.ruleset.json'
              updatebuildnumber: false
              alcodeanalyzer: 'UICop,CodeCop,PerTenantExtensionCop,AppSourceCop,Gac.Analyzers.AlCop.dll'
              failonwarnings: false

Also tried:

ruleset: '$(System.DefaultWorkingDirectory)\Pipelines\Rulesets\saas.ruleset.json'
ruleset: '.\Pipelines\Rulesets\saas.ruleset.json'
ruleset: './Pipelines/Rulesets/saas.ruleset.json'
ruleset: 'https://navmgtstorage00000000.blob.core.windows.net/backup/app.ruleset.json?sp=r&st=2021-01-17T11:45:50Z&se=2022-02-01T19:45:50Z&spr=https&sv=2019-12-12&sr=b&sig=Y%2BibBuN2cTg3%2FIasH9rigqGBoUCCb9rsSXsrwaW8f%2Fc%3D'

the output I see in the ouput of this task, in the top section, my ruleset setting, eg.:

2022-04-12T11:59:11.1098656Z ruleset                                          C:\Agent2\_work\367\s\Pipelines\Rulesets\saas.ruleset.json            

But this seems to be the only place I see anything about a ruleset. When I look at the alc.exe command being used, there is not ruleset parameter passed:

2022-04-12T11:59:44.1588433Z ##[command]& C:\bcartifacts.cache\sandbox\20.0.37253.39047\VSIX\extension\bin\alc.exe /packagecachepath:"C:\Agent2\_work\367\s\DemoJp.BusinessCentral\Apps\Gac.TradeOnline.DemoApp1\.ALOPSCache" /project:"C:\Agent2\_work\367\s\DemoJp.BusinessCentral\Apps\Gac.TradeOnline.DemoApp1" /out:"C:\Agent2\_work\367\a\GAC Business Solutions_DemoApp1_1.0.11310.0_sandbox_20.0_nl.app" /fullpaths /analyzer:"C:\bcartifacts.cache\sandbox\20.0.37253.39047\VSIX\extension\bin\Analyzers\Microsoft.Dynamics.Nav.UICop.dll","C:\bcartifacts.cache\sandbox\20.0.37253.39047\VSIX\extension\bin\Analyzers\Microsoft.Dynamics.Nav.CodeCop.dll","C:\bcartifacts.cache\sandbox\20.0.37253.39047\VSIX\extension\bin\Analyzers\Microsoft.Dynamics.Nav.PerTenantExtensionCop.dll","C:\bcartifacts.cache\sandbox\20.0.37253.39047\VSIX\extension\bin\Analyzers\Microsoft.Dynamics.Nav.AppSourceCop.dll","C:\Agent2\_work\367\s\Gac.Analyzers.AlCop.dll" /parallel+ /maxDegreeOfParallelism:2 /assemblyprobingpaths:"C:\Windows\assembly","C:\Windows\Microsoft.NET\assembly","C:\bcartifacts.cache\sandbox\20.0.37253.39047\platform\Test Assemblies\Mock Assemblies","C:\bcartifacts.cache\sandbox\20.0.37253.39047\platform\ServiceTier\program files\Microsoft Dynamics NAV\200\Service"

If searched in the raw output of the pipeline, the only place 'ruleset' or 'rule' is being used is when outputting the input parameter. No warnings and/or errors are shown.

Expected behavior I see my result being used, and compilation throwns warnings and/or errors depending on the ruleset I pass. At the very least a warning and/or error if something isn't working in the pipeline.

waldo1001 commented 2 years ago

Can you provide the complete log for this step?

Joerio commented 2 years ago

I added the log for this step as attachment.

log.txt

jpreniers commented 2 years ago

Hi Waldo, do you know when we can expect an update on this ticket?

waldo1001 commented 2 years ago

Hi @Joerio , I only get a subset of the log .. it stops at the start of the compile.. .

In the log, I also see the value "Pipelines\AL\Rulesets\saas.ruleset.json". That doesn't seem right. If it's a relative path to the workspace, please include it like ".\Pipelines..".

A good practice is to use a URL (like blob storage) so you can share the same ruleset easily among other pipelines as well. Did you try that approach?

Where is your ruleset coming from at this moment?

Joerio commented 2 years ago

Hi @waldo1001 ,

Here is a complete log, not sure if it's the exact same run, but should contain the same data CompleteLog.txt

As stated in the original message, we don't know how to pass the ruleset parameter, we tried many different things including an uri, but nothing seems to change anything.

We have a repository with a bunch of rulesets. We also checkout this repo, and depending on the type of Business Central repo, we switch to ruleset (at least that's the goal). So, we have them all locally on the build server.

waldo1001 commented 2 years ago

Ok,

let me give you a few resources.

here you can find documentation on the compilerv2: https://github.com/HodorNV/ALOps/blob/master/Documentation/BuildSteps_v2.md

Here you can find examples: https://github.com/HodorNV/ALOps/tree/master/Examples/Compiler%20V2

One of which describes:

- task: ALOpsAppCompiler@2
  inputs:
    artifacttype: 'Sandbox'
    appversiontemplate: '1.0.*.0'
    alcodeanalyzer: none
      # This will take these specific code analyzers 
      #     example: "alcodeanalyzer: UICop,CodeCop,PerTenantExtensionCop,AppSourceCop"
      # 'none' disables all code analysers
      #     example: "alcodeanalyzer: none"
      # (empty) will take vscode settings      
    ruleset: none
      # path - will take that specific file
      # url - wille download the ruleset from a url, and applies that one
      # 'none' - forces that no ruleset will be applied
      # (empty) will take the vscode settings
      # example: for appsource, you could point to the ruleset from Microsoft:
      #     ruleset: 'https://navmgtstorage00000000.blob.core.windows.net/backup/app.ruleset.json?sp=r&st=2021-01-17T11:45:50Z&se=2022-02-01T19:45:50Z&spr=https&sv=2019-12-12&sr=b&sig=Y%2BibBuN2cTg3%2FIasH9rigqGBoUCCb9rsSXsrwaW8f%2Fc%3D'

So,

I read indeed that "you tried many different things" - what I don't know yet is what you tried exactly though, except from the log you sent me, where I see: Pipelines\AL\Rulesets\saas.ruleset.json as a value. That is not a path, though.

So, you might try actual paths:

I did also some tests myself.

Setting: ruleset: './sometest.ruleset.json' Log:

...
*** Using Ruleset: [X:\vsts-agent-hodor\_work\92\s\Test\sometest.ruleset.json]
*** No AL-RuleSet json found
...

This was expected, because the file doesn't exist. but what is important here is that it actually chnaged the setting to an actual path. I won't do that if it can't:

Setting: ruleset: 'Pipelines\AL\Rulesets\saas.ruleset.json' Log:

...
*** Overrule VSCode settings RuleSetPath: Pipelines\AL\Rulesets\saas.ruleset.json
*** Using Ruleset: [Pipelines\AL\Rulesets\saas.ruleset.json]
*** No AL-RuleSet json found.
...

So that settings wrong, and will never find anything.

What I find very weird is that I don't see that output in your log. What I also seem to read from your log is that you do not have a settings.json in your workspace. Just a hunch, but maybe the lack of the settings prevents alops from overriding it .. .

Could you try to foresee a settings.json in your .vscode folder, make that part of the repository, and try again? And send me the full log again?

waldo1001 commented 2 years ago

@Joerio - were you able to check this?

jpreniers commented 2 years ago

@waldo1001 I've send last week an email to admin@hodor.be with the details and configuration of this issue. Can you please have a look at that?

AdminHodor commented 2 years ago

v1.449: ALOpsAppCompiler@2: Ruleset not being applied when settings.json is missing

@jpreniers, @Joerio We just released v1.449 which contains a possible fix for this issue. Could you please validate that this solves your issue?

jpreniers commented 2 years ago

it looks like release v1.449 requires now a settings.json file. Only we are not using this file! The error is:

[error]Could not find a part of the path 'C:\Agent2_work\423\s\DemoJp.BusinessCentral\Apps\Gac.TradeOnline.DemoApp1.vscode\settings.json'.

AdminHodor commented 2 years ago

@jpreniers , could you please share a little more of the log file of this last error?

jpreniers commented 2 years ago

Log2405.txt See attachment!

AdminHodor commented 2 years ago

@jpreniers , thanks for the log! We just released a hotfix: v1.449.3024

Could you please validate if the hotfix works for you?

jpreniers commented 2 years ago

Thanks! That seems to work now.