Skip to content

Commit 7253e68

Browse files
committed
docs: Add information around smoke tests
1 parent fb34720 commit 7253e68

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

deploy/Invoke-SmokeTests.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# These tests run against the installed module, not the source code, so they are a real-world test and should not use mocks.
33
# Since mocks are not used, be careful to not rely on state stored on the machine, such as a module configuration file.
44
# This is a great place to put tests that differ between operating systems, since they will be ran on multiple platforms.
5+
# Keep in mind that these tests can only call the public functions in the module, not the private functions.
56
# To run these tests on your local machine, see the comments in the BeforeAll block.
67

78
BeforeAll {

docs/Contributing.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,21 @@ If you want to increment the Major or Minor version number, you have 2 options:
2323
Builds are not triggered on tags, and thus the version tag will be used as the starting point for the next version.
2424
e.g. Creating a new tag of `v2.4.0` will produce a new version of `2.4.1` on the next commit to the `main` branch.
2525

26-
## Why are the template dot-files filenames prefixed with an underscore?
26+
## 📄 Why are the template dot-files filenames prefixed with an underscore?
2727

2828
`Publish-Module` has a bug where it does not include any files or directories starting with `.` in the module NuGet package.
2929
The newer `Publish-PSResource` has fixed this issue somewhat so the directories and some of the files are included, but it still leaves out some dot-files, like the `.gitignore` and `.editorconfig` files.
3030
To work around these issues, we prefix the files with an underscore (e.g. `_.gitignore`) so that they are included in the module package, and then remove the underscore prefix during the file copy process of the `New-PowerShellScriptModuleRepository` cmdlet.
3131

32+
## 🧪 Smoke tests
33+
34+
[The Smoke tests](/deploy/Invoke-SmokeTests.ps1) are used during the CI/CD workflow to verify that the module is working as expected after it is published to the gallery.
35+
The smoke tests are ran on Windows, MacOS, and Linux agents to ensure cross-platform compatibility, as well as against a Windows PowerShell 5.1 agent to ensure backward compatibility.
36+
37+
The difference between the smoke tests and the regular tests is that the smoke tests rely on the module actually being installed, not just the files being present.
38+
This means they can only test the functions and aliases that are exported from the module manifest and publicly accessible.
39+
This is the reason why we must use different files for the smoke tests than the regular tests; regular tests can test private functions and variables, but smoke tests cannot.
40+
3241
## ⁉ Why was a specific decision made
3342

3443
Curious about some of the choices made in this project?

src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/ReadMe.md

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ If you already have the module, manifest, and tests written, replace the followi
2121

2222
Otherwise, use these files as a starting point for your new module.
2323

24+
#### Smoke tests
25+
26+
When you change the module and tests, you will also need to update [the Smoke tests](/deploy/Invoke-SmokeTests.ps1), otherwise they may fail the CI/CD workflow.
27+
See the [Contributing docs](/docs/Contributing.md) for more information on smoke tests.
28+
2429
### 🚀 Step 4: Update your CI/CD workflows
2530

2631
#### 🔑 Create a PowerShell Gallery API Key

src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/deploy/Invoke-SmokeTests.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# These tests run against the installed module, not the source code, so they are a real-world test and should not use mocks.
33
# Since mocks are not used, be careful to not rely on state stored on the machine, such as a module configuration file.
44
# This is a great place to put tests that differ between operating systems, since they will be ran on multiple platforms.
5+
# Keep in mind that these tests can only call the public functions in the module, not the private functions.
56
# To run these tests on your local machine, see the comments in the BeforeAll block.
67

78
BeforeAll {

src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md

+13
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,16 @@ If you want to increment the Major or Minor version number, you have 2 options:
1919
1. Create a new version tag and pushing it up to GitHub.
2020
Builds are not triggered on tags, and thus the version tag will be used as the starting point for the next version.
2121
e.g. Creating a new tag of `v2.4.0` will produce a new version of `2.4.1` on the next commit to the `main` branch.
22+
23+
## 🧪 Smoke tests
24+
25+
[The Smoke tests](/deploy/Invoke-SmokeTests.ps1) are used during the CI/CD workflow to verify that the module is working as expected after it is published to the gallery.
26+
The smoke tests are ran on Windows, MacOS, and Linux agents to ensure cross-platform compatibility, as well as against a Windows PowerShell 5.1 agent to ensure backward compatibility.
27+
28+
The difference between the smoke tests and the regular tests is that the smoke tests rely on the module actually being installed, not just the files being present.
29+
This means they can only test the functions and aliases that are exported from the module manifest and publicly accessible.
30+
This is the reason why we must use different files for the smoke tests than the regular tests; regular tests can test private functions and variables, but smoke tests cannot.
31+
32+
You do not need to run every public function test in the smoke tests, but it can help give you confidence that the module is truly cross-platform and backward compatible.
33+
If you do not want to run any smoke tests, you can comment out all of the code in the smoke tests file.
34+
The CI/CD workflow will still validate that the module can be installed on each platform.

0 commit comments

Comments
 (0)