Skip to content

Commit c209290

Browse files
authored
Merge pull request #587 from SteveL-MSFT/linux-build
Only build linux musl and update CFS auth
2 parents 27fe013 + 420150e commit c209290

File tree

17 files changed

+208
-158
lines changed

17 files changed

+208
-158
lines changed

.github/workflows/rust.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ env:
1515
CARGO_TERM_COLOR: always
1616

1717
jobs:
18-
build-linux:
18+
# build-linux:
1919

20-
runs-on: ubuntu-latest
20+
# runs-on: ubuntu-latest
2121

22-
steps:
23-
- uses: actions/checkout@v3
24-
- name: Build
25-
shell: pwsh
26-
run: ./build.ps1 -clippy
27-
- name: Run tests
28-
shell: pwsh
29-
run: ./build.ps1 -test
22+
# steps:
23+
# - uses: actions/checkout@v3
24+
# - name: Build
25+
# shell: pwsh
26+
# run: ./build.ps1 -clippy
27+
# - name: Run tests
28+
# shell: pwsh
29+
# run: ./build.ps1 -test
3030

31-
build-musl:
31+
build-linux:
3232

3333
runs-on: ubuntu-latest
3434

.pipelines/DSC-Official.yml

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pr:
55
branches:
66
include:
77
- onebranch
8-
- release*
8+
- release/v*
99

1010
schedules:
1111
- cron: '0 3 * * 1'
@@ -33,7 +33,7 @@ extends:
3333
template: v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates
3434
parameters:
3535
featureFlags:
36-
WindowsHostVersion:
36+
WindowsHostVersion:
3737
Disk: Large
3838
Version: 2022
3939
Network: KS1 # note that this property is sticky so commenting out will use the previous set one
@@ -59,7 +59,7 @@ extends:
5959
apiscan:
6060
enabled: false
6161

62-
stages:
62+
stages:
6363
- stage: BuildAndSign
6464
displayName: Build Native Binaries
6565
dependsOn: []
@@ -225,61 +225,61 @@ extends:
225225
displayName: 'Create msixbundle'
226226
condition: succeeded()
227227
228-
- job: BuildLinux
229-
dependsOn: SetPackageVersion
230-
variables:
231-
LinuxContainerImage: 'onebranch.azurecr.io/linux/ubuntu-2204:latest'
232-
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
233-
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
234-
displayName: Linux-x64-gnu
235-
pool:
236-
type: linux
237-
steps:
238-
- task: RustInstaller@1
239-
inputs:
240-
rustVersion: ms-stable
241-
toolchainFeed: https://pkgs.dev.azure.com/mscodehub/Rust/_packaging/Rust/nuget/v3/index.json
242-
additionalTargets: x86_64-unknown-linux-gnu
243-
displayName: Install Rust
244-
env:
245-
ob_restore_phase: true
246-
- pwsh: |
247-
./build.ps1 -Release -Architecture x86_64-unknown-linux-gnu
248-
./build.ps1 -PackageType tgz -Architecture x86_64-unknown-linux-gnu -Release
249-
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
250-
displayName: 'Build x86_64-unknown-linux-gnu'
251-
condition: succeeded()
228+
# - job: BuildLinux
229+
# dependsOn: SetPackageVersion
230+
# variables:
231+
# LinuxContainerImage: 'onebranch.azurecr.io/linux/ubuntu-2204:latest'
232+
# PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
233+
# ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
234+
# displayName: Linux-x64-gnu
235+
# pool:
236+
# type: linux
237+
# steps:
238+
# - task: RustInstaller@1
239+
# inputs:
240+
# rustVersion: ms-stable
241+
# toolchainFeed: https://pkgs.dev.azure.com/mscodehub/Rust/_packaging/Rust/nuget/v3/index.json
242+
# additionalTargets: x86_64-unknown-linux-gnu
243+
# displayName: Install Rust
244+
# env:
245+
# ob_restore_phase: true
246+
# - pwsh: |
247+
# ./build.ps1 -Release -Architecture x86_64-unknown-linux-gnu
248+
# ./build.ps1 -PackageType tgz -Architecture x86_64-unknown-linux-gnu -Release
249+
# Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
250+
# displayName: 'Build x86_64-unknown-linux-gnu'
251+
# condition: succeeded()
252252

