зеркало из https://github.com/Azure/benchpress.git
Update to PowerShell Sample Code after Running in the Dev Container (#34)
* PowerShell Sample code dev container update * update dev container post commands * dev container run command for powershell * fixing python linting errors * fixing python linting errors
This commit is contained in:
Родитель
eeee250e81
Коммит
0f0da61121
|
@ -1,3 +1,6 @@
|
|||
# [Choice] .NET version: 6.0, 5.0, 3.1, 6.0-bullseye, 5.0-bullseye, 3.1-bullseye, 6.0-focal, 5.0-focal, 3.1-focal
|
||||
ARG VARIANT="6.0"
|
||||
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:${VARIANT}
|
||||
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
RUN Install-Module -Name Pester -Force -SkipPublisherCheck
|
||||
RUN Install-Module -Name Az -Force -SkipPublisherCheck
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
"VARIANT": "6.0"
|
||||
}
|
||||
},
|
||||
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
// Configure properties specific to VS Code.
|
||||
|
@ -28,7 +27,7 @@
|
|||
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
|
||||
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
|
||||
},
|
||||
|
||||
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": [
|
||||
// ARM tools
|
||||
|
@ -39,7 +38,6 @@
|
|||
|
||||
// C#
|
||||
"ms-dotnettools.csharp",
|
||||
|
||||
// Python
|
||||
"ms-python.python",
|
||||
"ms-python.vscode-pylance",
|
||||
|
@ -54,10 +52,9 @@
|
|||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
// Installs:
|
||||
// 1. Mega Linter
|
||||
// 2. Pester
|
||||
// 3. Configures benchpress Python module
|
||||
"postCreateCommand": "npm install -g mega-linter-runner && pwsh -command Install-Module -Name Pester -Force -SkipPublisherCheck && pip install --editable ./framework/python/",
|
||||
// 1. Mega Linter`
|
||||
// 2. Configures benchpress Python module
|
||||
"postCreateCommand": "npm install -g mega-linter-runner && pip install --editable ./framework/python/",
|
||||
|
||||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||
"remoteUser": "vscode",
|
||||
|
|
|
@ -19,9 +19,11 @@ function Deploy-BicepFeature([string]$path, $params){
|
|||
# TODO: Bicep code deploys using subscription deployment. Required to add other deployment types
|
||||
# 1. TenantDeployment 2.ResourceGroupDeployment 3. ManagementGroupDeployment 4. SubscriptionDeployment
|
||||
New-AzSubscriptionDeployment -Name "$deploymentName" -Location "$location" -TemplateFile "$armPath" -TemplateParameterObject $params -SkipTemplateParameterPrompt
|
||||
|
||||
}
|
||||
|
||||
Write-Host "Removing Arm template json"
|
||||
Remove-Item "$armPath"
|
||||
|
||||
}
|
||||
|
||||
function Remove-BicepFeature($resourceGroupName){
|
||||
|
|
|
@ -40,7 +40,7 @@ any_other_function_with_shell_equals_true:
|
|||
- subprocess.check_output
|
||||
- subprocess.run
|
||||
assert_used:
|
||||
skips: []
|
||||
skips: ['*_test.py', '*test_*.py']
|
||||
hardcoded_tmp_directory:
|
||||
tmp_dirs:
|
||||
- /tmp
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
"MSRC",
|
||||
"msrc",
|
||||
"Benchpress",
|
||||
"BenchPress",
|
||||
"pwsh"
|
||||
],
|
||||
"version": "0.2",
|
||||
|
@ -54,4 +55,4 @@
|
|||
"/^\\s*`[\\s\\S]*?^\\s*`/gm",
|
||||
"/^\\s*```[\\s\\S]*?^\\s*```/gm"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ Following instruction shows how to run StorageAccount.Tests.ps1 file
|
|||
|
||||
File is located under following directory: `/samples/dotnet/samples/pwsh/Test`
|
||||
|
||||
Login to Azure Subscription `Connect-AzAccount`
|
||||
if you are using docker container `Connect-AzAccount -UseDeviceAuthentication` and follow additional login instruction on the terminal
|
||||
|
||||
Run the test `.\StorageAccount.Tests.ps1`
|
||||
|
||||
Storage Account deployment uses two bicep files:
|
||||
|
@ -18,8 +21,8 @@ Storage Account deployment uses two bicep files:
|
|||
$ROOT_PATH = $PSScriptRoot | split-path -parent | split-path -parent | split-path -parent | split-path -parent | split-path -parent
|
||||
|
||||
BeforeAll {
|
||||
Import-Module -Name $ROOT_PATH/Benchpress/Helpers/Azure/StorageAcccount.psm1
|
||||
Import-Module -Name $ROOT_PATH/Benchpress/Helpers/Azure/Bicep.psm1
|
||||
Import-Module -Name $ROOT_PATH/BenchPress/Helpers/Azure/StorageAcccount.psm1
|
||||
Import-Module -Name $ROOT_PATH/BenchPress/Helpers/Azure/Bicep.psm1
|
||||
}
|
||||
|
||||
#global variables with required values for the tests. script keyword is used to avoid powershell megalinter complain for global keyword
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
$ROOT_PATH = $PSScriptRoot | split-path -parent | split-path -parent | split-path -parent | split-path -parent | split-path -parent
|
||||
|
||||
BeforeAll {
|
||||
Import-Module -Name $ROOT_PATH/Benchpress/Helpers/Azure/ResourceGroup.psm1
|
||||
Import-Module -Name $ROOT_PATH/Benchpress/Helpers/Azure/Bicep.psm1
|
||||
Import-Module -Name $ROOT_PATH/BenchPress/Helpers/Azure/ResourceGroup.psm1
|
||||
Import-Module -Name $ROOT_PATH/BenchPress/Helpers/Azure/Bicep.psm1
|
||||
}
|
||||
|
||||
Describe 'Verify Resource Group Exists' {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#repo root path
|
||||
$ROOT_PATH = $PSScriptRoot | split-path -parent | split-path -parent | split-path -parent | split-path -parent | split-path -parent
|
||||
Get-ChildItem $ROOT_PATH
|
||||
|
||||
BeforeAll {
|
||||
Import-Module -Name $ROOT_PATH/Benchpress/Helpers/Azure/StorageAcccount.psm1
|
||||
Import-Module -Name $ROOT_PATH/Benchpress/Helpers/Azure/Bicep.psm1
|
||||
Import-Module -Name $ROOT_PATH/BenchPress/Helpers/Azure/StorageAcccount.psm1
|
||||
Import-Module -Name $ROOT_PATH/BenchPress/Helpers/Azure/Bicep.psm1
|
||||
}
|
||||
|
||||
#global variables with required values for the tests. script keyword is used to avoid powershell megalinter complain for global keyword
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
def resource_group_exists(resource_group: str) -> bool:
|
||||
print("ResourceGroup: " + resource_group)
|
||||
return True
|
||||
|
||||
def create_resource_group(azure_subscription: str) -> str:
|
||||
print("Subscription: " + azure_subscription)
|
||||
return "dummy_resource_group_id"
|
||||
|
||||
def destroy(resource_group: str):
|
||||
pass
|
||||
print("Deleting ResourceGroup: " + resource_group)
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
pass
|
||||
|
|
|
@ -15,14 +15,14 @@ class ExampleTest(unittest.TestCase):
|
|||
|
||||
# Act
|
||||
sa_status = storage_account.create(resource_group, storage_account_params)
|
||||
|
||||
|
||||
# Assert
|
||||
self.assertTrue(benchpress.resource_group_exists(resource_group))
|
||||
self.assertTrue(sa_status.success)
|
||||
self.assertEqual(sa_status.a, storage_account_params["a"])
|
||||
self.assertEqual(sa_status.b, storage_account_params["b"])
|
||||
self.assertEqual(sa_status.c, storage_account_params["c"])
|
||||
except:
|
||||
except ValueError:
|
||||
# CRITIAL: We MUST include an "except" block or "finally" will not run
|
||||
# Consider adding a linting rule to enforce try: except: finally
|
||||
print("no-op") # linter try-except-pass rule
|
||||
|
|
Загрузка…
Ссылка в новой задаче