Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/PowerShell/DSC into issue_282
Browse files Browse the repository at this point in the history
  • Loading branch information
anmenaga committed Oct 31, 2024
2 parents 65702f4 + c209290 commit 5979505
Show file tree
Hide file tree
Showing 18 changed files with 262 additions and 163 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ env:
CARGO_TERM_COLOR: always

jobs:
build-linux:
# build-linux:

runs-on: ubuntu-latest
# runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build
shell: pwsh
run: ./build.ps1 -clippy
- name: Run tests
shell: pwsh
run: ./build.ps1 -test
# steps:
# - uses: actions/checkout@v3
# - name: Build
# shell: pwsh
# run: ./build.ps1 -clippy
# - name: Run tests
# shell: pwsh
# run: ./build.ps1 -test

build-musl:
build-linux:

runs-on: ubuntu-latest

Expand Down
114 changes: 57 additions & 57 deletions .pipelines/DSC-Official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pr:
branches:
include:
- onebranch
- release*
- release/v*

schedules:
- cron: '0 3 * * 1'
Expand Down Expand Up @@ -33,7 +33,7 @@ extends:
template: v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates
parameters:
featureFlags:
WindowsHostVersion:
WindowsHostVersion:
Disk: Large
Version: 2022
Network: KS1 # note that this property is sticky so commenting out will use the previous set one
Expand All @@ -59,7 +59,7 @@ extends:
apiscan:
enabled: false

stages:
stages:
- stage: BuildAndSign
displayName: Build Native Binaries
dependsOn: []
Expand Down Expand Up @@ -225,61 +225,61 @@ extends:
displayName: 'Create msixbundle'
condition: succeeded()
- job: BuildLinux
dependsOn: SetPackageVersion
variables:
LinuxContainerImage: 'onebranch.azurecr.io/linux/ubuntu-2204:latest'
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
displayName: Linux-x64-gnu
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
- pwsh: |
./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)"
displayName: 'Build x86_64-unknown-linux-gnu'
condition: succeeded()
# - job: BuildLinux
# dependsOn: SetPackageVersion
# variables:
# LinuxContainerImage: 'onebranch.azurecr.io/linux/ubuntu-2204:latest'
# PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
# ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
# displayName: Linux-x64-gnu
# 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
# - pwsh: |
# ./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)"
# displayName: 'Build x86_64-unknown-linux-gnu'
# condition: succeeded()

- job: BuildLinuxArm64
dependsOn: SetPackageVersion
variables:
LinuxContainerImage: 'onebranch.azurecr.io/linux/ubuntu-2004-arm64:latest'
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
displayName: Linux-ARM64-gnu
pool:
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
- pwsh: |
apt update
apt -y install gcc-aarch64-linux-gnu
if ((openssl version -d) -match 'OPENSSLDIR: "(?<dir>.*?)"') {
$env:OPENSSL_LIB_DIR = $matches['dir']
}
./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)"
displayName: 'Build aarch64-unknown-linux-gnu'
condition: succeeded()
# - job: BuildLinuxArm64
# dependsOn: SetPackageVersion
# variables:
# LinuxContainerImage: 'onebranch.azurecr.io/linux/ubuntu-2004-arm64:latest'
# PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
# ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
# displayName: Linux-ARM64-gnu
# pool:
# 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
# - pwsh: |
# apt update
# apt -y install gcc-aarch64-linux-gnu
# if ((openssl version -d) -match 'OPENSSLDIR: "(?<dir>.*?)"') {
# $env:OPENSSL_LIB_DIR = $matches['dir']
# }
# ./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)"
# displayName: 'Build aarch64-unknown-linux-gnu'
# condition: succeeded()

- job: BuildLinuxMusl
dependsOn: SetPackageVersion
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"sarif-viewer.connectToGithubCodeScanning": "off",
"vscode-nmake-tools.workspaceBuildDirectories": [
"."
]
],
"azure-pipelines.1ESPipelineTemplatesSchemaFile": true
}
46 changes: 30 additions & 16 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ param(
[switch]$UseX64MakeAppx,
[switch]$UseCratesIO,
[switch]$UpdateLockFile,
[switch]$Audit
[switch]$Audit,
[switch]$UseCFSAuth
)

