|
1 | 1 | # Contributing
|
2 | 2 |
|
3 |
| -## TODO |
| 3 | +## Welcome |
| 4 | + |
| 5 | +Before we go any further, thanks for being here. Thanks for using dbachecks and especially thanks |
| 6 | +for being here and looking into how you can help! |
| 7 | + |
| 8 | +## Important resources |
| 9 | + |
| 10 | +- docs |
| 11 | +- bugs |
| 12 | +- communicate with the team |
| 13 | + - slack |
| 14 | + - github discussions? |
| 15 | +- presentations\blogs? |
4 | 16 |
|
5 | 17 | ## Running the Tests
|
6 | 18 |
|
7 | 19 | If want to know how to run this module's tests you can look at the [Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines/#running-tests)
|
| 20 | + |
| 21 | +## Environment details |
| 22 | + |
| 23 | +We strongly believe that 'every repo should have a devcontainer' and therefore we've built one |
| 24 | +for this project that includes 3 SQL Servers and everything you need to develop and build the |
| 25 | +dbachecks module. |
| 26 | + |
| 27 | +It's magic! |
| 28 | + |
| 29 | +### Prerequisites: |
| 30 | + |
| 31 | +In order to use the devcontainer there are a few things you need to get started. |
| 32 | + |
| 33 | +- [Docker](https://www.docker.com/get-started) |
| 34 | +- [git](https://git-scm.com/downloads) |
| 35 | +- [VSCode](https://code.visualstudio.com/download) |
| 36 | +- [Remote Development Extension for VSCode](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) |
| 37 | + |
| 38 | +### Setup |
| 39 | + |
| 40 | +Once the prerequisites are in place follow these steps to download the repo and start up the |
| 41 | +devcontainer. The first time you build the devcontainer it will need to pull down the images |
| 42 | +so that could take a hot second depending on your internet speeds. |
| 43 | + |
| 44 | +1. Download the repo from GitHub |
| 45 | + ```PowerShell |
| 46 | + # change directory to where you'd like the repo to go |
| 47 | + cd C:\GitHub\ |
| 48 | +
|
| 49 | + # clone the repo from GitHub |
| 50 | + git clone https://github.com/dataplat/dbachecks |
| 51 | +
|
| 52 | + # move into the folder |
| 53 | + cd .\dbachecks\ |
| 54 | +
|
| 55 | + # open VSCode |
| 56 | + code . |
| 57 | + ``` |
| 58 | +
|
| 59 | +754662. Once code opens, there should be a toast in the bottom right that suggests you 'ReOpen in Container'. |
| 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 |
| 61 | +
|
| 62 | +### Develop & Build |
| 63 | +
|
| 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 |
| 138 | +
|
| 139 | +The only way to properly rebuild to ensure that all volumes etc are removed is to open up a console |
| 140 | +or PowerShell window outside of the devcontainer and run the following: |
| 141 | +
|
| 142 | +```PowerShell |
| 143 | + cd \path-of-dbachecks-folder\.devcontainer |
| 144 | +
|
| 145 | + docker-compose -f "docker-compose.yml" -p "bitsdbatools_devcontainer" down |
| 146 | +``` |
| 147 | + |
| 148 | +## How to submit changes: |
| 149 | +TODO: |
| 150 | +Pull Request protocol etc. You might also include what response they'll get back from the team on submission, or any caveats about the speed of response. |
| 151 | + |
| 152 | +## How to report a bug: |
| 153 | +TODO: |
| 154 | +Bugs are problems in code, in the functionality of an application or in its UI design; you can submit them through "bug trackers" and most projects invite you to do so, so that they may "debug" with more efficiency and the input of a contributor. Take a look at Atom's example for how to teach people to report bugs to your project. |
| 155 | + |
| 156 | +## Templates: |
| 157 | +TODO: |
| 158 | +in this section of your file, you might also want to link to a bug report "template" like this one here which contributors can copy and add context to; this will keep your bugs tidy and relevant. |
| 159 | + |
| 160 | +## Style Guide |
| 161 | +TODO: |
| 162 | +include extensions and vscode settings we use to keep things neat |
| 163 | + |
| 164 | +## Code of Conduct |
| 165 | +TODO: maybe beef this out - stolen from data sat repo for now. |
| 166 | + |
| 167 | +We expect and demand that you follow some basic rules. Nothing dramatic here. There will be a proper code of conduct for the websites added soon, but in this repository |
| 168 | + |
| 169 | +BE EXCELLENT TO EACH OTHER |
| 170 | + |
| 171 | +Do I need to say more? If your behaviour or communication does not fit into this statement, we do not wish for you to help us. |
0 commit comments