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

Upgrade to v1.1.0 #1784

Merged

Conversation

ianjennings
Copy link
Contributor

  • remove hanging testdriver checks
  • upgrade to v1.1.0 which spawns "commit status" of calling action
  • commit status "show details" link goes right to dashcam recording

testdriverai/action@1.0.0...1.1.0#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556R270-R279

Copy link
Contributor

coderabbitai bot commented Jan 21, 2025

Walkthrough

The pull request involves modifications to the GitHub Actions workflow file testdriver.yml. The primary change is the removal of steps related to creating and managing a GitHub check run using the actions/github-script@v7 action. Specifically, the steps that created a check run with an 'in_progress' status and updated its status to 'completed' based on the outcome of the testdriver step have been removed. Additionally, the permissions section has been updated, changing pull-requests: write and checks: write to statuses: write. The revised workflow now focuses solely on executing the testdriver action and managing artifacts, without any check run management.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
.github/workflows/testdriver.yml (2)

89-101: Add file integrity verification after download.

The artifact download process should include checksum verification to ensure file integrity.

  Write-Host "Starting artifact download..."
  $artifactZipPath = "$env:TEMP\artifact.zip"
  try {
      Invoke-WebRequest -Uri $artifactUrl `
          -Headers $headers `
          -OutFile $artifactZipPath `
          -MaximumRedirection 5

      Write-Host "Artifact downloaded successfully to $artifactZipPath"
+     # Verify file integrity
+     if (-not (Test-Path $artifactZipPath) -or (Get-Item $artifactZipPath).Length -eq 0) {
+         throw "Downloaded file is empty or missing"
+     }
  } catch {

63-65: Move hardcoded values to variables at the top of the script.

Improve maintainability by consolidating configuration values.

+ # Configuration
+ $config = @{
+     DownloadFolder = "./download"
+     ArtifactFileName = "waveterm.exe"
+     TempFolder = $env:TEMP
+     InstallTimeout = 300000  # 5 minutes
+     WaveTermPath = Join-Path $env:USERPROFILE "AppData\Local\Programs\waveterm\Wave.exe"
+ }
+
- $downloadFolder = "./download"
- $artifactFileName = "waveterm.exe"
- $artifactFilePath = "$downloadFolder/$artifactFileName"
+ $artifactFilePath = Join-Path $config.DownloadFolder $config.ArtifactFileName
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4fba9e6 and 0ad19f3.

📒 Files selected for processing (1)
  • .github/workflows/testdriver.yml (1 hunks)
🔇 Additional comments (1)
.github/workflows/testdriver.yml (1)

52-54: Implement commit status with dashcam link.

According to the PR objectives, this version should spawn a "commit status" with a "show details" link to the dashcam recording. However, this implementation is missing.

Could you confirm if this feature is implemented in the action itself (testdriverai/[email protected]) rather than in the workflow? If not, we should add the necessary steps to create the commit status.

Comment on lines +52 to +58
- uses: testdriverai/action@main
id: testdriver
env:
FORCE_COLOR: "3"
with:
key: ${{ secrets.DASHCAM_API }}
prerun: |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Pin the action version for stability.

Using @main is not recommended as it points to a mutable ref. Since this PR is upgrading to v1.1.0, you should pin the action to this specific version.

- - uses: testdriverai/action@main
+ - uses: testdriverai/[email protected]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: testdriverai/action@main
id: testdriver
env:
FORCE_COLOR: "3"
with:
key: ${{ secrets.DASHCAM_API }}
prerun: |
- uses: testdriverai/action@v1.1.0
id: testdriver
env:
FORCE_COLOR: "3"
with:
key: ${{ secrets.DASHCAM_API }}
prerun: |

Comment on lines +125 to +132
Write-Host "Running the installer: $($artifactInstallerPath.FullName)..."
try {
Start-Process -FilePath $artifactInstallerPath.FullName -Wait
Write-Host "Installer ran successfully."
} catch {
Write-Error "Failed to run the installer: $_"
exit 1
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add timeout handling for installer process.

The Start-Process call should include a timeout to prevent hanging.

  Write-Host "Running the installer: $($artifactInstallerPath.FullName)..."
  try {
-     Start-Process -FilePath $artifactInstallerPath.FullName -Wait
+     $process = Start-Process -FilePath $artifactInstallerPath.FullName -Wait -PassThru
+     $processExited = $process.WaitForExit(300000) # 5-minute timeout
+     if (-not $processExited) {
+         $process.Kill()
+         throw "Installer process timed out after 5 minutes"
+     }
      Write-Host "Installer ran successfully."
  } catch {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Write-Host "Running the installer: $($artifactInstallerPath.FullName)..."
try {
Start-Process -FilePath $artifactInstallerPath.FullName -Wait
Write-Host "Installer ran successfully."
} catch {
Write-Error "Failed to run the installer: $_"
exit 1
}
Write-Host "Running the installer: $($artifactInstallerPath.FullName)..."
try {
$process = Start-Process -FilePath $artifactInstallerPath.FullName -Wait -PassThru
$processExited = $process.WaitForExit(300000) # 5-minute timeout
if (-not $processExited) {
$process.Kill()
throw "Installer process timed out after 5 minutes"
}
Write-Host "Installer ran successfully."
} catch {
Write-Error "Failed to run the installer: $_"
exit 1
}

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
.github/workflows/testdriver.yml (3)

88-89: Add cleanup for temporary files.

The script creates temporary files but doesn't clean them up after use. This could lead to disk space issues over time.

Add cleanup steps after installation:

    $artifactZipPath = "$env:TEMP\artifact.zip"
    $artifactUnzipPath = "$env:TEMP\artifact"
+   
+   # Cleanup function
+   function Cleanup-TempFiles {
+       if (Test-Path $artifactZipPath) {
+           Remove-Item -Path $artifactZipPath -Force
+           Write-Host "Cleaned up artifact zip file"
+       }
+       if (Test-Path $artifactUnzipPath) {
+           Remove-Item -Path $artifactUnzipPath -Recurse -Force
+           Write-Host "Cleaned up unzipped artifact folder"
+       }
+   }

Add cleanup calls in the success and error paths.

Also applies to: 101-103


133-137: Avoid hardcoded paths.

The script uses hardcoded paths which could break if the installation location changes.

Consider making the paths configurable:

-   $wavePath = Join-Path $env:USERPROFILE "AppData\Local\Programs\waveterm\Wave.exe"
+   # Define default and allow override through environment variable
+   $waveInstallDir = $env:WAVE_INSTALL_DIR ?? "AppData\Local\Programs\waveterm"
+   $waveExeName = $env:WAVE_EXE_NAME ?? "Wave.exe"
+   $wavePath = Join-Path $env:USERPROFILE $waveInstallDir $waveExeName

56-138: Consider modularizing the installation script.

The prerun script is quite long and handles multiple responsibilities. Consider breaking it into smaller, reusable functions for better maintainability.

Extract the main operations into functions:

function Initialize-DownloadDirectory {
    param($downloadFolder)
    # Directory creation logic
}

function Get-ArtifactUrl {
    param($headers, $runId, $repo)
    # URL fetching logic
}

function Save-Artifact {
    param($url, $headers, $destination)
    # Download logic
}

function Install-WaveTerminal {
    param($installerPath)
    # Installation logic
}

function Start-WaveTerminal {
    param($installPath)
    # Launch logic
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ad19f3 and 74b6cde.

📒 Files selected for processing (1)
  • .github/workflows/testdriver.yml (2 hunks)
🔇 Additional comments (2)
.github/workflows/testdriver.yml (2)

14-15: LGTM! Permission changes align with the new functionality.

The changes follow the principle of least privilege by removing unnecessary permissions (checks: write, pull-requests: write) and only adding what's needed (statuses: write) for the new commit status feature.


50-56: Pin the action version for stability.

Using @main is not recommended as it points to a mutable ref. Since this PR is upgrading to v1.1.0, you should pin the action to this specific version.

- - uses: testdriverai/action@main
+ - uses: testdriverai/[email protected]

Comment on lines +113 to +120
$artifactInstallerPath = Get-ChildItem -Path $artifactUnzipPath -Filter *.exe -Recurse | Select-Object -First 1

if ($artifactInstallerPath) {
Write-Host "Executable file found: $($artifactInstallerPath.FullName)"
} else {
Write-Error "Executable file not found. Exiting."
exit 1
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add validation of artifact content before execution.

The script executes the first .exe file found without validating its authenticity or expected structure. This could be a security risk.

Add validation steps:

-   $artifactInstallerPath = Get-ChildItem -Path $artifactUnzipPath -Filter *.exe -Recurse | Select-Object -First 1
+   # Expected installer name pattern
+   $expectedInstallerPattern = "waveterm-setup-*.exe"
+   
+   # Find installer matching expected pattern
+   $artifactInstallerPath = Get-ChildItem -Path $artifactUnzipPath -Filter $expectedInstallerPattern -Recurse | Select-Object -First 1
+   
+   # Validate digital signature if applicable
+   if ($artifactInstallerPath) {
+       $signature = Get-AuthenticodeSignature -FilePath $artifactInstallerPath.FullName
+       if ($signature.Status -ne "Valid") {
+           Write-Error "Invalid digital signature on installer: $($signature.Status)"
+           exit 1
+       }
+   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$artifactInstallerPath = Get-ChildItem -Path $artifactUnzipPath -Filter *.exe -Recurse | Select-Object -First 1
if ($artifactInstallerPath) {
Write-Host "Executable file found: $($artifactInstallerPath.FullName)"
} else {
Write-Error "Executable file not found. Exiting."
exit 1
}
# Expected installer name pattern
$expectedInstallerPattern = "waveterm-setup-*.exe"
# Find installer matching expected pattern
$artifactInstallerPath = Get-ChildItem -Path $artifactUnzipPath -Filter $expectedInstallerPattern -Recurse | Select-Object -First 1
# Validate digital signature if applicable
if ($artifactInstallerPath) {
$signature = Get-AuthenticodeSignature -FilePath $artifactInstallerPath.FullName
if ($signature.Status -ne "Valid") {
Write-Error "Invalid digital signature on installer: $($signature.Status)"
exit 1
}
Write-Host "Executable file found: $($artifactInstallerPath.FullName)"
} else {
Write-Error "Executable file not found. Exiting."
exit 1
}

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/testdriver.yml (1)

14-17: LGTM! Permission changes align with the new commit status feature.

The changes follow the principle of least privilege by removing unused permissions and adding only the required statuses: write permission.

Fix formatting issues.

The indentation and trailing spaces should be fixed to maintain consistency.

-  contents: read
-  statuses: write
-
+    contents: read
+    statuses: write
🧰 Tools
🪛 yamllint (1.35.1)

[warning] 14-14: wrong indentation: expected 4 but found 2

(indentation)


[error] 17-17: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 74b6cde and 456f91d.

📒 Files selected for processing (1)
  • .github/workflows/testdriver.yml (2 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/testdriver.yml

[warning] 14-14: wrong indentation: expected 4 but found 2

(indentation)


[error] 17-17: trailing spaces

(trailing-spaces)


[warning] 51-51: wrong indentation: expected 12 but found 10

(indentation)

🔇 Additional comments (4)
.github/workflows/testdriver.yml (4)

51-57: Pin the action version for stability.

Using @main is not recommended as it points to a mutable ref. Since this PR is upgrading to v1.1.0, you should pin the action to this specific version.

- - uses: testdriverai/action@main
+ - uses: testdriverai/[email protected]
🧰 Tools
🪛 yamllint (1.35.1)

[warning] 51-51: wrong indentation: expected 12 but found 10

(indentation)


124-131: Add timeout handling for installer process.

The Start-Process call should include a timeout to prevent hanging.

  Write-Host "Running the installer: $($artifactInstallerPath.FullName)..."
  try {
-     Start-Process -FilePath $artifactInstallerPath.FullName -Wait
+     $process = Start-Process -FilePath $artifactInstallerPath.FullName -Wait -PassThru
+     $processExited = $process.WaitForExit(300000) # 5-minute timeout
+     if (-not $processExited) {
+         $process.Kill()
+         throw "Installer process timed out after 5 minutes"
+     }
      Write-Host "Installer ran successfully."
  } catch {

114-121: Add validation of artifact content before execution.

The script executes the first .exe file found without validating its authenticity or expected structure. This could be a security risk.

-   $artifactInstallerPath = Get-ChildItem -Path $artifactUnzipPath -Filter *.exe -Recurse | Select-Object -First 1
+   # Expected installer name pattern
+   $expectedInstallerPattern = "waveterm-setup-*.exe"
+   
+   # Find installer matching expected pattern
+   $artifactInstallerPath = Get-ChildItem -Path $artifactUnzipPath -Filter $expectedInstallerPattern -Recurse | Select-Object -First 1
+   
+   # Validate digital signature if applicable
+   if ($artifactInstallerPath) {
+       $signature = Get-AuthenticodeSignature -FilePath $artifactInstallerPath.FullName
+       if ($signature.Status -ne "Valid") {
+           Write-Error "Invalid digital signature on installer: $($signature.Status)"
+           exit 1
+       }
+   }

140-141: LGTM! Clear and concise test prompt.

The prompt clearly specifies the test file to run.

Comment on lines +133 to +139
# Optional: If the app executable is different from the installer, find and launch it
$wavePath = Join-Path $env:USERPROFILE "AppData\Local\Programs\waveterm\Wave.exe"

Write-Host "Launching the application: $($wavePath)"
Start-Process -FilePath $wavePath
Write-Host "Application launched."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for application launch.

The application launch step lacks proper error handling and verification.

     # Optional: If the app executable is different from the installer, find and launch it
-    $wavePath = Join-Path $env:USERPROFILE "AppData\Local\Programs\waveterm\Wave.exe"
+    $waveInstallDir = Join-Path $env:LOCALAPPDATA "Programs\waveterm"
+    $wavePath = Join-Path $waveInstallDir "Wave.exe"
 
-    Write-Host "Launching the application: $($wavePath)"
-    Start-Process -FilePath $wavePath
-    Write-Host "Application launched."
+    if (Test-Path $wavePath) {
+        Write-Host "Launching the application: $($wavePath)"
+        try {
+            $process = Start-Process -FilePath $wavePath -PassThru
+            Start-Sleep -Seconds 5  # Give the app time to start
+            if ($process.HasExited) {
+                throw "Application crashed on startup"
+            }
+            Write-Host "Application launched successfully."
+        } catch {
+            Write-Error "Failed to launch application: $_"
+            exit 1
+        }
+    } else {
+        Write-Error "Application executable not found at expected path: $wavePath"
+        exit 1
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Optional: If the app executable is different from the installer, find and launch it
$wavePath = Join-Path $env:USERPROFILE "AppData\Local\Programs\waveterm\Wave.exe"
Write-Host "Launching the application: $($wavePath)"
Start-Process -FilePath $wavePath
Write-Host "Application launched."
# Optional: If the app executable is different from the installer, find and launch it
$waveInstallDir = Join-Path $env:LOCALAPPDATA "Programs\waveterm"
$wavePath = Join-Path $waveInstallDir "Wave.exe"
if (Test-Path $wavePath) {
Write-Host "Launching the application: $($wavePath)"
try {
$process = Start-Process -FilePath $wavePath -PassThru
Start-Sleep -Seconds 5 # Give the app time to start
if ($process.HasExited) {
throw "Application crashed on startup"
}
Write-Host "Application launched successfully."
} catch {
Write-Error "Failed to launch application: $_"
exit 1
}
} else {
Write-Error "Application executable not found at expected path: $wavePath"
exit 1
}

@esimkowitz esimkowitz merged commit a5fa098 into wavetermdev:main Jan 22, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants