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

Default build to using CFS and include musl #513

Merged
merged 37 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1f243c8
enable use of custom token
Jul 31, 2024
1cb1ff9
fix task
Jul 31, 2024
6d2b21e
write out token
Jul 31, 2024
e4ed5d7
change param default vaule
Jul 31, 2024
897844a
add tracing
Jul 31, 2024
cedd268
default to CFS, add -useCratesIO to override, move into build.ps1
Aug 1, 2024
784ed93
change casing of powershell registry
Aug 1, 2024
292593a
add musl build
Aug 14, 2024
7d21698
change to ubuntu and install musl tools
Aug 14, 2024
d9d89e0
change to apt
Aug 14, 2024
9b9ff9c
switch to tdnf
Aug 14, 2024
dcdb76a
add llvm to path
Aug 14, 2024
8efb2b6
specify vmimage
Aug 14, 2024
6183222
use windows-latest vmimage
Aug 14, 2024
21f717f
add pool type
Aug 14, 2024
d496551
change to use specific onebranch images
Aug 14, 2024
81ab095
add host version
Aug 14, 2024
a027c10
switch back to apt
Aug 14, 2024
09ac379
explicitly install aarch64 gcc and set ubuntu image
Aug 14, 2024
e4288ff
update container image
Aug 14, 2024
46e1870
remove host architecture
Aug 14, 2024
7b7c6e2
update build to perform npm install
Aug 14, 2024
47d2ad5
add specific linker for aarch64 linux
Aug 15, 2024
54d576f
set env vars for arm64 musl build
Aug 15, 2024
656d494
add tracing of VCINSTALLDIR
Aug 15, 2024
4acf681
set default toolchain for arm64-musl
Aug 15, 2024
abe1477
fix typo
Aug 15, 2024
a2dbc56
explicit install llvm
Aug 15, 2024
cfb9d48
update vs path
Aug 15, 2024
eb8e20f
add year to vs folder
Aug 15, 2024
925c9a2
add enterprise to path
Aug 15, 2024
f44d4ea
search for clang
Aug 15, 2024
2e105cc
use vswhere
Aug 15, 2024
25eab2b
add llvm path
Aug 15, 2024
d203fbd
fix test-path usage
Aug 15, 2024
2da92bc
update crate versions and lock files
Aug 15, 2024
b9540a9
fix process due to changes in sysinfo crate
Aug 15, 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
10 changes: 8 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
registry-auth = true

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

[registry]
global-credential-providers = ["cargo:token"]
Expand All @@ -17,4 +17,10 @@ rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-arg

# The following is only needed for release builds
[source.crates-io]
replace-with = "powershell"
replace-with = "POWERSHELL"

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
16 changes: 16 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ jobs:
shell: pwsh
run: ./build.ps1 -test

build-musl:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- run: rustup target add x86_64-unknown-linux-musl
- name: Install musl build tools
run: sudo apt update && sudo apt install musl-tools -y
- name: Build
shell: pwsh
run: ./build.ps1 -clippy -target x86_64-unknown-linux-musl
- name: Run tests
shell: pwsh
run: ./build.ps1 -test -target x86_64-unknown-linux-musl

build-windows:

runs-on: windows-latest
Expand Down
148 changes: 76 additions & 72 deletions .pipelines/DSC-Official.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
name: DSC-Release-$(Build.BuildId)
trigger: none

parameters:
- name: 'debugConsole'
displayName: 'Enable debug console'
type: boolean
default: false

pr:
branches:
include:
Expand All @@ -16,8 +10,9 @@ pr:
variables:
BuildConfiguration: 'release'
PackageRoot: '$(System.ArtifactsDirectory)/Packages'
LinuxContainerImage: 'mcr.microsoft.com/onebranch/cbl-mariner/build:2.0'
WindowsContainerImage: onebranch.azurecr.io/windows/ltsc2019/vse2022:latest
# LinuxContainerImage: 'mcr.microsoft.com/onebranch/cbl-mariner/build:2.0'
LinuxContainerImage: 'onebranch.azurecr.io/linux/ubuntu-2204:latest'
WindowsContainerImage: 'onebranch.azurecr.io/windows/ltsc2022/vse2022:latest'