253-
- job: BuildLinuxArm64
254-
dependsOn: SetPackageVersion
255-
variables:
256-
LinuxContainerImage: 'onebranch.azurecr.io/linux/ubuntu-2004-arm64:latest'
257-
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
258-
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
259-
displayName: Linux-ARM64-gnu
260-
pool:
261-
type: linux
262-
hostArchitecture: arm64
263-
steps:
264-
- task: RustInstaller@1
265-
inputs:
266-
rustVersion: ms-stable
267-
toolchainFeed: https://pkgs.dev.azure.com/mscodehub/Rust/_packaging/Rust/nuget/v3/index.json
268-
additionalTargets: aarch64-unknown-linux-gnu
269-
displayName: Install Rust
270-
env:
271-
ob_restore_phase: true
272-
- pwsh: |
273-
apt update
274-
apt -y install gcc-aarch64-linux-gnu
275-
if ((openssl version -d) -match 'OPENSSLDIR: "(?<dir>.*?)"') {
276-
$env:OPENSSL_LIB_DIR = $matches['dir']
277-
}
278-
./build.ps1 -Release -Architecture aarch64-unknown-linux-gnu
279-
./build.ps1 -PackageType tgz -Architecture aarch64-unknown-linux-gnu -Release
280-
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
281-
displayName: 'Build aarch64-unknown-linux-gnu'
282-
condition: succeeded()
253+
# - job: BuildLinuxArm64
254+
# dependsOn: SetPackageVersion
255+
# variables:
256+
# LinuxContainerImage: 'onebranch.azurecr.io/linux/ubuntu-2004-arm64:latest'
257+
# PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
258+
# ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
259+
# displayName: Linux-ARM64-gnu
260+
# pool:
261+
# type: linux
262+
# hostArchitecture: arm64
263+
# steps:
264+
# - task: RustInstaller@1
265+
# inputs:
266+
# rustVersion: ms-stable
267+
# toolchainFeed: https://pkgs.dev.azure.com/mscodehub/Rust/_packaging/Rust/nuget/v3/index.json
268+
# additionalTargets: aarch64-unknown-linux-gnu
269+
# displayName: Install Rust
270+
# env:
271+
# ob_restore_phase: true
272+
# - pwsh: |
273+
# apt update
274+
# apt -y install gcc-aarch64-linux-gnu
275+
# if ((openssl version -d) -match 'OPENSSLDIR: "(?<dir>.*?)"') {
276+
# $env:OPENSSL_LIB_DIR = $matches['dir']
277+
# }
278+
# ./build.ps1 -Release -Architecture aarch64-unknown-linux-gnu
279+
# ./build.ps1 -PackageType tgz -Architecture aarch64-unknown-linux-gnu -Release
280+
# Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
281+
# displayName: 'Build aarch64-unknown-linux-gnu'
282+
# condition: succeeded()
283283

284284
- job: BuildLinuxMusl
285285
dependsOn: SetPackageVersion

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525
"sarif-viewer.connectToGithubCodeScanning": "off",
2626
"vscode-nmake-tools.workspaceBuildDirectories": [
2727
"."
28-
]
28+
],
29+
"azure-pipelines.1ESPipelineTemplatesSchemaFile": true
2930
}

build.ps1

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ param(
1515
[switch]$UseX64MakeAppx,
1616
[switch]$UseCratesIO,
1717
[switch]$UpdateLockFile,
18-
[switch]$Audit
18+
[switch]$Audit,
19+
[switch]$UseCFSAuth
1920
)
2021

