Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Updated workflow file tests & small bugfix for utility (#707)
## Description - Refactored test cases and output for current workflow test - Added test case to ensure the `workflowPath` variable has the correct expected value - In the process added a generic function to get any environment variable defined in a given workflow - Small bugfixes to trigger for branch function & added example to ONLY get pipeline badges - Fixed bug in fallback logic of PSRule formatter ## Example outputs ### Valid file ``` Describing Pipeline tests [+] [operational-insights/workspace] Module should have a GitHub workflow in path [.github/workflows/avm.res.operational-insights.workspace.yml]. 24ms (18ms|6ms) [+] [operational-insights/workspace] GitHub workflow [avm.res.operational-insights.workspace.yml] should have [workflowPath] environment variable with value [.github/workflows/avm.res.operational-insights.workspace.yml]. 11ms (10ms|2ms) ``` ### Invalid file ``` Describing Pipeline tests [+] [operational-insights/workspace] Module should have a GitHub workflow in path [.github/workflows/avm.res.operational-insights.workspace.yml]. 9ms (3ms|6ms) [-] [operational-insights/workspace] GitHub workflow [avm.res.operational-insights.workspace.yml] should have [workflowPath] environment variable with value [.github/workflows/avm.res.operational-insights.workspace.yml]. 20ms (18ms|2ms) Expected strings to be the same, but they were different. Expected length: 60 Actual length: 56 Strings differ at index 56. Expected: '.github/workflows/avm.res.operational-insights.workspace.yml' But was: '.github/workflows/avm.res.operational-insights.workspace' --------------------------------------------------------^ at $environmentVariables['workflowPath'] | Should -Be ".github/workflows/$workflowFileName", C:\dev\ip\Azure-bicep-registry-modules\alexanderSehr-fork\avm\utilities\pipelines\staticValidation\compliance\module.tests.ps1:268 at <ScriptBlock>, C:\dev\ip\Azure-bicep-registry-modules\alexanderSehr-fork\avm\utilities\pipelines\staticValidation\compliance\module.tests.ps1:268 ``` ## Pipeline reference | Pipeline | | - | [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.batch.batch-account.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.cognitive-services.account.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.compute.ssh-public-key.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.db-for-postgre-sql.flexible-server.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.document-db.database-account.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.event-grid.domain.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.event-grid.system-topic.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.event-grid.topic.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.insights.action-group.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.insights.component.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.insights.data-collection-endpoint.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.insights.diagnostic-setting.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.key-vault.vault.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.kubernetes-configuration.extension.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.kubernetes-configuration.flux-configuration.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.logic.workflow.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.managed-identity.user-assigned-identity.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.bastion-host.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.dns-forwarding-ruleset.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.dns-resolver.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.dns-zone.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.express-route-circuit.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.express-route-gateway.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.load-balancer.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.network-interface.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.private-dns-zone.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.private-endpoint.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.public-ip-address.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.public-ip-prefix.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.route-table.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.trafficmanagerprofile.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.network.virtual-network.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.operational-insights.workspace.yml) (unrelated) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.operations-management.solution.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.power-bi-dedicated.capacity.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.resource-graph.query.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.resources.deployment-script.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.search.search-service.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.service-bus.namespace.yml) [](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.sql.server.yml) --------- Co-authored-by: Erika Gressi <[email protected]>
- Loading branch information