|
| 1 | +name: CI |
| 2 | + |
| 3 | +# Runs on every push to any branch and on every pull request. |
| 4 | +# Builds PowerMeter.exe (Release x64) and both ACSIL DLLs, then runs |
| 5 | +# smoke tests to verify the binaries are valid PE images and export |
| 6 | +# the expected entry points. |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: ["**"] |
| 11 | + tags-ignore: ["v*"] # releases are handled by release.yml |
| 12 | + pull_request: |
| 13 | + branches: ["**"] |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ci-${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + # --------------------------------------------------------------------------- |
| 21 | + build-overlay: |
| 22 | + name: Build PowerMeter.exe |
| 23 | + runs-on: windows-latest |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Add MSBuild to PATH |
| 30 | + uses: microsoft/setup-msbuild@v2 |
| 31 | + |
| 32 | + - name: Build PowerMeter.exe (Release x64) |
| 33 | + run: | |
| 34 | + msbuild PowerMeter.vcxproj ` |
| 35 | + /p:Configuration=Release ` |
| 36 | + /p:Platform=x64 ` |
| 37 | + /v:minimal ` |
| 38 | + /nologo |
| 39 | +
|
| 40 | + - name: Locate PowerMeter.exe |
| 41 | + id: locate-exe |
| 42 | + shell: pwsh |
| 43 | + run: | |
| 44 | + $candidates = @( |
| 45 | + "x64\Release\PowerMeter.exe", |
| 46 | + "PowerMeter\x64\Release\PowerMeter.exe" |
| 47 | + ) |
| 48 | + $found = $candidates | Where-Object { Test-Path $_ } | Select-Object -First 1 |
| 49 | + if (-not $found) { Write-Error "PowerMeter.exe not found after build."; exit 1 } |
| 50 | + Write-Host "Found: $found" |
| 51 | + "exe_path=$found" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 52 | +
|
| 53 | + - name: Smoke test - valid AMD64 PE image |
| 54 | + shell: pwsh |
| 55 | + run: | |
| 56 | + $exe = "${{ steps.locate-exe.outputs.exe_path }}" |
| 57 | + $bytes = [System.IO.File]::ReadAllBytes($exe) |
| 58 | + if ($bytes[0] -ne 0x4D -or $bytes[1] -ne 0x5A) { Write-Error "Missing MZ header"; exit 1 } |
| 59 | + $peOffset = [BitConverter]::ToInt32($bytes, 0x3C) |
| 60 | + $machine = [BitConverter]::ToUInt16($bytes, $peOffset + 4) |
| 61 | + if ($machine -ne 0x8664) { Write-Error ("Not AMD64: 0x{0:X4}" -f $machine); exit 1 } |
| 62 | + $size = (Get-Item $exe).Length |
| 63 | + if ($size -lt 50KB) { Write-Error "Binary too small: $size bytes"; exit 1 } |
| 64 | + Write-Host ("PASS: AMD64 PE, {0:N0} bytes" -f $size) |
| 65 | +
|
| 66 | + - name: Upload overlay artifact |
| 67 | + uses: actions/upload-artifact@v4 |
| 68 | + with: |
| 69 | + name: PowerMeter-exe |
| 70 | + path: ${{ steps.locate-exe.outputs.exe_path }} |
| 71 | + retention-days: 7 |
| 72 | + |
| 73 | + # --------------------------------------------------------------------------- |
| 74 | + build-acsil: |
| 75 | + name: Build ACSIL DLLs |
| 76 | + runs-on: windows-latest |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: Checkout |
| 80 | + uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - name: Add MSBuild to PATH |
| 83 | + uses: microsoft/setup-msbuild@v2 |
| 84 | + |
| 85 | + - name: Download Sierra Chart ACS_Source headers |
| 86 | + shell: pwsh |
| 87 | + run: | |
| 88 | + $dest = "${{ github.workspace }}\sc_stub\ACS_Source" |
| 89 | + New-Item -ItemType Directory -Force $dest | Out-Null |
| 90 | + foreach ($f in @("sierrachart.h","SCStructures.h","SCDateTime.h")) { |
| 91 | + Invoke-WebRequest -Uri "https://www.sierrachart.com/ACS_Source/$f" ` |
| 92 | + -OutFile "$dest\$f" -UseBasicParsing |
| 93 | + Write-Host "Downloaded $f" |
| 94 | + } |
| 95 | +
|
| 96 | + - name: Build PowerMeterFeed DLL (Debug x64) |
| 97 | + run: | |
| 98 | + msbuild PowerMeterFeed.vcxproj ` |
| 99 | + /p:Configuration=Debug ` |
| 100 | + /p:Platform=x64 ` |
| 101 | + /p:SierraChartRoot="${{ github.workspace }}\sc_stub" ` |
| 102 | + /v:minimal ` |
| 103 | + /nologo |
| 104 | + working-directory: ACSIL |
| 105 | + |
| 106 | + - name: Build PowerMeterFeedJS DLL (Debug x64) |
| 107 | + run: | |
| 108 | + msbuild PowerMeterFeedJS.vcxproj ` |
| 109 | + /p:Configuration=Debug ` |
| 110 | + /p:Platform=x64 ` |
| 111 | + /p:SierraChartRoot="${{ github.workspace }}\sc_stub" ` |
| 112 | + /v:minimal ` |
| 113 | + /nologo |
| 114 | + working-directory: ACSIL |
| 115 | + |
| 116 | + - name: Smoke test - DLLs are valid AMD64 PE images |
| 117 | + shell: pwsh |
| 118 | + run: | |
| 119 | + $dlls = @( |
| 120 | + "ACSIL\bin\x64\Debug\PowerMeterFeed_64_d.dll", |
| 121 | + "ACSIL\bin\x64\Debug\PowerMeterFeedJS_64_d.dll" |
| 122 | + ) |
| 123 | + foreach ($dll in $dlls) { |
| 124 | + if (-not (Test-Path $dll)) { Write-Error "Not found: $dll"; exit 1 } |
| 125 | + $bytes = [System.IO.File]::ReadAllBytes($dll) |
| 126 | + if ($bytes[0] -ne 0x4D -or $bytes[1] -ne 0x5A) { Write-Error "Bad MZ: $dll"; exit 1 } |
| 127 | + $peOffset = [BitConverter]::ToInt32($bytes, 0x3C) |
| 128 | + $machine = [BitConverter]::ToUInt16($bytes, $peOffset + 4) |
| 129 | + if ($machine -ne 0x8664) { Write-Error ("Not AMD64: $dll (0x{0:X4})" -f $machine); exit 1 } |
| 130 | + $size = (Get-Item $dll).Length |
| 131 | + if ($size -lt 10KB) { Write-Error "Too small: $size bytes ($dll)"; exit 1 } |
| 132 | + Write-Host ("PASS: $(Split-Path $dll -Leaf) ({0:N0} bytes, AMD64)" -f $size) |
| 133 | + } |
| 134 | +
|
| 135 | + - name: Smoke test - scsf_PowerMeterFeed exported |
| 136 | + shell: pwsh |
| 137 | + run: | |
| 138 | + $dll = "ACSIL\bin\x64\Debug\PowerMeterFeed_64_d.dll" |
| 139 | + $exports = dumpbin /exports $dll 2>&1 |
| 140 | + if ($exports -notmatch "scsf_PowerMeterFeed") { |
| 141 | + Write-Error "Export 'scsf_PowerMeterFeed' not found"; Write-Host $exports; exit 1 |
| 142 | + } |
| 143 | + Write-Host "PASS: scsf_PowerMeterFeed exported" |
| 144 | +
|
| 145 | + - name: Smoke test - scsf_PowerMeterFeedJS exported |
| 146 | + shell: pwsh |
| 147 | + run: | |
| 148 | + $dll = "ACSIL\bin\x64\Debug\PowerMeterFeedJS_64_d.dll" |
| 149 | + $exports = dumpbin /exports $dll 2>&1 |
| 150 | + if ($exports -notmatch "scsf_PowerMeterFeedJS") { |
| 151 | + Write-Error "Export 'scsf_PowerMeterFeedJS' not found"; Write-Host $exports; exit 1 |
| 152 | + } |
| 153 | + Write-Host "PASS: scsf_PowerMeterFeedJS exported" |
| 154 | +
|
| 155 | + - name: Upload ACSIL artifacts |
| 156 | + uses: actions/upload-artifact@v4 |
| 157 | + with: |
| 158 | + name: ACSIL-debug-dlls |
| 159 | + path: ACSIL/bin/x64/Debug/*.dll |
| 160 | + retention-days: 7 |
| 161 | + |
| 162 | + # --------------------------------------------------------------------------- |
| 163 | + ci-passed: |
| 164 | + name: CI passed |
| 165 | + needs: [build-overlay, build-acsil] |
| 166 | + runs-on: ubuntu-latest |
| 167 | + if: always() |
| 168 | + steps: |
| 169 | + - name: Check all jobs succeeded |
| 170 | + run: | |
| 171 | + if [[ "${{ needs.build-overlay.result }}" != "success" || \ |
| 172 | + "${{ needs.build-acsil.result }}" != "success" ]]; then |
| 173 | + echo "One or more CI jobs failed." |
| 174 | + exit 1 |
| 175 | + fi |
| 176 | + echo "All CI jobs passed." |
0 commit comments