Skip to content

Add custom central feed service to builds #425

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

Merged
merged 51 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6864058
create cargo.log files and add .npmrc for new feed
SteveL-MSFT Apr 26, 2024
5b9b6ac
add global config.toml pointing to custom feed
Apr 26, 2024
dd439e2
update gitignore
Apr 26, 2024
05756a9
update package lock
Apr 26, 2024
20edb0e
only use `powershell` CFS for official build
Apr 27, 2024
d442a99
update to auth with CFS
May 2, 2024
cedaf55
change feed
May 2, 2024
0b0825c
disable compliance for setting pkg version
May 2, 2024
6346f2a
fix rust install feed
May 2, 2024
abeba2c
specify linux rust
May 2, 2024
1dcb7ce
add faux rustup for ADO
May 3, 2024
d0dee3a
fix faux rustup
May 3, 2024
f1b8f2e
move cargo to restore phase
May 9, 2024
df63756
change rust tools URI
May 9, 2024
7356ab3
fix path of config.toml
May 9, 2024
01014b9
add service connection to auth with CFS
May 9, 2024
5732687
change how to auth with cargo feed
SteveL-MSFT May 30, 2024
9f808bf
fix bearer token
SteveL-MSFT May 30, 2024
0dd1b29
remove issecret
SteveL-MSFT May 30, 2024
cf9609d
add tracing of token
SteveL-MSFT Jun 6, 2024
19b3888
remove base64
SteveL-MSFT Jun 6, 2024
37b4665
change output
SteveL-MSFT Jun 6, 2024
6787070
change to utf8
SteveL-MSFT Jun 6, 2024
5c69773
remove trace
SteveL-MSFT Jun 7, 2024
b8d2d15
try using token
SteveL-MSFT Jun 10, 2024
0164bda
remove test
SteveL-MSFT Jun 10, 2024
6991e2e
add cargo credential provider
Jun 14, 2024
ac0beed
fix using gzip
SteveL-MSFT Jun 18, 2024
8bb8329
temp remove use of token
SteveL-MSFT Jun 18, 2024
77aa78a
remove crates override
SteveL-MSFT Jun 18, 2024
677ba85
fix creation of tar
SteveL-MSFT Jun 18, 2024
106d473
add error check
SteveL-MSFT Jun 18, 2024
fa07562
remove use of ms toolchain feed
SteveL-MSFT Jun 18, 2024
4f3947b
change rustversion
SteveL-MSFT Jun 18, 2024
8b44994
comment out rustinstaller
SteveL-MSFT Jun 18, 2024
a5df606
update config for windows-arm64 rust flags
SteveL-MSFT Jun 18, 2024
2bfeb9a
remove crate override
SteveL-MSFT Jun 19, 2024
45b0945
remove linker
SteveL-MSFT Jun 19, 2024
7bf8b9f
move getting token before installing rust
SteveL-MSFT Jun 19, 2024
c718ad8
remove feed override during install of rust
SteveL-MSFT Jun 19, 2024
cde17c0
add more tracing and add back redirecting of registry
SteveL-MSFT Jun 19, 2024
feeb04f
inject cred provider
SteveL-MSFT Jun 19, 2024
9eec202
put linux rust install first
SteveL-MSFT Jun 20, 2024
0960892
change back to install rust first, add tracing to config.toml
SteveL-MSFT Jun 20, 2024
d8629be
fix typo for cred providers
SteveL-MSFT Jun 20, 2024
a8dee48
change declaration of cred provider to toml file
SteveL-MSFT Jun 20, 2024
a0ccd35
remove unused redirect of crates
SteveL-MSFT Jun 20, 2024
50f1def
disable checks for publishing job
SteveL-MSFT Jun 20, 2024
cb896c4
remove including psdsc as part of package
SteveL-MSFT Jun 20, 2024
04faa65
Merge branch 'main' into cfs
SteveL-MSFT Jun 22, 2024
739a66b
Merge branch 'main' into cfs
SteveL-MSFT Jul 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# CFS/ADO crate feed is currently only working with unstable features.
[unstable]
registry-auth = true