if ($GetPackageVersion) {
Expand Down Expand Up @@ -197,21 +198,25 @@ if (!$SkipBuild) {
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = $null
$env:CARGO_REGISTRIES_CRATESIO_INDEX = $null

if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
throw "Azure CLI not found"
}
if ($UseCFSAuth -or $null -ne $env:TF_BUILD) {
if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
throw "Azure CLI not found"
}

if ($null -ne $env:CARGO_REGISTRIES_POWERSHELL_TOKEN) {
Write-Host "Using existing token"
} else {
Write-Host "Getting token"
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
if ($LASTEXITCODE -ne 0) {
Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access."
} else {
$header = "Bearer $accessToken"
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
if ($null -ne (Get-Command az -ErrorAction Ignore)) {
Write-Host "Getting token"
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
if ($LASTEXITCODE -ne 0) {
Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access."
} else {
$header = "Bearer $accessToken"
$env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/"
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
}
}
else {
Write-Warning "Azure CLI not found, proceeding with anonymous access."
}
}
}
Expand Down Expand Up @@ -661,7 +666,16 @@ if ($packageType -eq 'msixbundle') {
}
}

$packageName = "DSC-$productVersion-$architecture.tar"
# for Linux, we only build musl as its statically linked, so we remove the musl suffix
$productArchitecture = if ($architecture -eq 'aarch64-unknown-linux-musl') {
'aarch64-linux'
} elseif ($architecture -eq 'x86_64-unknown-linux-musl') {
'x86_64-linux'
} else {
$architecture
}

$packageName = "DSC-$productVersion-$productArchitecture.tar"
$tarFile = Join-Path $PSScriptRoot 'bin' $packageName
tar cvf $tarFile -C $tgzTarget .
if ($LASTEXITCODE -ne 0) {
Expand Down
18 changes: 15 additions & 3 deletions dsc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions dsc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dsc"
version = "3.0.0-preview.11"
version = "3.0.0-rc.1"
edition = "2021"

[profile.release]
Expand All @@ -11,22 +11,22 @@ opt-level = 2
lto = true

[dependencies]
clap = { version = "4.5.17", features = ["derive"] }
clap_complete = { version = "4.5.28" }
crossterm = { version = "0.28.1" }
ctrlc = { version = "3.4.0" }
clap = { version = "4.5", features = ["derive"] }
clap_complete = { version = "4.5" }
crossterm = { version = "0.28" }
ctrlc = { version = "3.4" }
dsc_lib = { path = "../dsc_lib" }
indicatif = { version = "0.17" }
jsonschema = { version = "0.23.0", default-features = false }
path-absolutize = { version = "3.1.1" }
jsonschema = { version = "0.23", default-features = false }
path-absolutize = { version = "3.1" }
# reqwest = { version = "0.12.8", features = ["native-tls"], default-features = false }
schemars = { version = "0.8.12" }
serde = { version = "1.0.210", features = ["derive"] }
serde_json = { version = "1.0.128", features = ["preserve_order"] }
serde_yaml = { version = "0.9.3" }
schemars = { version = "0.8" }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
serde_yaml = { version = "0.9" }
syntect = { version = "5.0", features = ["default-fancy"], default-features = false }
sysinfo = { version = "0.32.0" }
thiserror = "1.0.52"
sysinfo = { version = "0.32" }
thiserror = "1.0"
tracing = { version = "0.1.37" }
tracing-subscriber = { version = "0.3.17", features = ["ansi", "env-filter", "json"] }
tracing-indicatif = { version = "0.3.6" }
tracing-subscriber = { version = "0.3", features = ["ansi", "env-filter", "json"] }
tracing-indicatif = { version = "0.3" }
16 changes: 14 additions & 2 deletions dsc_lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5979505

Please sign in to comment.