Skip to content

Commit d3b866e

Browse files
Merge pull request #984 from jpomfret/contributing
Contribution.md - Add developing instructions
2 parents 148d7c5 + 9e769bd commit d3b866e

File tree

1 file changed

+75
-4
lines changed

1 file changed

+75
-4
lines changed

CONTRIBUTING.md

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Contributing
22

3-
## TODO
43
## Welcome
54

65
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.
3433
- [Docker](https://www.docker.com/get-started)
3534
- [git](https://git-scm.com/downloads)
3635
- [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)
3837

3938
### Setup
4039

@@ -61,9 +60,81 @@ so that could take a hot second depending on your internet speeds.
6160
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
6261
6362
### Develop & Build
64-
TODO: sampler instructions - similar to /workspace/developing/Howto.md
6563
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
67138
68139
The only way to properly rebuild to ensure that all volumes etc are removed is to open up a console
69140
or PowerShell window outside of the devcontainer and run the following:

0 commit comments

Comments
 (0)