Super quick introduction. I have altered the project to use Sampler by Gael to scaffold and later to improve the CI/CD pipeline.
I have also updated the devcontainer so that we have 3 containers 2 based on dbatools/sqlinstance and dbatools/sqlinstance2 but also a SQL2022 container with the sqlinstance objects copied into it. The default container also has GitVersion and Sampler installed as well as few other bits to make thigns easier and to save having to do the build everytime (as installing gitversion was a PITA and lengthy)
The containers are all now hosted in the dbachecks docker hub account.
What does this mean?
It means that as well as using a dev container to develop in, thus ensuring that everyone is using the same environment, we will also be using the Sampler build and test process to ensure that we are always using a clean build of the code we are writing and testing. :-)
So to develop you need to understand the following:
The code in the source directory is the code that will be built and deployed to the PowerShell Gallery. This is the directory that you will be changing the code in.
NOTE - You will get really frustrated if you alter the code in the output directory and then build it again and find it doesnt work and the code all vanished. ASK ME HOW I KNOW !!!
The code in the output directory is the code that is built by Sampler. It is in the gitignore file so that it is not committed to the repo. This is the code that you can test with the 3 SQL instances. The advantage is that the Sampler build process will create a clean environment and add the built module into the PSModulePath.
- Run
.\build.ps1 -ResolveDependency -Tasks noop
to download all required dependencies and set up the environment.
- Code in the source directory
- Save the files
- Run the build.ps1 script
- with Tasks build
./build.ps1 -Tasks build
- This will build the code and copy it to the output directory.
- with Tasks build
Once you have finished doing some coding and want to test
- With Tasks build test ./build.ps1 -Tasks build,test
- This will build the code and run the Pester Tests.
- if you have failed tests, you can
- Run Pester manually
Invoke-Pester tests
- You can check the test results in the browser by creating a html page
.\tests\extent.exe -i .\output\testResults\NUnitXml_dbachecks_v2.0.18.Linux.PSv.7.3.0.xml -o .\output\testResults\reports -r v3html
and then outside of the container ii .\output\testResults\reports\index.html # outside of container
- Fix the broken tests or add more code and rinse and repeat.