[registries]
powershell = { index = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/Cargo/index/" }

# Enable Control Flow Guard (needed for OneBranch's post-build analysis).
[target.x86_64-pc-windows-msvc]
rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE /CETCOMPAT"]

[target.aarch64-windows-msvc]
rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE"]
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Cargo.lock
target
bin/
.DS_Store
Expand All @@ -10,4 +9,3 @@ node_modules/
tree-sitter-dscexpression/bindings/
tree-sitter-dscexpression/src/
tree-sitter-dscexpression/parser.*
tree-sitter-dscexpression/binding.gyp
141 changes: 134 additions & 7 deletions .pipelines/DSC-Official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ extends:
repoRoot: $(Build.SourcesDirectory)\DSC
ob_sdl_tsa_configFile: $(Build.SourcesDirectory)\DSC\.config\tsaoptions.json
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
ob_sdl_sbom_enabled: false
ob_signing_setup_enabled: false
ob_sdl_codeql_compiled_enabled: false
steps:
- checkout: self
- pwsh: |
Expand Down Expand Up @@ -92,37 +95,66 @@ extends:
signSrcPath: '$(Build.SourcesDirectory)\out'
ob_sdl_sbom_enabled: true
ob_signing_setup_enabled: true
ob_sdl_codeql_compiled_enabled: false
ob_sdl_codeql_compiled_enabled: true
pool:
type: windows
displayName: BuildWin
steps:
- checkout: self
env:
env:
ob_restore_phase: true
- task: CodeQL3000Init@0 # Add CodeQL Init task right before your 'Build' step.
inputs:
Enabled: true
AnalyzeInPipeline: true
Language: rust
env:
env:
ob_restore_phase: true
- pwsh: |
$tmpdir = "$(Agent.TempDirectory)"
Write-Host "##vso[task.setvariable variable=CARGO_TARGET_DIR;]$tmpdir"
displayName: 🛠️ Workaround for the LoadLibrary ACCESS_VIOLATION OneBranch issue
env:
env:
ob_restore_phase: true
- task: RustInstaller@1
inputs:
rustVersion: ms-stable
toolchainFeed: https://pkgs.dev.azure.com/mscodehub/Rust/_packaging/Rust/nuget/v3/index.json
additionalTargets: $(buildName)
displayName: Install Rust
env:
ob_restore_phase: true
- task: AzureCLI@2
inputs:
azureSubscription: az-PowerShell-feed-ingestion
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv

# Set the access token as a secret, so it doesn't get leaked in the logs
Write-Host "##vso[task.setsecret]$accessToken"
$header = "Bearer $accessToken"
Write-Host "##vso[task.setvariable variable=CARGO_REGISTRIES_POWERSHELL_TOKEN]$header"
displayName: 'Get Azure DevOps Token'
env:
ob_restore_phase: true
- pwsh: |
Set-Location "$(Build.SourcesDirectory)/DSC"
Write-Host "Use 'powershell' CFS"
Add-Content -Path "./.cargo/config.toml" -Value '[source.crates-io]'
Add-Content -Path "./.cargo/config.toml" -Value 'replace-with = "powershell"'
Add-Content -Path "./.cargo/config.toml" -Value '[registry]'
Add-Content -Path "./.cargo/config.toml" -Value 'global-credential-providers = ["cargo:token"]'

./build.ps1 -Release -Architecture $(buildName) -SkipLinkCheck
displayName: 'Build $(buildName)'
env:
env:
ob_restore_phase: true
condition: succeeded()
- task: CodeQL3000Finalize@0 # Add CodeQL Finalize task right after your 'Build' step.
condition: always()
env:
env:
ob_restore_phase: true
- pwsh: |
$null = New-Item -ItemType Directory -Path "$(PackageRoot)" -ErrorAction Ignore
Expand All @@ -137,7 +169,7 @@ extends:
write-host 'Binaries in $(signSrcPath)'
dir -r "$(signSrcPath)"
displayName: Copy built binaries
env:
env:
ob_restore_phase: true
condition: succeeded()
- task: onebranch.pipeline.signing@1
Expand Down Expand Up @@ -201,6 +233,9 @@ extends:
signOutPath: $[ dependencies.BuildWin.outputs['signOutPath.signOutPath'] ]
ob_sdl_tsa_configFile: $(Build.SourcesDirectory)\DSC\.config\tsaoptions.json
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
ob_sdl_sbom_enabled: false
ob_signing_setup_enabled: false
ob_sdl_codeql_compiled_enabled: false
pool:
type: windows
steps:
Expand All @@ -220,7 +255,36 @@ extends:
pool:
type: linux
steps:
- task: RustInstaller@1
inputs:
rustVersion: ms-stable
toolchainFeed: https://pkgs.dev.azure.com/mscodehub/Rust/_packaging/Rust/nuget/v3/index.json
additionalTargets: x86_64-unknown-linux-gnu
displayName: Install Rust
env:
ob_restore_phase: true
- task: AzureCLI@2
inputs:
azureSubscription: az-PowerShell-feed-ingestion
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv

# Set the access token as a secret, so it doesn't get leaked in the logs
Write-Host "##vso[task.setsecret]$accessToken"
$header = "Bearer $accessToken"
Write-Host "##vso[task.setvariable variable=CARGO_REGISTRIES_POWERSHELL_TOKEN]$header"
displayName: 'Get Azure DevOps Token'
env:
ob_restore_phase: true
- pwsh: |
Write-Host "Use 'powershell' CFS"
Add-Content -Path "./.cargo/config.toml" -Value '[source.crates-io]'
Add-Content -Path "./.cargo/config.toml" -Value 'replace-with = "powershell"'
Add-Content -Path "./.cargo/config.toml" -Value '[registry]'
Add-Content -Path "./.cargo/config.toml" -Value 'global-credential-providers = ["cargo:token"]'

./build.ps1 -Release -Architecture x86_64-unknown-linux-gnu
./build.ps1 -PackageType tgz -Architecture x86_64-unknown-linux-gnu -Release
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
Expand All @@ -237,7 +301,36 @@ extends:
type: linux
hostArchitecture: arm64
steps:
- task: RustInstaller@1
inputs:
rustVersion: ms-stable
toolchainFeed: https://pkgs.dev.azure.com/mscodehub/Rust/_packaging/Rust/nuget/v3/index.json
additionalTargets: aarch64-unknown-linux-gnu
displayName: Install Rust
env:
ob_restore_phase: true
- task: AzureCLI@2
inputs:
azureSubscription: az-PowerShell-feed-ingestion
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv

# Set the access token as a secret, so it doesn't get leaked in the logs
Write-Host "##vso[task.setsecret]$accessToken"
$header = "Bearer $accessToken"
Write-Host "##vso[task.setvariable variable=CARGO_REGISTRIES_POWERSHELL_TOKEN]$header"
displayName: 'Get Azure DevOps Token'
env:
ob_restore_phase: true
- pwsh: |
Write-Host "Use 'powershell' CFS"
Add-Content -Path "./.cargo/config.toml" -Value '[source.crates-io]'
Add-Content -Path "./.cargo/config.toml" -Value 'replace-with = "powershell"'
Add-Content -Path "./.cargo/config.toml" -Value '[registry]'
Add-Content -Path "./.cargo/config.toml" -Value 'global-credential-providers = ["cargo:token"]'

./build.ps1 -Release -Architecture aarch64-unknown-linux-gnu
./build.ps1 -PackageType tgz -Architecture aarch64-unknown-linux-gnu -Release
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
Expand All @@ -262,7 +355,41 @@ extends:
macOS arm64:
buildName: aarch64-apple-darwin
steps:
- task: RustInstaller@1
inputs:
rustVersion: ms-stable
toolchainFeed: https://pkgs.dev.azure.com/mscodehub/Rust/_packaging/Rust/nuget/v3/index.json
additionalTargets: $(buildName)
displayName: Install Rust
env:
ob_restore_phase: true
- task: AzureCLI@2
inputs:
azureSubscription: az-PowerShell-feed-ingestion
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv

# Set the access token as a secret, so it doesn't get leaked in the logs
Write-Host "##vso[task.setsecret]$accessToken"
$header = "Bearer $accessToken"
Write-Host "##vso[task.setvariable variable=CARGO_REGISTRIES_POWERSHELL_TOKEN]$header"
displayName: 'Get Azure DevOps Token'
env:
ob_restore_phase: true
- pwsh: |
Write-Host "Use 'powershell' CFS"
Add-Content -Path "./.cargo/config.toml" -Value '[source.crates-io]'
Add-Content -Path "./.cargo/config.toml" -Value 'replace-with = "powershell"'
Add-Content -Path "./.cargo/config.toml" -Value '[registry]'
Add-Content -Path "./.cargo/config.toml" -Value 'global-credential-providers = ["cargo:token"]'

$c = get-content "./.cargo/config.toml" | Out-String
Write-Host $c

$env:CARGO_HTTP_DEBUG=true
$env:CARGO_LOG='network=trace'
./build.ps1 -Release -Architecture $(buildName)
./build.ps1 -PackageType tgz -Architecture $(buildName) -Release
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
Expand Down
32 changes: 22 additions & 10 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ $filesForWindowsPackage = @(
'assertion.dsc.resource.json',
'group.dsc.resource.json',
'powershell.dsc.resource.json',
'PSDesiredStateConfiguration/',
'psDscAdapter/',
'reboot_pending.dsc.resource.json',
'reboot_pending.resource.ps1',
Expand Down Expand Up @@ -87,6 +86,12 @@ function Find-LinkExe {
}
}

if ($null -ne (Get-Command rustup -ErrorAction Ignore)) {
$rustup = 'rustup'
} else {
$rustup = 'echo'
}

if ($null -ne $packageType) {
$SkipBuild = $true
} else {
Expand All @@ -112,7 +117,7 @@ if ($null -ne $packageType) {

$BuildToolsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC"

rustup default stable
& $rustup default stable
}

if (!$SkipBuild -and !$SkipLinkCheck -and $IsWindows -and !(Get-Command 'link.exe' -ErrorAction Ignore)) {
Expand Down Expand Up @@ -153,7 +158,7 @@ if ($architecture -eq 'current') {
$target = Join-Path $PSScriptRoot 'bin' $configuration
}
else {
rustup target add $architecture
& $rustup target add $architecture
$flags += '--target'
$flags += $architecture
$path = ".\target\$architecture\$configuration"
Expand Down Expand Up @@ -192,9 +197,6 @@ if (!$SkipBuild) {

if ($IsWindows) {
$projects += $windows_projects
Save-Module -Path $target -Name 'PSDesiredStateConfiguration' -RequiredVersion '2.0.7' -Repository PSGallery -Force
# Need to unhide all the files so that packaging works
Get-ChildItem -Path $target -Recurse -Hidden | ForEach-Object { $_.Attributes = 'Normal' }
}

if ($IsMacOS) {
Expand Down Expand Up @@ -562,10 +564,20 @@ if ($packageType -eq 'msixbundle') {
}
}

$packageName = "DSC-$productVersion-$architecture.tar.gz"
$tgzFile = Join-Path $PSScriptRoot 'bin' $packageName
tar cvf $tgzFile -C $tgzTarget .
Write-Host -ForegroundColor Green "`nTgz file is created at $tgzFile"
$packageName = "DSC-$productVersion-$architecture.tar"
$tarFile = Join-Path $PSScriptRoot 'bin' $packageName
tar cvf $tarFile -C $tgzTarget .
if ($LASTEXITCODE -ne 0) {
throw "Failed to create tar file"
}
Write-Host -ForegroundColor Green "`nTar file is created at $tarFile"

$gzFile = "$tarFile.gz"
gzip -c $tarFile > $gzFile
if ($LASTEXITCODE -ne 0) {
throw "Failed to create gz file"
}
Write-Host -ForegroundColor Green "`nGz file is created at $gzFile"
}

$env:RUST_BACKTRACE=1
Loading
Loading