2122
if ($GetPackageVersion) {
@@ -191,21 +192,25 @@ if (!$SkipBuild) {
191192
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = $null
192193
$env:CARGO_REGISTRIES_CRATESIO_INDEX = $null
193194

194-
if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
195-
throw "Azure CLI not found"
196-
}
195+
if ($UseCFSAuth -or $null -ne $env:TF_BUILD) {
196+
if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
197+
throw "Azure CLI not found"
198+
}
197199

198-
if ($null -ne $env:CARGO_REGISTRIES_POWERSHELL_TOKEN) {
199-
Write-Host "Using existing token"
200-
} else {
201-
Write-Host "Getting token"
202-
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
203-
if ($LASTEXITCODE -ne 0) {
204-
Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access."
205-
} else {
206-
$header = "Bearer $accessToken"
207-
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
208-
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
200+
if ($null -ne (Get-Command az -ErrorAction Ignore)) {
201+
Write-Host "Getting token"
202+
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
203+
if ($LASTEXITCODE -ne 0) {
204+
Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access."
205+
} else {
206+
$header = "Bearer $accessToken"
207+
$env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/"
208+
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
209+
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
210+
}
211+
}
212+
else {
213+
Write-Warning "Azure CLI not found, proceeding with anonymous access."
209214
}
210215
}
211216
}
@@ -655,7 +660,16 @@ if ($packageType -eq 'msixbundle') {
655660
}
656661
}
657662

