1
1
# Contributing
2
2
3
- ## TODO
4
3
## Welcome
5
4
6
5
Before we go any further, thanks for being here. Thanks for using dbachecks and especially thanks
@@ -34,7 +33,7 @@ In order to use the devcontainer there are a few things you need to get started.
34
33
- [ Docker] ( https://www.docker.com/get-started )
35
34
- [ git] ( https://git-scm.com/downloads )
36
35
- [ VSCode] ( https://code.visualstudio.com/download )
37
- - [ ` Remote Development ` Extension for VSCode] ( https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack )
36
+ - [ Remote Development Extension for VSCode] ( https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack )
38
37
39
38
### Setup
40
39
@@ -61,9 +60,81 @@ so that could take a hot second depending on your internet speeds.
61
60
1. The first time you do this it may take a little, and you'll need an internet connection, as it'll download the container images used in our demos
62
61
63
62
### Develop & Build
64
- TODO: sampler instructions - similar to /workspace/developing/Howto.md
65
63
66
- ### Rebuild
64
+ We are using the [Sampler](https://github.com/gaelcolas/Sampler) Powershell Module to structure our module.
65
+ This makes it easier to develop and test the module locally.
66
+
67
+ The workflow for using this and developing the code - for example to add a new Database level check you could follow
68
+ this guide.
69
+
70
+ 1. Download the repo locally and create a new branch to develop on
71
+ ```PowerShell
72
+ git checkout -b newStuff # give it a proper name!
73
+ ```
74
+
75
+ 1. Develop in the source repository, to add a check you need to add the following code:
76
+ - add check code to `source/checks/DatabaseV5.Tests.ps1`
77
+ - add required configurations to `source/internal/configurations/configuration.ps1`
78
+ - `skip.database.checkName`
79
+ - `policy.database.checkNameExcludeDb`
80
+ - add required properties to object info to `source/internal/functions/Get-AllDatabaseInfo.ps1`
81
+
82
+ 1. Build the module
83
+ ```PowerShell
84
+ ./build.ps1 -Tasks build
85
+ ```
86
+
87
+ 1. Sampler automatically adds the new version to your path you can prove that with the following code:
88
+ ```PowerShell
89
+ get-module dbachecks -ListAvailable | Select-Object Name, ModuleBase
90
+ ```
91
+
92
+ 1. Import new version of the module
93
+ ```PowerShell
94
+ Import-Module dbachecks -force
95
+ ```
96
+
97
+ 1. Test out the new code
98
+ ```PowerShell
99
+ # save the password to make for easy connections
100
+ $password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
101
+ $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
102
+
103
+ $show = 'All'
104
+ $checks = 'RecoveryModel' # <-- change this to your new check name
105
+
106
+ $sqlinstances = 'localhost,7401', 'localhost,7402', 'localhost,7403'
107
+ #$sqlinstances = 'dbachecks1', 'dbachecks2', 'dbachecks3' # need client aliases for this to work New-DbaClientAlias
108
+
109
+ # Run v5 checks
110
+ $v5code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $false -Show $show -PassThru -Verbose
111
+ ```
112
+
113
+ 1. If you are working on the v4 --> v5 upgrade you can also confirm your v5 test results match v4 with the following
114
+ ```PowerShell
115
+ # save the password to make for easy connections
116
+ $password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
117
+ $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
118
+
119
+ $show = 'All'
120
+ $checks = 'RecoveryModel' # <-- change this to your new check name
121
+
122
+ $sqlinstances = 'localhost,7401', 'localhost,7402', 'localhost,7403'
123
+ #$sqlinstances = 'dbachecks1', 'dbachecks2', 'dbachecks3' # need client aliases for this to work New-DbaClientAlias
124
+
125
+ # Check results of the tests - are we testing the same things with the same results for v4 & v5
126
+ Invoke-PerfAndValidateCheck -SQLInstances $sqlinstances -Checks $Checks
127
+ # Include the specific details for the perf testing
128
+ Invoke-PerfAndValidateCheck -SQLInstances $sqlinstances -Checks $Checks -PerfDetail
129
+ # Include the test results - this helps troubleshooting if your tests aren't the same
130
+ Invoke-PerfAndValidateCheck -SQLInstances $sqlinstances -Checks $Checks -showTestResults
131
+ ```
132
+
133
+ 1. Once you are happy with your code, push your branch to GitHub and create a PR against the dbachecks repo.
134
+
135
+ 1. Thanks!
136
+
137
+ ### Rebuild your devcontainer
67
138
68
139
The only way to properly rebuild to ensure that all volumes etc are removed is to open up a console
69
140
or PowerShell window outside of the devcontainer and run the following:
0 commit comments