resources:
repositories:
Expand All @@ -30,7 +25,9 @@ extends:
template: v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates
parameters:
featureFlags:
debugConsole: ${{ parameters.debugConsole }}
WindowsHostVersion:
Disk: Large
Version: 2022
customTags: 'ES365AIMigrationTooling'
globalSdl:
disableLegacyManifest: true
Expand Down Expand Up @@ -60,6 +57,7 @@ extends:
displayName: Set PackageVersion
pool:
type: windows
vmImage: windows-latest
variables:
repoRoot: $(Build.SourcesDirectory)\DSC
ob_sdl_tsa_configFile: $(Build.SourcesDirectory)\DSC\.config\tsaoptions.json
Expand Down Expand Up @@ -124,24 +122,15 @@ extends:
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"
./build.ps1 -Release -Architecture $(buildName) -SkipLinkCheck -UseCFS
$LLVMBIN = "$($env:PROGRAMFILES)\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\bin"
if (!(Test-Path $LLVMBIN)) {
throw "LLVM path '$LLVMBIN' does not exist"
}
$env:PATH += ";$LLVMBIN"
write-verbose -verbose (gcm clang.exe | out-string)
./build.ps1 -Release -Architecture $(buildName) -SkipLinkCheck
displayName: 'Build $(buildName)'
env:
ob_restore_phase: true
Expand Down Expand Up @@ -257,23 +246,8 @@ extends:
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: |
./build.ps1 -Release -Architecture x86_64-unknown-linux-gnu -UseCFS
./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'
Expand All @@ -287,7 +261,6 @@ extends:
displayName: Linux-ARM64-gnu
pool:
type: linux
hostArchitecture: arm64
steps:
- task: RustInstaller@1
inputs:
Expand All @@ -297,26 +270,69 @@ extends:
displayName: Install Rust
env:
ob_restore_phase: true
- task: AzureCLI@2
- pwsh: |
apt -y install gcc-aarch64-linux-gnu
./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
variables:
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
displayName: Linux-x64-musl
pool:
type: linux
steps:
- task: RustInstaller@1
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
rustVersion: ms-stable
toolchainFeed: https://pkgs.dev.azure.com/mscodehub/Rust/_packaging/Rust/nuget/v3/index.json
additionalTargets: x86_64-unknown-linux-musl
displayName: Install Rust
env:
ob_restore_phase: true
- pwsh: |
apt -y install musl-tools
./build.ps1 -Release -Architecture x86_64-unknown-linux-musl
./build.ps1 -PackageType tgz -Architecture x86_64-unknown-linux-musl -Release
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
displayName: 'Build x86_64-unknown-linux-musl'
condition: succeeded()

# 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'
- job: BuildLinuxArm64Musl
dependsOn: SetPackageVersion
variables:
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
displayName: Linux-ARM64-musl
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: aarch64-unknown-linux-musl
displayName: Install Rust
env:
ob_restore_phase: true
- pwsh: |
./build.ps1 -Release -Architecture aarch64-unknown-linux-gnu -UseCFS
./build.ps1 -PackageType tgz -Architecture aarch64-unknown-linux-gnu -Release
$env:CC_aarch64_unknown_linux_musl='clang'
$env:AR_aarch64_unknown_linux_musl='llvm-ar'
$env:CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld"
apt -y install clang
apt -y install llvm
apt -y install musl-tools
apt -y install gcc-multilib
rustup default stable-aarch64-unknown-linux-musl
./build.ps1 -Release -Architecture aarch64-unknown-linux-musl
./build.ps1 -PackageType tgz -Architecture aarch64-unknown-linux-musl -Release
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
displayName: 'Build aarch64-unknown-linux-gnu'
displayName: 'Build aarch64-unknown-linux-musl'
condition: succeeded()

- job: BuildMac
Expand Down Expand Up @@ -345,23 +361,8 @@ extends:
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: |
./build.ps1 -Release -Architecture $(buildName) -UseCFS
./build.ps1 -Release -Architecture $(buildName)
./build.ps1 -PackageType tgz -Architecture $(buildName) -Release
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
Write-Host "##vso[artifact.upload containerfolder=release;artifactname=release]$(ob_outputDirectory)/DSC-$(PackageVersion)-$(buildName).tar.gz"
Expand All @@ -372,6 +373,9 @@ extends:
dependsOn: BuildAndSign
variables:
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
ob_sdl_sbom_enabled: false
ob_signing_setup_enabled: false
ob_sdl_codeql_compiled_enabled: false
drop: $(Pipeline.Workspace)/drop_build_main
jobs:
- job: Validation
Expand Down
23 changes: 20 additions & 3 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ param(
[switch]$GetPackageVersion,
[switch]$SkipLinkCheck,
[switch]$UseX64MakeAppx,
[switch]$UseCFS
[switch]$UseCratesIO
)

if ($GetPackageVersion) {
Expand Down Expand Up @@ -168,7 +168,7 @@ if (!$SkipBuild) {
}
New-Item -ItemType Directory $target -ErrorAction Ignore > $null

if (!$UseCFS) {
if ($UseCratesIO) {
# this will override the config.toml
Write-Host "Setting CARGO_SOURCE_crates-io_REPLACE_WITH to 'crates-io'"
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = 'CRATESIO'
Expand All @@ -177,11 +177,28 @@ if (!$SkipBuild) {
Write-Host "Using CFS for cargo source replacement"
${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 ($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'
}
}
}

# make sure dependencies are built first so clippy runs correctly
$windows_projects = @("pal", "registry", "reboot_pending", "wmi-adapter")

$macOS_projects = @("resources/brew")
$linux_projects = @("resources/apt")

Expand Down
Loading
Loading