Skip to content
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

Add Microsoft.Windows.Assertion Module #90

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

Trenly
Copy link
Contributor

@Trenly Trenly commented Nov 2, 2024

Premise

Until DSC v3 is released, there isn't a good way to assert specific system parameters in DSC - Especially for use with WinGet. This module adds several different DSC Resources that can be used for asserting the state of a system, primarily for use in WinGet configuration files. This will allow DSC users in enterprises to target specific architectures, specific domain roles, computers with specific print servers, etc. by adding these assertions directly into their configuration YAML instead of having to push out a wrapper script that performs the checks before invoking the DSC, and without having to write their own implementations using the Script DSCResource.


@Trenly Trenly marked this pull request as ready for review November 4, 2024 19:56
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Author-Feedback This needs a response from the author. Needs-Attention This work item needs to be reviewed by a member of the core team and removed Needs-Author-Feedback This needs a response from the author. labels Nov 5, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed Changes-Requested Changes Requested Needs-Attention This work item needs to be reviewed by a member of the core team labels Nov 5, 2024

This comment has been minimized.

@Trenly Trenly marked this pull request as draft November 5, 2024 22:29
@Trenly Trenly marked this pull request as ready for review November 5, 2024 22:47
@Trenly Trenly requested a review from ryfu-msft November 5, 2024 22:47
@Trenly Trenly marked this pull request as draft November 5, 2024 23:01
@Trenly
Copy link
Contributor Author

Trenly commented Nov 5, 2024

Didn't realize I still have scriptanalyzer errors

@Trenly Trenly marked this pull request as ready for review November 6, 2024 00:44

This comment has been minimized.

@ryfu-msft
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Trenly
Copy link
Contributor Author

Trenly commented Nov 11, 2024

Hmmmmmm

@Trenly
Copy link
Contributor Author

Trenly commented Nov 23, 2024

@ryfu-msft - I'm a bit stuck here and don't know how to go about it. When I run the pester tests locally, I see them pass -

PS E:\winget-dsc> Invoke-Pester E:\winget-dsc\tests\Microsoft.Windows.Assertion

Starting discovery in 1 files.
Discovery found 73 tests in 711ms.
Running tests.
[+] E:\winget-dsc\tests\Microsoft.Windows.Assertion\Microsoft.Windows.Assertion.Tests.ps1 5.3s (3.8s|814ms)
Tests completed in 5.33s
Tests Passed: 73, Failed: 0, Skipped: 0, Inconclusive: 0, NotRun: 0
PS E:\winget-dsc> $env:COMPUTERNAME
CORSAIR-JLU545

I even went to a completely different computer, checked out the repo, and ran the tests, where they all passed.

PS C:\git\winget-dsc> Invoke-Pester C:\git\winget-dsc\tests\Microsoft.Windows.Assertion

Starting discovery in 1 files.
Discovery found 73 tests in 510ms.
Running tests.
[+] C:\git\winget-dsc\tests\Microsoft.Windows.Assertion\Microsoft.Windows.Assertion.Tests.ps1 17.3s (16.44s|347ms)      
Tests completed in 17.3s
Tests Passed: 73, Failed: 0, Skipped: 0, Inconclusive: 0, NotRun: 0
PS C:\git\winget-dsc> $env:COMPUTERNAME
M5423133

Then, I used Invoke-DSCResource to manually test, and everything passed there; Granted I did have to use valid PnPDevices that were on my system for the cases where I expected it to match, but all of the ones that I expected to not match didn't match.

As a final effort, I opened up a new Windows Sandbox, mapped in the folder from Git, installed PowerShell 7, and tried running the tests. They all passed again -

PS C:\Users\WDAGUtilityAccount> Invoke-Pester C:\Users\WDAGUtilityAccount\Desktop\winget-dsc\tests\Microsoft.Windows.Assertion\

Starting discovery in 1 files.
Discovery found 73 tests in 715ms.
Running tests.
[+] C:\Users\WDAGUtilityAccount\Desktop\winget-dsc\tests\Microsoft.Windows.Assertion\Microsoft.Windows.Assertion.Tests.ps1 11.71s (10.33s|699ms)
Tests completed in 11.73s
Tests Passed: 73, Failed: 0, Skipped: 0, Inconclusive: 0, NotRun: 0
PS C:\Users\WDAGUtilityAccount> $env:COMPUTERNAME
C1BE12D1-33D2-4

Can you help me understand why the pipelines are showing different results? Are they using a specific version of Pester?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants