Skip to content
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
174 changes: 134 additions & 40 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ on:

jobs:
build:
# Guard: if this ever gets merged upstream elsewhere,
# it will be "skipped" there and won't break their CI.
if: github.repository_owner == 'SAM-BIM'
runs-on: windows-2022

Expand All @@ -21,7 +19,6 @@ jobs:
NUGET_XMLDOC_MODE: "skip"

steps:
# Checkout THIS repo into its own folder
- name: Checkout SAM_Revit_UI
uses: actions/checkout@v4
with:
Expand All @@ -47,7 +44,6 @@ jobs:
$ErrorActionPreference = 'Stop'

$org = '${{ env.ORG_NAME }}'
$repo = '${{ env.REPO_NAME }}'
$token = '${{ secrets.ORG_REPO_TOKEN }}'

function Clone-Repo([string]$name) {
Expand All @@ -57,10 +53,6 @@ jobs:
git clone --depth 1 $url $name
}

# Practical CI order:
# - build modules first
# - build SAM_UI before Revit bits
# - then build Revit 2025 + 2026 configs
$deps = @(
'SAM'
'SAM_Systems'
Expand All @@ -73,24 +65,24 @@ jobs:
'SAM_gbXML'
'SAM_GEM'
'SAM_LadybugTools'
'SAM_Solver' # private -> token needed
'SAM_Solver'
'SAM_SolarCalculator'
'SAM_Tas'
'SAM_Excel'
'SAM_SQLite'
'SAM_OpenStudio' # x64
'SAM_OpenStudio'
'SAM_Multitasker'
'SAM_UI'
'SAM_Revit'
)

foreach ($r in $deps) { Clone-Repo $r }

# Ensure build folders exist (some projects expect these paths)
New-Item -ItemType Directory -Force -Path "SAM_Windows\build" | Out-Null
New-Item -ItemType Directory -Force -Path "SAM_UI\build" | Out-Null
New-Item -ItemType Directory -Force -Path "_ci_artifacts" | Out-Null

- name: Restore + Rebuild (ordered) + Revit 2025/2026
- name: Restore + Rebuild base dependencies (ordered)
shell: powershell
run: |
$ErrorActionPreference = 'Stop'
Expand All @@ -110,7 +102,6 @@ jobs:
throw "No .sln found under: $repoName"
}

# Build order up to SAM_UI
$orderedRepos = @(
'SAM'
'SAM_Systems'
Expand All @@ -133,20 +124,10 @@ jobs:
'SAM_UI'
)

# Revit configs (build both configs for SAM_Revit + SAM_Revit_UI)
$revitItems = @(
@{ Repo='SAM_Revit'; Configuration='Release2025'; Platform='Any CPU' },
@{ Repo='SAM_Revit_UI'; Configuration='Release2025'; Platform='Any CPU' },
@{ Repo='SAM_Revit'; Configuration='Release2026'; Platform='Any CPU' },
@{ Repo='SAM_Revit_UI'; Configuration='Release2026'; Platform='Any CPU' }
)

# Platform overrides for specific solutions that actually have x64 configs
$platformOverride = @{
'SAM_OpenStudio' = 'x64'
}

# ReferencePath: keep it simple and consistent
$winBuild = (Resolve-Path 'SAM_Windows\build').Path
$uiBuild = (Resolve-Path 'SAM_UI\build').Path
$env:ReferencePath = "$winBuild;$uiBuild"
Expand All @@ -160,45 +141,158 @@ jobs:
'/p:RunPostBuildEvent=OnOutputUpdated'
)

function Msbuild-ConfigPlatform([string]$cfg, [string]$plat) {
$args = @("/p:Configuration=$cfg")
if ($plat) { $args += "/p:Platform=$plat" } # no quotes
return $args
}

function Restore-Build([string]$repoName, [string]$cfg, [string]$plat) {
$sln = Find-Solution $repoName
Write-Host ""
Write-Host "=== $repoName ==="
Write-Host "Solution: $sln"

$cfgArgs = Msbuild-ConfigPlatform $cfg $plat
$cfgArgs = @("/p:Configuration=$cfg")
if ($plat) { $cfgArgs += "/p:Platform=$plat" }

Write-Host "-> msbuild restore ($cfg | $plat)"
& msbuild $sln /t:Restore @msbuildBase @cfgArgs
if ($LASTEXITCODE -ne 0) { throw "MSBuild restore failed: $repoName ($cfg | $plat)" }

Write-Host "-> msbuild rebuild ($cfg | $plat)"
& msbuild $sln /t:Rebuild @msbuildBase @cfgArgs
if ($LASTEXITCODE -ne 0) { throw "MSBuild rebuild failed: $repoName ($cfg | $plat)" }
}

# Build non-Revit repos (Release)
foreach ($r in $orderedRepos) {
$plat = 'Any CPU'
if ($platformOverride.ContainsKey($r)) { $plat = $platformOverride[$r] }
Restore-Build $r 'Release' $plat
}

# Build Revit (Release2025/Release2026)
foreach ($it in $revitItems) {
Restore-Build $it.Repo $it.Configuration $it.Platform
- name: Build Revit 2025 and snapshot outputs
shell: powershell
run: |
$ErrorActionPreference = 'Stop'

function Find-Solution([string]$repoName) {
$expected = Join-Path $repoName "$repoName.sln"
if (Test-Path $expected) { return (Resolve-Path $expected).Path }

$rootSln = Get-ChildItem -Path $repoName -Filter *.sln -File -ErrorAction SilentlyContinue | Select-Object -First 1
if ($rootSln) { return $rootSln.FullName }

$anySln = Get-ChildItem -Path $repoName -Recurse -Filter *.sln -File -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -notmatch '\\(bin|obj|packages)\\' } |
Select-Object -First 1
if ($anySln) { return $anySln.FullName }

throw "No .sln found under: $repoName"
}

function Restore-Build([string]$repoName, [string]$cfg) {
$sln = Find-Solution $repoName
$args = @(
'/m:1'
'/nr:false'
'/v:m'
'/p:UseSharedCompilation=false'
'/p:RunPostBuildEvent=OnOutputUpdated'
"/p:Configuration=$cfg"
'/p:Platform=Any CPU'
)

& msbuild $sln /t:Restore @args
if ($LASTEXITCODE -ne 0) { throw "MSBuild restore failed: $repoName ($cfg)" }

& msbuild $sln /t:Rebuild @args
if ($LASTEXITCODE -ne 0) { throw "MSBuild rebuild failed: $repoName ($cfg)" }
}

Restore-Build 'SAM_Revit' 'Release2025'
Restore-Build 'SAM_Revit_UI' 'Release2025'

function Copy-FolderContents([string]$src, [string]$dst) {
if (-not (Test-Path $src)) {
throw "Source folder not found: $src"
}
New-Item -ItemType Directory -Force -Path $dst | Out-Null
Copy-Item (Join-Path $src '*') $dst -Recurse -Force
}

$out = "_ci_artifacts\Revit 2025"
New-Item -ItemType Directory -Force -Path $out | Out-Null
Copy-FolderContents "SAM_Revit\build" (Join-Path $out "SAM_Revit")
Copy-FolderContents "SAM_Revit_UI\build" (Join-Path $out "SAM_Revit_UI")

if (-not (Test-Path (Join-Path $out "SAM_Revit_UI\SAM.Revit.UI.dll"))) {
throw "Revit 2025 snapshot is missing SAM.Revit.UI.dll"
}

- name: Clean Revit build folders before 2026
shell: powershell
run: |
$ErrorActionPreference = 'Stop'
foreach ($p in @('SAM_Revit\build','SAM_Revit_UI\build')) {
if (Test-Path $p) { Remove-Item $p -Recurse -Force }
New-Item -ItemType Directory -Force -Path $p | Out-Null
}

- name: Build Revit 2026 and snapshot outputs
shell: powershell
run: |
$ErrorActionPreference = 'Stop'

function Find-Solution([string]$repoName) {
$expected = Join-Path $repoName "$repoName.sln"
if (Test-Path $expected) { return (Resolve-Path $expected).Path }

$rootSln = Get-ChildItem -Path $repoName -Filter *.sln -File -ErrorAction SilentlyContinue | Select-Object -First 1
if ($rootSln) { return $rootSln.FullName }

$anySln = Get-ChildItem -Path $repoName -Recurse -Filter *.sln -File -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -notmatch '\\(bin|obj|packages)\\' } |
Select-Object -First 1
if ($anySln) { return $anySln.FullName }

throw "No .sln found under: $repoName"
}

function Restore-Build([string]$repoName, [string]$cfg) {
$sln = Find-Solution $repoName
$args = @(
'/m:1'
'/nr:false'
'/v:m'
'/p:UseSharedCompilation=false'
'/p:RunPostBuildEvent=OnOutputUpdated'
"/p:Configuration=$cfg"
'/p:Platform=Any CPU'
)

& msbuild $sln /t:Restore @args
if ($LASTEXITCODE -ne 0) { throw "MSBuild restore failed: $repoName ($cfg)" }

& msbuild $sln /t:Rebuild @args
if ($LASTEXITCODE -ne 0) { throw "MSBuild rebuild failed: $repoName ($cfg)" }
}

Restore-Build 'SAM_Revit' 'Release2026'
Restore-Build 'SAM_Revit_UI' 'Release2026'

function Copy-FolderContents([string]$src, [string]$dst) {
if (-not (Test-Path $src)) {
throw "Source folder not found: $src"
}
New-Item -ItemType Directory -Force -Path $dst | Out-Null
Copy-Item (Join-Path $src '*') $dst -Recurse -Force
}

$out = "_ci_artifacts\Revit 2026"
New-Item -ItemType Directory -Force -Path $out | Out-Null
Copy-FolderContents "SAM_Revit\build" (Join-Path $out "SAM_Revit")
Copy-FolderContents "SAM_Revit_UI\build" (Join-Path $out "SAM_Revit_UI")

if (-not (Test-Path (Join-Path $out "SAM_Revit_UI\SAM.Revit.UI.dll"))) {
throw "Revit 2026 snapshot is missing SAM.Revit.UI.dll"
}

- name: Upload build folders (optional)
- name: Upload isolated Revit build outputs
uses: actions/upload-artifact@v4
with:
name: SAM_Revit_UI-build-folders
path: |
**\build\*
if-no-files-found: warn
path: _ci_artifacts/**/*
if-no-files-found: error
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public override Result Execute(ExternalCommandData commandData, ref string messa
SimulateTo = 1
};

analyticalModel = Tas.Modify.RunWorkflow(analyticalModel, workflowSettings);
analyticalModel = Analytical.UI.WPF.Modify.RunWorkflow(analyticalModel, workflowSettings);

List<Core.ISAMObject> results = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
<Reference Include="SAM.Analytical.UI">
<HintPath>..\..\..\SAM_UI\build\SAM.Analytical.UI.dll</HintPath>
</Reference>
<Reference Include="SAM.Analytical.UI.WPF">
<HintPath>..\..\..\SAM_UI\build\SAM.Analytical.UI.WPF.dll</HintPath>
</Reference>
<Reference Include="SAM.Analytical.Windows">
<HintPath>..\..\..\SAM_Windows\build\SAM.Analytical.Windows.dll</HintPath>
</Reference>
Expand Down