Skip to content

Commit b7afe15

Browse files
authored
Merge branch 'main' into feature/add-delete-whatif
2 parents 5fd621b + 208f406 commit b7afe15

File tree

155 files changed

+6481
-1985
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+6481
-1985
lines changed

.cargo/config.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,3 @@ rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-arg
1818
# The following is only needed for release builds
1919
[source.crates-io]
2020
replace-with = "POWERSHELL"
21-
22-
#[target.aarch64-unknown-linux-gnu]
23-
#linker = "aarch64-linux-gnu-gcc"
24-
25-
#[target.aarch64-unknown-linux-musl]
26-
#linker = "aarch64-linux-musl-gcc"

.github/workflows/winget.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish to Winget
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
9+
env:
10+
WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_CREATE_GITHUB_TOKEN }}
11+
12+
jobs:
13+
publish:
14+
runs-on: windows-latest # Action can only run on Windows
15+
16+
# Only submit stable releases
17+
if: ${{ !github.event.release.prerelease }}
18+
steps:
19+
- name: Publish DSC package
20+
run: |
21+
$assets = '${{ toJSON(github.event.release.assets) }}' | ConvertFrom-Json
22+
$x64ZIPInstallerUrl = $assets | Where-Object -Property name -like '*x86_64-pc-windows-msvc.zip' | Select-Object -ExpandProperty browser_download_url
23+
$arm64InstallerUrl = $assets | Where-Object -Property name -like '*aarch64-pc-windows-msvc.zip' | Select-Object -ExpandProperty browser_download_url
24+
$msixInstallerURL = $assets | Where-Object -Property name -like '*Win.msixbundle' | Select-Object -ExpandProperty browser_download_url
25+
$version = (${{ toJSON(github.event.release.tag_name) }}).Trim('v')
26+
27+
$wingetPackage = "Microsoft.DSC"
28+
29+
& curl.exe -JLO https://aka.ms/wingetcreate/latest
30+
& .\wingetcreate.exe update $wingetPackage --version $version --urls $x64ZIPInstallerUrl $arm64InstallerUrl $msixInstallerURL --submit
31+
32+

.vscode/docs.code-snippets

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
// Place your DSCv3 workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
3-
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
4-
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
5-
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
6-
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
2+
// Place your DSCv3 workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
3+
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
4+
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
5+
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
6+
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
77
// Placeholders with the same ids are connected.
88
"Configuration function template": {
99
"scope": "markdown",
@@ -140,7 +140,7 @@
140140
" </details>",
141141
""
142142
]
143-
}
143+
},
144144
"Changelog Entry Multi Item": {
145145
"scope": "markdown",
146146
"prefix": "docs-changelog-entry-multi-issue-pr",
@@ -158,7 +158,7 @@
158158
" </details>",
159159
""
160160
]
161-
}
161+
},
162162
"Changelog release heading": {
163163
"scope": "markdown",
164164
"prefix": "docs-changelog-release-heading",
@@ -173,14 +173,22 @@
173173
"[release-${1:v3.0.0-${2:alpha.5}}]: https://github.com/PowerShell/DSC/releases/tag/${1:v3.0.0-${2:alpha.5}} \"Link to the DSC ${1:v3.0.0-${2:alpha.5}} release on GitHub\"",
174174
"[compare-${1:v3.0.0-${2:alpha.5}}]: https://github.com/PowerShell/DSC/compare/v3.0.0-alpha.4...${1:v3.0.0-${2:alpha.5}}"
175175
]
176-
177-
}
176+
},
178177
"Github Work Item Link": {
179178
"scope": "markdown",
180179
"prefix": "docs-gh-link",
181180
"description": "Template for a DSC Github work item link",
182181
"body": [
183182
"[#${1:work item id}]: https://github.com/PowerShell/DSC/issues/${1:work item id}"
184183
]
185-
}
184+
},
185+
"RFC table entry": {
186+
"scope": "markdown",
187+
"prefix": "rfc-table-entry",
188+
"description": "Template for an entry in the RFC History table",
189+
"body": [
190+
"| RFC${1:NNNN} | ${2:Title} | ${3|Accepted,Rejected,Final|} | ${4:#123} |"
191+
]
192+
},
193+
186194
}

build.ps1

Lines changed: 56 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,26 @@ param(
1515
[switch]$GetPackageVersion,
1616
[switch]$SkipLinkCheck,
1717
[switch]$UseX64MakeAppx,
18-
[switch]$UseCratesIO,
18+
[switch]$UseCFS,
1919
[switch]$UpdateLockFile,
2020
[switch]$Audit,
2121
[switch]$UseCFSAuth,
2222
[switch]$Clean,
2323
[switch]$Verbose
2424
)
2525

26-
$env:RUSTC_LOG=$null
27-
$env:RUSTFLAGS='-Dwarnings'
28-
$usingADO = ($null -ne $env:TF_BUILD)
29-
3026
trap {
3127
Write-Error "An error occurred: $($_ | Out-String)"
3228
exit 1
3329
}
3430

