-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test the output of ScubaGear's basic commands #1538
base: main
Are you sure you want to change the base?
Changes from 87 commits
24bbb46
67317a3
09af0f3
761cb7d
f759803
728a3b1
86bf6ad
c7849ce
bca5ab6
a3be6fa
4796791
450f730
9291a42
c3cea2f
a458ca0
96b0ae5
81e04bd
3eb395d
3aba2ce
ebe759d
f994d30
c969105
b20fbdd
869ffbc
27f9eb2
1601fde
9c8116d
f0978d0
0a02517
899891f
685fefc
ccfd135
df841eb
3d1d456
2a6187e
17c3e63
f9a9180
dcaf216
616231d
17681c0
de86b44
f7d2d4d
1982593
0066977
ff82f25
19d34e5
40baebb
ebf2edc
c1b1a47
3d7aadb
9980f19
d9a864c
2aca557
2dcfc03
e0dae41
bfb7293
669edbb
0db083d
5857ea4
58af250
cbceac6
a9bd4f9
0ff26aa
2f16a6a
75b4f60
28c9d76
ccb4f79
48e1f2f
f916286
dddcf1a
e781b97
687077e
14bfa3f
807b6e3
70df10e
018c959
8448962
fef328d
3928dcc
6798463
3abf71b
15067bb
9b871fe
63d7e46
06903ee
e48e6e4
810e8f7
7b5fe81
308c81e
a1d174a
12c0b44
27acd09
8213d12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,10 +52,10 @@ jobs: | |
enable-AzPSSession: true | ||
- name: Get Key Vault Info | ||
id: key-vault-info | ||
env: | ||
KEY_VAULT_INFO: ${{ secrets.KeyVaultInfo }} | ||
# Stop the workflow if logging into Azure failed. | ||
if: ${{ success() }} | ||
run: | | ||
$KeyVaultInfo = ${env:KEY_VAULT_INFO} | ConvertFrom-Json | ||
$KeyVaultInfo = ${{ secrets.KeyVaultInfo }} | ConvertFrom-Json | ||
echo "KeyVaultUrl=$($KeyVaultInfo.KeyVault.URL)" >> $env:GITHUB_OUTPUT | ||
echo "KeyVaultCertificateName=$($KeyVaultInfo.KeyVault.CertificateName)" >> $env:GITHUB_OUTPUT | ||
- name: Create Private Gallery | ||
|
@@ -65,6 +65,7 @@ jobs: | |
cd repo | ||
New-PrivateGallery -GalleryName $env:GalleryName -Trusted | ||
- name: Sign and Publish Module | ||
id: sign-publish-module | ||
run: | | ||
# Source the deploy utilities so the functions in it can be called. | ||
. repo/utils/workflow/Publish-ScubaGear.ps1 | ||
|
@@ -80,7 +81,9 @@ jobs: | |
# This publishes to a private gallery, from which we will pull in a future step. | ||
# This step helps us verify that ScubaGear is in a state where it can be | ||
# published to PSGallery. | ||
Publish-ScubaGearModule @Parameters | ||
$ModuleVersion = Publish-ScubaGearModule @Parameters | ||
Write-Output "The module version is $ModuleVersion" | ||
echo "ModuleVersion=$ModuleVersion" >> $env:GITHUB_OUTPUT | ||
- name: Test Module Publish | ||
run: | | ||
Get-Location | ||
|
@@ -98,12 +101,40 @@ jobs: | |
Invoke-Pester -Configuration $Config | ||
- name: Initialize ScubaGear | ||
run: | | ||
Install-Module -Name ScubaGear -Repository $env:GalleryName -SkipPublisherCheck | ||
# These are two of the expected output values that result from installing the module. | ||
# These checks are intended to help verify that the module installed correctly. | ||
$ExpectedName = 'ScubaGear' | ||
$ExpectedDescription = 'The Secure Cloud Business Applications (SCuBA) Gear module automates conformance testing about CISA M365 Secure Configuration Baselines.' | ||
Comment on lines
+108
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would these make more sense as env vars so they are easier to change if/when they are adjusted? Or read directly from the manifest? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The description is found in the manifest. I think it should be possible to read from it. The name is not found in the manifest, so it would need to be defined here (or possibly be read from some other file). I have no idea if using an env var make more sense. Variables are variables however you create and adjust them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a DRY thing. If we decided to change the name of the tool to ScubaSomethingElse, and it was read from the manifest then you wouldn't need to update the workflow to match. So that's why I think it makes more sense. Even if it's only for some of the things at the moment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree this is a good idea and that I should attempt to do so. I think this work should be done before approving this issue, so I am going to push this into Marlin and do it there. |
||
# The -PassThru paramaters allows us to read the output | ||
# value from Install-Module | ||
$InstallOutput = Install-Module -Name ScubaGear -Repository $env:GalleryName -SkipPublisherCheck -PassThru | ||
# Check for the expected name. | ||
if ($InstallOutput.Name -ne $ExpectedName) { | ||
Write-Output "::error::The name of the published module should be $ExpectedName" | ||
exit 1 | ||
} | ||
# Because reasons, the description has a newline character. | ||
# Strip all whitespace before comparing the descriptions. | ||
$DescriptionFixed = $InstallOutput.Description -replace "\s", "" | ||
$ExpectedFixed = $ExpectedDescription -replace "\s", "" | ||
# Check for the expected description. | ||
if ($DescriptionFixed -ne $ExpectedFixed) { | ||
Write-Output "::error::The description of the published module should be $ExpectedDescription" | ||
exit 1 | ||
} | ||
# Source the function | ||
. repo/utils/workflow/Initialize-ScubaGearForTesting.ps1 | ||
Initialize-ScubaGearForTesting | ||
# This is a manual test that simply writes the version to the console. | ||
Invoke-SCuBA -Version | ||
# This is the expected output value that results from running the module. | ||
# This check is intended to help verify that ScubaGear installed correctly. | ||
$VersionOutput = Invoke-SCuBA -Version | ||
$ExpectedVersion = "SCuBA Gear v${{ steps.sign-publish-module.outputs.ModuleVersion }}" | ||
Write-Output "The version is $VersionOutput" | ||
Write-Output "The expected version is $ExpectedVersion" | ||
if ($VersionOutput -ne $ExpectedVersion) { | ||
Write-Output "::error::The version of the published module should be $ExpectedVersion" | ||
exit 1 | ||
} | ||
Test-Path -Path "C:\Program Files\WindowsPowerShell\Modules\ScubaGear" | ||
- name: Install Selenium | ||
run: | | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure the comment lines up with the step. Since this makes the run conditional, on a fail, won't it just skip the step to get vault info, but continue running other steps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you are correct. Comment fixed.