658-
$packageName = "DSC-$productVersion-$architecture.tar"
663+
# for Linux, we only build musl as its statically linked, so we remove the musl suffix
664+
$productArchitecture = if ($architecture -eq 'aarch64-unknown-linux-musl') {
665+
'aarch64-linux'
666+
} elseif ($architecture -eq 'x86_64-unknown-linux-musl') {
667+
'x86_64-linux'
668+
} else {
669+
$architecture
670+
}
671+
672+
$packageName = "DSC-$productVersion-$productArchitecture.tar"
659673
$tarFile = Join-Path $PSScriptRoot 'bin' $packageName
660674
tar cvf $tarFile -C $tgzTarget .
661675
if ($LASTEXITCODE -ne 0) {

dsc/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dsc/Cargo.toml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ opt-level = 2
1111
lto = true
1212

1313
[dependencies]
14-
clap = { version = "4.5.17", features = ["derive"] }
15-
clap_complete = { version = "4.5.28" }
16-
crossterm = { version = "0.28.1" }
17-
ctrlc = { version = "3.4.0" }
14+
clap = { version = "4.5", features = ["derive"] }
15+
clap_complete = { version = "4.5" }
16+
crossterm = { version = "0.28" }
17+
ctrlc = { version = "3.4" }
1818
dsc_lib = { path = "../dsc_lib" }
1919
indicatif = { version = "0.17" }
20-
jsonschema = { version = "0.23.0", default-features = false }
21-
path-absolutize = { version = "3.1.1" }
20+
jsonschema = { version = "0.23", default-features = false }
21+
path-absolutize = { version = "3.1" }
2222
# reqwest = { version = "0.12.8", features = ["native-tls"], default-features = false }
23-
schemars = { version = "0.8.12" }
24-
serde = { version = "1.0.210", features = ["derive"] }
25-
serde_json = { version = "1.0.128", features = ["preserve_order"] }
26-
serde_yaml = { version = "0.9.3" }
23+
schemars = { version = "0.8" }
24+
serde = { version = "1.0", features = ["derive"] }
25+
serde_json = { version = "1.0", features = ["preserve_order"] }
26+
serde_yaml = { version = "0.9" }
2727
syntect = { version = "5.0", features = ["default-fancy"], default-features = false }
28-
sysinfo = { version = "0.32.0" }
29-
thiserror = "1.0.52"
28+
sysinfo = { version = "0.32" }
29+
thiserror = "1.0"
3030
tracing = { version = "0.1.37" }
31-
tracing-subscriber = { version = "0.3.17", features = ["ansi", "env-filter", "json"] }
32-
tracing-indicatif = { version = "0.3.6" }
31+
tracing-subscriber = { version = "0.3", features = ["ansi", "env-filter", "json"] }
32+
tracing-indicatif = { version = "0.3" }

dsc_lib/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dsc_lib/Cargo.toml

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,40 @@ name = "dsc_lib"
33
version = "3.0.0"
44
edition = "2021"
55

6+
[profile.release]
7+
strip = true
8+
# optimize for size
9+
opt-level = 2
10+
# enable link time optimization to remove dead code
11+
lto = true
12+
613
[dependencies]
7-
base64 = "0.22.1"
8-
chrono = "0.4.26"
9-
clap = { version = "4.5.17", features = ["derive"] }
10-
derive_builder ="0.20.1"
11-
indicatif = "0.17.0"
12-
jsonschema = { version = "0.23.0", default-features = false }
13-
linked-hash-map = "0.5.6"
14-
num-traits = "0.2.14"
15-
regex = "1.7.0"
14+
base64 = "0.22"
15+
chrono = "0.4"
16+
clap = { version = "4.5", features = ["derive"] }
17+
derive_builder ="0.20"
18+
indicatif = "0.17"
19+
jsonschema = { version = "0.23", default-features = false }
20+
linked-hash-map = "0.5"
21+
num-traits = "0.2"
22+
regex = "1.11"
1623
# reqwest = { version = "0.12.8", features = ["native-tls"], default-features = false }
17-
schemars = { version = "0.8.12", features = ["preserve_order"] }
18-
serde = { version = "1.0.210", features = ["derive"] }
19-
serde_json = { version = "1.0.128", features = ["preserve_order"] }
20-
serde_yaml = { version = "0.9.3" }
21-
thiserror = "1.0.0"
24+
schemars = { version = "0.8", features = ["preserve_order"] }
25+
serde = { version = "1.0", features = ["derive"] }
26+
serde_json = { version = "1.0", features = ["preserve_order"] }
27+
serde_yaml = { version = "0.9" }
28+
thiserror = "1.0"
2229
security_context_lib = { path = "../security_context_lib" }
23-
semver = "1.0.0"
24-
tokio = { version = "1.40.0", features = ["full"] }
25-
tracing = "0.1.37"
26-
tracing-indicatif = { version = "0.3.6" }
27-
tree-sitter = "0.24.3"
28-
tree-sitter-rust = "0.23.0"
30+
semver = "1.0"
31+
tokio = { version = "1.41", features = ["full"] }
32+
tracing = "0.1"
33+
tracing-indicatif = { version = "0.3" }
34+
tree-sitter = "0.24"
35+
tree-sitter-rust = "0.23"
2936
tree-sitter-dscexpression = { path = "../tree-sitter-dscexpression" }
3037

3138
[dev-dependencies]
32-
serde_yaml = "0.9.3"
39+
serde_yaml = "0.9"
3340

3441
[build-dependencies]
3542
cc="1.1"

osinfo/Cargo.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ name = "osinfo"
33
version = "0.1.0"
44
edition = "2021"
55

6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
6+
[profile.release]
7+
strip = true
8+
# optimize for size
9+
opt-level = 2
10+
# enable link time optimization to remove dead code
11+
lto = true
712

813
[dependencies]
9-
os_info = { version = "3.7.0" }
10-
serde = { version = "1.0.0", features = ["derive"] }
11-
serde_json = { version = "1.0.0", features = ["preserve_order"] }
14+
os_info = { version = "3.7" }
15+
serde = { version = "1.0", features = ["derive"] }
16+
serde_json = { version = "1.0", features = ["preserve_order"] }

pal/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ opt-level = 2
1313
lto = true
1414

1515
[build-dependencies]
16-
cc = "1.1.20"
16+
cc = "1.1"

0 commit comments

Comments
 (0)