31+
$env:RUSTC_LOG=$null
32+
$env:RUSTFLAGS='-Dwarnings'
33+
$usingADO = ($null -ne $env:TF_BUILD)
34+
if ($usingADO -or $UseCFSAuth) {
35+
$UseCFS = $true
36+
}
37+
3538
if ($Verbose) {
3639
$env:RUSTC_LOG='rustc_codegen_ssa::back::link=info'
3740
}
@@ -164,13 +167,44 @@ if ($null -ne (Get-Command msrustup -CommandType Application -ErrorAction Ignore
164167
}
165168
} elseif ($null -ne (Get-Command rustup -CommandType Application -ErrorAction Ignore)) {
166169
$rustup = 'rustup'
167-
} else {
168-
$rustup = 'echo'
169170
}
170171

171172
if ($null -ne $packageType) {
172173
$SkipBuild = $true
173174
} else {
175+
if ($UseCFS) {
176+
Write-Host "Using CFS for cargo source replacement"
177+
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = $null
178+
$env:CARGO_REGISTRIES_CRATESIO_INDEX = $null
179+
180+
if ($UseCFSAuth) {
181+
if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
182+
throw "Azure CLI not found"
183+
}
184+
185+
if ($null -ne (Get-Command az -ErrorAction Ignore)) {
186+
Write-Host "Getting token"
187+
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
188+
if ($LASTEXITCODE -ne 0) {
189+
Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access."
190+
} else {
191+
$header = "Bearer $accessToken"
192+
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
193+
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
194+
$env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/"
195+
}
196+
}
197+
else {
198+
Write-Warning "Azure CLI not found, proceeding with anonymous access."
199+
}
200+
}
201+
} else {
202+
# this will override the config.toml
203+
Write-Host "Setting CARGO_SOURCE_crates-io_REPLACE_WITH to 'crates-io'"
204+
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = 'CRATESIO'
205+
$env:CARGO_REGISTRIES_CRATESIO_INDEX = 'sparse+https://index.crates.io/'
206+
}
207+
174208
## Test if Rust is installed
175209
if (!$usingADO -and !(Get-Command 'cargo' -ErrorAction Ignore)) {
176210
Write-Verbose -Verbose "Rust not found, installing..."
@@ -229,7 +263,11 @@ if ($null -ne $packageType) {
229263
## Test if tree-sitter is installed
230264
if ($null -eq (Get-Command tree-sitter -ErrorAction Ignore)) {
231265
Write-Verbose -Verbose "tree-sitter not found, installing..."
232-
cargo install tree-sitter-cli --config .cargo/config.toml
266+
if ($UseCFS) {
267+
cargo install tree-sitter-cli --config .cargo/config.toml
268+
} else {
269+
cargo install tree-sitter-cli
270+
}
233271
if ($LASTEXITCODE -ne 0) {
234272
throw "Failed to install tree-sitter-cli"
235273
}
@@ -290,39 +328,6 @@ if (!$SkipBuild) {
290328
}
291329
New-Item -ItemType Directory $target -ErrorAction Ignore > $null
292330

293-
if ($UseCratesIO) {
294-
# this will override the config.toml
295-
Write-Host "Setting CARGO_SOURCE_crates-io_REPLACE_WITH to 'crates-io'"
296-
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = 'CRATESIO'
297-
$env:CARGO_REGISTRIES_CRATESIO_INDEX = 'sparse+https://index.crates.io/'
298-
} else {
299-
Write-Host "Using CFS for cargo source replacement"
300-
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = $null
301-
$env:CARGO_REGISTRIES_CRATESIO_INDEX = $null
302-
303-
if ($UseCFSAuth) {
304-
if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
305-
throw "Azure CLI not found"
306-
}
307-
308-
if ($null -ne (Get-Command az -ErrorAction Ignore)) {
309-
Write-Host "Getting token"
310-
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
311-
if ($LASTEXITCODE -ne 0) {
312-
Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access."
313-
} else {
314-
$header = "Bearer $accessToken"
315-
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
316-
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
317-
$env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/"
318-
}
319-
}
320-
else {
321-
Write-Warning "Azure CLI not found, proceeding with anonymous access."
322-
}
323-
}
324-
}
325-
326331
# make sure dependencies are built first so clippy runs correctly
327332
$windows_projects = @("pal", "registry_lib", "registry", "reboot_pending", "wmi-adapter", "configurations/windows", 'extensions/appx')
328333
$macOS_projects = @("resources/brew")
@@ -380,7 +385,11 @@ if (!$SkipBuild) {
380385
else {
381386
if ($Audit) {
382387
if ($null -eq (Get-Command cargo-audit -ErrorAction Ignore)) {
383-
cargo install cargo-audit --features=fix --config .cargo/config.toml
388+
if ($UseCFS) {
389+
cargo install cargo-audit --features=fix --config .cargo/config.toml
390+
} else {
391+
cargo install cargo-audit --features=fix
392+
}
384393
}
385394

386395
cargo audit fix
@@ -413,7 +422,11 @@ if (!$SkipBuild) {
413422
else {
414423
if ($Audit) {
415424
if ($null -eq (Get-Command cargo-audit -ErrorAction Ignore)) {
416-
cargo install cargo-audit --features=fix --config .cargo/config.toml
425+
if ($UseCFS) {
426+
cargo install cargo-audit --features=fix --config .cargo/config.toml
427+
} else {
428+
cargo install cargo-audit --features=fix
429+
}
417430
}
418431

419432
cargo audit fix

0 commit comments

Comments
 (0)