Skip to content

Update build-installers.yml - #97

Merged
cj-vana merged 6 commits into
betafrom
new-pr
Sep 22, 2025
Merged

cj-vana merged 6 commits into
betafrom
new-pr

Conversation

@cj-vana

@cj-vana cj-vana commented Sep 22, 2025 •

Copy link
Copy Markdown
Collaborator

PR Type

Other


Description

  • Update NSIS installer build command with explicit path

Diagram Walkthrough

flowchart LR
  A["makensis installer.nsi"] -- "replace with" --> B["C:\Program Files (x86)\NSIS\makensis.exe installer.nsi"]
Loading

File Walkthrough

Relevant files
Configuration changes
build-installers.yml
Update NSIS installer build command                                           

.github/workflows/build-installers.yml

  • Replace makensis command with explicit path to NSIS executable
  • Use PowerShell call operator & for command execution
+1/-1     

@netlify

netlify Bot commented Sep 22, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for sounddocsbeta ready!

Name Link
🔨 Latest commit f3a8e0d
🔍 Latest deploy log https://app.netlify.com/projects/sounddocsbeta/deploys/68d1657c4318a70008c3d9d2
😎 Deploy Preview https://deploy-preview-97--sounddocsbeta.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Shell Mismatch

The step uses the PowerShell call operator '&', but the job/step appears to run under bash (previous step explicitly sets shell: bash, and this step doesn't override it). Using '&' in bash will fail. Either set shell: pwsh for this step or use a bash-compatible command.

  shell: bash

- name: Build NSIS installer
  run: |
    cd agents/capture-agent-py
    & "C:\Program Files (x86)\NSIS\makensis.exe" installer.nsi
Path Quoting

The Windows path with spaces is quoted, which is correct, but ensure invocation format matches the chosen shell. For pwsh, & "C:\Program Files (x86)\NSIS\makensis.exe" installer.nsi is fine; for bash on Windows runners, use "/c/Program Files (x86)/NSIS/makensis.exe" or call via cmd.exe.

run: |
  cd agents/capture-agent-py
  & "C:\Program Files (x86)\NSIS\makensis.exe" installer.nsi

@qodo-code-review

qodo-code-review Bot commented Sep 22, 2025 •

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Latest suggestions up to f3a8e0d

CategorySuggestion                                                                                                                                    Impact
Incremental [*]
Robustly locate NSIS makensis

To make locating NSIS more robust, search for makensis.exe in multiple common
installation directories and fall back to Get-Command instead of relying on a
single hardcoded path.

.github/workflows/build-installers.yml [226-237]

 - name: Install NSIS
   shell: pwsh
   run: |
     choco install nsis -y
     if ($LASTEXITCODE -ne 0) { throw "Chocolatey failed to install NSIS. Exit code: $LASTEXITCODE" }
-    $pf86 = ${env:ProgramFiles(x86)}
-    $nsisRoot = Join-Path -Path $pf86 -ChildPath 'NSIS\Bin'
-    if (-not (Test-Path -LiteralPath $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
-    $makensis = Join-Path $nsisRoot 'makensis.exe'
-    if (-not (Test-Path -LiteralPath $makensis)) { throw "makensis.exe not found in path: $nsisRoot" }
-    & $makensis /VERSION | Out-Host
-    Add-Content -Path $env:GITHUB_PATH -Value $nsisRoot
 
+    $candidates = @()
+    if ($env:ProgramFiles)      { $candidates += (Join-Path $env:ProgramFiles      'NSIS\Bin') }
+    if ($env:'ProgramFiles(x86)'){ $candidates += (Join-Path $env:'ProgramFiles(x86)' 'NSIS\Bin') }
+    $candidates += 'C:\ProgramData\chocolatey\lib\nsis\tools'
+
+    $makensisPath = $null
+    foreach ($dir in $candidates) {
+      if (Test-Path -LiteralPath $dir) {
+        $exe = Join-Path $dir 'makensis.exe'
+        if (Test-Path -LiteralPath $exe) { $makensisPath = $exe; break }
+      }
+    }
+    if (-not $makensisPath) {
+      $cmd = Get-Command makensis -ErrorAction SilentlyContinue
+      if ($cmd) { $makensisPath = $cmd.Source }
+    }
+    if (-not $makensisPath) { throw "makensis.exe not found in common locations or PATH." }
+
+    & $makensisPath /VERSION | Out-Host
+    Add-Content -Path $env:GITHUB_PATH -Value (Split-Path -Path $makensisPath -Parent)
+
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies that hardcoding the NSIS installation path is brittle and proposes a much more robust solution by searching multiple common locations, making the workflow more resilient to environment changes.

Medium
Possible issue
Harden NSIS install and PATH setup

Improve the NSIS installation script by using a try/catch block for more
reliable error handling with choco, adding flags for non-interactive use, and
robustly updating the PATH.

.github/workflows/build-installers.yml [227-237]

 shell: pwsh
 run: |
-  choco install nsis -y
-  if ($LASTEXITCODE -ne 0) { throw "Chocolatey failed to install NSIS. Exit code: $LASTEXITCODE" }
+  try {
+    choco install nsis -y --no-progress --limit-output
+  } catch {
+    throw "Chocolatey failed to install NSIS: $($_.Exception.Message)"
+  }
   $pf86 = ${env:ProgramFiles(x86)}
+  if (-not $pf86) { throw "ProgramFiles(x86) environment variable is not set." }
   $nsisRoot = Join-Path -Path $pf86 -ChildPath 'NSIS\Bin'
   if (-not (Test-Path -LiteralPath $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
   $makensis = Join-Path $nsisRoot 'makensis.exe'
   if (-not (Test-Path -LiteralPath $makensis)) { throw "makensis.exe not found in path: $nsisRoot" }
+  # Ensure available in current step and subsequent steps
+  $env:PATH = "$nsisRoot;$env:PATH"
+  if (-not (Test-Path -LiteralPath $env:GITHUB_PATH)) { throw "GITHUB_PATH file not available." }
+  "$nsisRoot" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
   & $makensis /VERSION | Out-Host
-  Add-Content -Path $env:GITHUB_PATH -Value $nsisRoot
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly points out that try/catch is more robust for handling choco failures than checking $LASTEXITCODE and proposes several other improvements to make the CI script more reliable.

Medium
Validate makensis execution result

After running makensis /VERSION, check $LASTEXITCODE to ensure the command
executed successfully and fail the step if it did not.

.github/workflows/build-installers.yml [236]

 & $makensis /VERSION | Out-Host
+if ($LASTEXITCODE -ne 0) {
+  throw "makensis failed to run. Exit code: $LASTEXITCODE at path $makensis"
+}
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly proposes adding an explicit check on the exit code of makensis to ensure it ran successfully, which improves the script's reliability and prevents potential downstream failures.

Low
  • More

Previous suggestions

✅ Suggestions up to commit 2e71cc2
Category Suggestion                                                                                                                                    Impact
Possible issue
✅ Fix invalid env var expansion
Suggestion Impact:The code was modified to avoid using ${...} directly in Join-Path; it now assigns the ProgramFiles(x86) env var to $pf86 and uses that in Join-Path. Although it still uses ${env:ProgramFiles(x86)} for the assignment (not $env:...), the change reflects the suggestion’s intent to correct the usage in the Join-Path context.

code diff:

-          $nsisRoot = Join-Path -Path ${env:ProgramFiles(x86)} -ChildPath 'NSIS\Bin'
+          if ($LASTEXITCODE -ne 0) { throw "Chocolatey failed to install NSIS. Exit code: $LASTEXITCODE" }
+          $pf86 = ${env:ProgramFiles(x86)}
+          $nsisRoot = Join-Path -Path $pf86 -ChildPath 'NSIS\Bin'
           if (-not (Test-Path -LiteralPath $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
-          if (-not (Test-Path -LiteralPath (Join-Path $nsisRoot "makensis.exe"))) { throw "makensis.exe not found in $nsisRoot" }
+          $makensis = Join-Path $nsisRoot 'makensis.exe'
+          if (-not (Test-Path -LiteralPath $makensis)) { throw "makensis.exe not found in path: $nsisRoot" }
+          & $makensis /VERSION | Out-Host

Correct the invalid PowerShell syntax for accessing the ProgramFiles(x86)
environment variable. The ${...} syntax is incorrect; use $env:ProgramFiles(x86)
instead.

.github/workflows/build-installers.yml [230]

-$nsisRoot = Join-Path -Path ${env:ProgramFiles(x86)} -ChildPath 'NSIS\Bin'
+$pf86 = $env:ProgramFiles(x86)
+$nsisRoot = Join-Path -Path $pf86 -ChildPath 'NSIS\Bin'

[Suggestion processed]

Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that ${env:ProgramFiles(x86)} is invalid PowerShell syntax and will cause the workflow step to fail. Fixing this syntax error is critical for the functionality of the build installer workflow.

High
Incremental [*]
✅ Validate Chocolatey install success
Suggestion Impact:The commit added an exit code check right after the Chocolatey install command and threw a descriptive error on failure, aligning with the suggestion. It also refactored path handling and added a makensis presence/version check.

code diff:

           choco install nsis -y
-          $nsisRoot = Join-Path -Path ${env:ProgramFiles(x86)} -ChildPath 'NSIS\Bin'
+          if ($LASTEXITCODE -ne 0) { throw "Chocolatey failed to install NSIS. Exit code: $LASTEXITCODE" }
+          $pf86 = ${env:ProgramFiles(x86)}
+          $nsisRoot = Join-Path -Path $pf86 -ChildPath 'NSIS\Bin'
           if (-not (Test-Path -LiteralPath $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
-          if (-not (Test-Path -LiteralPath (Join-Path $nsisRoot "makensis.exe"))) { throw "makensis.exe not found in $nsisRoot" }
+          $makensis = Join-Path $nsisRoot 'makensis.exe'
+          if (-not (Test-Path -LiteralPath $makensis)) { throw "makensis.exe not found in path: $nsisRoot" }
+          & $makensis /VERSION | Out-Host
           Add-Content -Path $env:GITHUB_PATH -Value $nsisRoot

Add a check for the exit code after the choco install nsis command to handle
potential installation failures and provide a clear error message.

.github/workflows/build-installers.yml [226-233]

 - name: Install NSIS
   shell: pwsh
   run: |
     choco install nsis -y
-    $nsisRoot = Join-Path -Path ${env:ProgramFiles(x86)} -ChildPath 'NSIS\Bin'
+    if ($LASTEXITCODE -ne 0) { throw "Chocolatey failed to install NSIS. Exit code: $LASTEXITCODE" }
+    $nsisRoot = Join-Path -Path '${env:ProgramFiles(x86)}' -ChildPath 'NSIS\Bin'
     if (-not (Test-Path -LiteralPath $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
     if (-not (Test-Path -LiteralPath (Join-Path $nsisRoot "makensis.exe"))) { throw "makensis.exe not found in $nsisRoot" }
     Add-Content -Path $env:GITHUB_PATH -Value $nsisRoot

[Suggestion processed]

Suggestion importance[1-10]: 7

__

Why: This suggestion correctly identifies a potential point of failure and proposes a robust error handling mechanism, which improves the reliability and debuggability of the workflow script.

Medium
General
✅ Validate NSIS executable runs
Suggestion Impact:The commit implemented the suggestion by assigning makensis path to a variable, validating its existence, and executing "& $makensis /VERSION | Out-Host" to verify it runs.

code diff:

+          $makensis = Join-Path $nsisRoot 'makensis.exe'
+          if (-not (Test-Path -LiteralPath $makensis)) { throw "makensis.exe not found in path: $nsisRoot" }
+          & $makensis /VERSION | Out-Host

Improve the NSIS installation validation by not only checking for the existence
of makensis.exe but also verifying it is executable by running makensis.exe
/VERSION.

.github/workflows/build-installers.yml [232]

-if (-not (Test-Path -LiteralPath (Join-Path $nsisRoot "makensis.exe"))) { throw "makensis.exe not found in $nsisRoot" }
+$makensis = Join-Path $nsisRoot 'makensis.exe'
+if (-not (Test-Path -LiteralPath $makensis)) { throw "makensis.exe not found in path: $nsisRoot" }
+& $makensis /VERSION | Out-Host

[Suggestion processed]

Suggestion importance[1-10]: 4

__

Why: The suggestion improves the script's robustness by adding a step to verify that makensis.exe is not only present but also executable. This is a good practice for ensuring the tool is correctly installed and configured before it is used in later steps.

Low
✅ Suggestions up to commit ba6f761
Category Suggestion                                                                                                                                    Impact
Incremental [*]
✅ Fix incorrect env var expansion
Suggestion Impact:The commit replaced the incorrect "${env:ProgramFiles(x86)}\NSIS\Bin" with a Join-Path construction and used Test-Path -LiteralPath, aligning with the suggestion. It also adjusted the shell placement and added an extra makensis.exe check.

code diff:

-          $nsisRoot = "${env:ProgramFiles(x86)}\NSIS\Bin"
-          if (-not (Test-Path $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
+          $nsisRoot = Join-Path -Path ${env:ProgramFiles(x86)} -ChildPath 'NSIS\Bin'
+          if (-not (Test-Path -LiteralPath $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
+          if (-not (Test-Path -LiteralPath (Join-Path $nsisRoot "makensis.exe"))) { throw "makensis.exe not found in $nsisRoot" }

Correct the invalid PowerShell syntax for environment variable expansion to
prevent the workflow step from failing. Use $env:'ProgramFiles(x86)' and
Join-Path for robust path construction.

.github/workflows/build-installers.yml [226-232]

 - name: Install NSIS
   run: |
     choco install nsis -y
-    $nsisRoot = "${env:ProgramFiles(x86)}\NSIS\Bin"
-    if (-not (Test-Path $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
+    $nsisRoot = Join-Path -Path $env:'ProgramFiles(x86)' -ChildPath 'NSIS\Bin'
+    if (-not (Test-Path -LiteralPath $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
     Add-Content -Path $env:GITHUB_PATH -Value $nsisRoot
   shell: pwsh

[Suggestion processed]

Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a bug where the PowerShell syntax for expanding the ProgramFiles(x86) environment variable is incorrect, which would cause the workflow step to fail. The proposed fix is robust and follows best practices.

High
Possible issue
✅ Fix NSIS path handling and export
Suggestion Impact:The commit switched to pwsh for the step, replaced the hardcoded NSIS path with Join-Path, added a makensis.exe existence check, and improved Test-Path usage; however, it kept Add-Content instead of switching to Out-File and did not add the ProgramFiles fallback.

code diff:

+        shell: pwsh
         run: |
           choco install nsis -y
-          $nsisRoot = "${env:ProgramFiles(x86)}\NSIS\Bin"
-          if (-not (Test-Path $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
+          $nsisRoot = Join-Path -Path ${env:ProgramFiles(x86)} -ChildPath 'NSIS\Bin'
+          if (-not (Test-Path -LiteralPath $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
+          if (-not (Test-Path -LiteralPath (Join-Path $nsisRoot "makensis.exe"))) { throw "makensis.exe not found in $nsisRoot" }
           Add-Content -Path $env:GITHUB_PATH -Value $nsisRoot

Improve the NSIS installation step by using Join-Path for robust path
construction, adding a fallback for different CPU architectures, and using
Out-File with explicit UTF-8 encoding to correctly update the GITHUB_PATH.

.github/workflows/build-installers.yml [226-232]

 - name: Install NSIS
+  shell: pwsh
   run: |
     choco install nsis -y
-    $nsisRoot = "${env:ProgramFiles(x86)}\NSIS\Bin"
+    $programFilesX86 = ${env:ProgramFiles(x86)}
+    if (-not $programFilesX86) { $programFilesX86 = $env:ProgramFiles } # fallback on ARM/other images
+    $nsisRoot = Join-Path $programFilesX86 "NSIS\Bin"
     if (-not (Test-Path $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
-    Add-Content -Path $env:GITHUB_PATH -Value $nsisRoot
-  shell: pwsh
+    if (-not (Test-Path (Join-Path $nsisRoot "makensis.exe"))) { throw "makensis.exe not found in $nsisRoot" }
+    "$nsisRoot" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

[Suggestion processed]

Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies multiple robustness issues: lack of a fallback for ProgramFiles(x86) on non-x86 runners, potential encoding problems with Add-Content, and brittle path construction. The proposed changes make the workflow script significantly more reliable and portable.

Medium
✅ Suggestions up to commit 02fa4bd
Category Suggestion                                                                                                                                    Impact
Possible issue
✅ Fix NSIS PATH and escaping
Suggestion Impact:The commit updated the NSIS installation step to use ProgramFiles(x86)\NSIS\Bin, added a Test-Path check with a throw on failure, and replaced echo with Add-Content to append to GITHUB_PATH.

code diff:

       - name: Install NSIS
         run: |
           choco install nsis -y
-          echo "C:\Program Files (x86)\NSIS" >> $env:GITHUB_PATH
+          $nsisRoot = "${env:ProgramFiles(x86)}\NSIS\Bin"
+          if (-not (Test-Path $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
+          Add-Content -Path $env:GITHUB_PATH -Value $nsisRoot

Correct the NSIS path added to $env:GITHUB_PATH to point to the Bin directory
containing the executable. Additionally, improve the script's robustness by
using environment variables and adding a path existence check.

.github/workflows/build-installers.yml [226-230]

 - name: Install NSIS
   run: |
     choco install nsis -y
-    echo "C:\Program Files (x86)\NSIS" >> $env:GITHUB_PATH
+    $nsisRoot = "${env:ProgramFiles(x86)}\NSIS\Bin"
+    if (-not (Test-Path $nsisRoot)) { throw "NSIS Bin folder not found at $nsisRoot" }
+    Add-Content -Path $env:GITHUB_PATH -Value $nsisRoot
   shell: pwsh

[Suggestion processed]

Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a bug where the wrong directory is added to the PATH, which would cause the workflow to fail. The proposed fix is robust, uses idiomatic PowerShell, and includes helpful error handling.

High
✅ Suggestions up to commit 646c200
Category Suggestion                                                                                                                                    Impact
General
✅ Avoid hardcoding executable path
Suggestion Impact:The workflow now adds "C:\Program Files (x86)\NSIS" to PATH during NSIS installation and replaces the hardcoded executable path with calling "makensis" directly.

code diff:

+        run: |
+          choco install nsis -y
+          echo "C:\Program Files (x86)\NSIS" >> $env:GITHUB_PATH
+        shell: pwsh
 
       - name: Create NSIS installer script
         run: |
@@ -295,7 +298,7 @@
       - name: Build NSIS installer
         run: |
           cd agents/capture-agent-py
-          & "C:\Program Files (x86)\NSIS\makensis.exe" installer.nsi
+          makensis installer.nsi
 

Instead of hardcoding the full path to makensis.exe, add its directory to the
PATH environment variable using $env:GITHUB_PATH and then call the executable by
name. This improves the workflow's robustness against changes in the runner
environment.

.github/workflows/build-installers.yml [298]

 -          makensis installer.nsi
-+          & "C:\Program Files (x86)\NSIS\makensis.exe" installer.nsi
++          echo "C:\Program Files (x86)\NSIS" >> $env:GITHUB_PATH
++          makensis installer.nsi
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly points out that hardcoding the path to an executable is brittle and proposes a more robust solution by adding the directory to the PATH, which is a standard best practice in GitHub Actions.

Low

@cj-vana
cj-vana merged commit 0a1c304 into beta Sep 22, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant