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

[CI Environment] Enable 'Publish if not exists' + Fix for 'Publish latest' #2410

Merged
merged 40 commits into from
Dec 23, 2022

Conversation

AlexanderSehr
Copy link
Contributor

@AlexanderSehr AlexanderSehr commented Dec 7, 2022

Description

In case people onboard CARML directly into main they have to apply workarounds to get their modules to publish as the CI envrionment expects a merge to main with module changes in order to publish.

This PR mitigates this issue but not only searching for changes, but also checking of any given module (or child-module) is already part of the target environment (e.g. Bicep Registry, Template Specs, Azure DevOps Artifacts Feed).

Also, this PR fixes an issue with the 'Publish latest' in that it adds a missing passthru of the settings.yml variable to the actual function that needs it.

Required tests:

Test Case \ Environment Azure DevOps GitHub
Target not existing Artifacts Build Status -
Target not existing ACR Build Status AnalysisServices: Servers
Target not existing TS Build Status AnalysisServices: Servers
Target existing Artifacts Build Status -
Target existing ACR Build Status AnalysisServices: Servers
Target existing TS Build Status AnalysisServices: Servers

The idea for a 'first' run in an 'empty' environment is to see an output such as

Bicep registry example
Publish module to private bicep registry
  VERBOSE: Invoke task with
  VERBOSE: {
    "PublishLatest": true,
    "TemplateFilePath": "/home/runner/work/ResourceModules/ResourceModules/modules/Microsoft.AnalysisServices/servers/deploy.bicep"
  }
  
  VERBOSE: Gathering modified files between current branch and main
  VERBOSE: Looking for modified files under: [Microsoft.AnalysisServices/servers]
  VERBOSE: No template file found in the modified module.
  VERBOSE: Modified modules found: [0]
  VERBOSE: No modules with changes found to publish.
  VERBOSE: Invoke Get-ModulesMissingFromPrivateBicepRegistry with
  VERBOSE: {
    "PublishLatest": true,
    "BicepRegistryRgName": "artifacts-rg",
    "BicepRegistryName": "adpsxxazacrx001",
    "TemplateFilePath": "/home/runner/work/ResourceModules/ResourceModules/modules/Microsoft.AnalysisServices/servers/deploy.bicep"
  }
  
  VERBOSE: Missing module [/home/runner/work/ResourceModules/ResourceModules/modules/Microsoft.AnalysisServices/servers/deploy.bicep] will be considered for publishing with version(s) [0.4.0, 0.4, 0, latest]
  VERBOSE: No modules missing in the target environment
 - [Microsoft.AnalysisServices/servers] [0.4.0]
 - [Microsoft.AnalysisServices/servers] [0.4]
  VERBOSE: Invoke task with
  VERBOSE: {
    "BicepRegistryRgName": "artifacts-rg",
    "ModuleVersion": "0.4",
    "BicepRegistryName": "adpsxxazacrx001",
    "BicepRegistryRgLocation": "West Europe",
    "TemplateFilePath": "/home/runner/work/ResourceModules/ResourceModules/modules/Microsoft.AnalysisServices/servers/deploy.bicep"
  }
  
  VERBOSE: Performing the operation "Publish" on target "Private bicep registry entry [bicep/modules/microsoft.analysisservices.servers] version [0.4] to registry [adpsxxazacrx001]".
  VERBOSE: Publish complete
 - [Microsoft.AnalysisServices/servers] [0]
  VERBOSE: Invoke task with
  VERBOSE: {
    "BicepRegistryRgName": "artifacts-rg",
    "ModuleVersion": "0",
    "BicepRegistryName": "adpsxxazacrx001",
    "BicepRegistryRgLocation": "West Europe",
    "TemplateFilePath": "/home/runner/work/ResourceModules/ResourceModules/modules/Microsoft.AnalysisServices/servers/deploy.bicep"
  }
  
  VERBOSE: Performing the operation "Publish" on target "Private bicep registry entry [bicep/modules/microsoft.analysisservices.servers] version [0] to registry [adpsxxazacrx001]".
  VERBOSE: Publish complete
 - [Microsoft.AnalysisServices/servers] [latest]
  VERBOSE: Invoke task with
  VERBOSE: {
    "BicepRegistryRgName": "artifacts-rg",
    "ModuleVersion": "latest",
    "BicepRegistryName": "adpsxxazacrx001",
    "BicepRegistryRgLocation": "West Europe",
    "TemplateFilePath": "/home/runner/work/ResourceModules/ResourceModules/modules/Microsoft.AnalysisServices/servers/deploy.bicep"
  }
  
  VERBOSE: Performing the operation "Publish" on target "Private bicep registry entry [bicep/modules/microsoft.analysisservices.servers] version [latest] to registry [adpsxxazacrx001]".
  VERBOSE: Publish complete

Then, for any subsequent run, the output should look similar to

Bicep registry example
Publish module to private bicep registry
  VERBOSE: Invoke task with
  VERBOSE: {
    "TemplateFilePath": "/home/runner/work/ResourceModules/ResourceModules/modules/Microsoft.AnalysisServices/servers/deploy.bicep",
    "PublishLatest": true
  }
  
  VERBOSE: Gathering modified files between current branch and main
  VERBOSE: Looking for modified files under: [Microsoft.AnalysisServices/servers]
  VERBOSE: No template file found in the modified module.
  VERBOSE: Modified modules found: [0]
  VERBOSE: No modules with changes found to publish.
  VERBOSE: Invoke Get-ModulesMissingFromPrivateBicepRegistry with
  VERBOSE: {
    "PublishLatest": true,
    "BicepRegistryRgName": "artifacts-rg",
    "TemplateFilePath": "/home/runner/work/ResourceModules/ResourceModules/modules/Microsoft.AnalysisServices/servers/deploy.bicep",
    "BicepRegistryName": "adpsxxazacrx001"
  }
  
  VERBOSE: No modules missing in the target environment

Type of Change

Please delete options that are not relevant.

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Update to documentation

Checklist

  • I'm sure there are no other open Pull Requests for the same update/change
  • My corresponding pipelines / checks run clean and green without any errors or warnings
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (readme)
  • I did format my code

@AlexanderSehr AlexanderSehr changed the title [CI Environment] Enable 'Publish if not exists' [CI Environment] Enable 'Publish if not exists' + Fix for 'Publish latest' Dec 7, 2022
@AlexanderSehr AlexanderSehr added bug Something isn't working [cat] pipelines category: pipelines [cat] publishing category: publishing [cat] github category: GitHub [cat] azure devops category: Azure DevOps labels Dec 7, 2022
@AlexanderSehr AlexanderSehr marked this pull request as ready for review December 7, 2022 13:22
@AlexanderSehr AlexanderSehr requested a review from a team as a code owner December 7, 2022 13:22
Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com>
@AlexanderSehr AlexanderSehr enabled auto-merge (squash) December 21, 2022 07:41
Copy link
Contributor

@eriqua eriqua left a comment

Choose a reason for hiding this comment

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

🆗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working [cat] azure devops category: Azure DevOps [cat] github category: GitHub [cat] pipelines category: pipelines [cat] publishing category: publishing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Enable Publishing to always publish if no version was found in the target location
2 participants