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

Only build linux musl and update CFS auth #587

Merged
merged 7 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -191,21 +192,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 @@ -655,7 +660,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
4 changes: 2 additions & 2 deletions dsc/Cargo.lock

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

28 changes: 14 additions & 14 deletions dsc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
4 changes: 2 additions & 2 deletions dsc_lib/Cargo.lock

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

49 changes: 28 additions & 21 deletions dsc_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,40 @@ name = "dsc_lib"
version = "3.0.0"
edition = "2021"

[profile.release]
strip = true
# optimize for size
opt-level = 2
# enable link time optimization to remove dead code
lto = true

[dependencies]
base64 = "0.22.1"
chrono = "0.4.26"
clap = { version = "4.5.17", features = ["derive"] }
derive_builder ="0.20.1"
indicatif = "0.17.0"
jsonschema = { version = "0.23.0", default-features = false }
linked-hash-map = "0.5.6"
num-traits = "0.2.14"
regex = "1.7.0"
base64 = "0.22"
chrono = "0.4"
clap = { version = "4.5", features = ["derive"] }
derive_builder ="0.20"
indicatif = "0.17"
jsonschema = { version = "0.23", default-features = false }
linked-hash-map = "0.5"
num-traits = "0.2"
regex = "1.11"
# reqwest = { version = "0.12.8", features = ["native-tls"], default-features = false }
schemars = { version = "0.8.12", features = ["preserve_order"] }
serde = { version = "1.0.210", features = ["derive"] }
serde_json = { version = "1.0.128", features = ["preserve_order"] }
serde_yaml = { version = "0.9.3" }
thiserror = "1.0.0"
schemars = { version = "0.8", features = ["preserve_order"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
serde_yaml = { version = "0.9" }
thiserror = "1.0"
security_context_lib = { path = "../security_context_lib" }
semver = "1.0.0"
tokio = { version = "1.40.0", features = ["full"] }
tracing = "0.1.37"
tracing-indicatif = { version = "0.3.6" }
tree-sitter = "0.24.3"
tree-sitter-rust = "0.23.0"
semver = "1.0"
tokio = { version = "1.41", features = ["full"] }
tracing = "0.1"
tracing-indicatif = { version = "0.3" }
tree-sitter = "0.24"
tree-sitter-rust = "0.23"
tree-sitter-dscexpression = { path = "../tree-sitter-dscexpression" }

[dev-dependencies]
serde_yaml = "0.9.3"
serde_yaml = "0.9"

[build-dependencies]
cc="1.1"
13 changes: 9 additions & 4 deletions osinfo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ name = "osinfo"
version = "0.1.0"
edition = "2021"

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

[dependencies]
os_info = { version = "3.7.0" }
serde = { version = "1.0.0", features = ["derive"] }
serde_json = { version = "1.0.0", features = ["preserve_order"] }
os_info = { version = "3.7" }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
2 changes: 1 addition & 1 deletion pal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ opt-level = 2
lto = true

[build-dependencies]
cc = "1.1.20"
cc = "1.1"
Loading
Loading