Skip to content

ci: fix build workflow and add test workflow - #5

Open
Ayush-Vish wants to merge 1 commit into
mainfrom
workflow-fixes-and-tests
Open

Ayush-Vish wants to merge 1 commit into
mainfrom
workflow-fixes-and-tests

Conversation

@Ayush-Vish

Copy link
Copy Markdown
Owner
  • Updated .github/workflows/main.yml:
    • Bumped Go version to 1.23 to match go.mod.
    • Fixed artifact upload failure by ensuring unique artifact names per matrix job (binaries-{os}-{arch}).
  • Added .github/workflows/test.yml:
    • New workflow to run go test -v ./... on push and pull request events.

- Updated `.github/workflows/main.yml`:
  - Bumped Go version to 1.23 to match `go.mod`.
  - Fixed artifact upload failure by ensuring unique artifact names per matrix job (`binaries-{os}-{arch}`).
- Added `.github/workflows/test.yml`:
  - New workflow to run `go test -v ./...` on push and pull request events.
Copilot AI review requested due to automatic review settings December 2, 2025 07:21
@netlify

netlify Bot commented Dec 2, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for shellsync canceled.

Name Link
🔨 Latest commit 7651e6d
🔍 Latest deploy log https://app.netlify.com/projects/shellsync/deploys/692e9398007f810008570a5a

@vercel

vercel Bot commented Dec 2, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
shellsyncc Error Error Dec 2, 2025 7:22am

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes CI/CD workflow issues and introduces comprehensive test coverage for the shellsync project. The changes align the Go version with go.mod (1.23.9), resolve artifact upload conflicts in matrix builds, and establish a dedicated test workflow. Additionally, the PR adds the first unit tests for core components (client controller, websocket hub, and backend service), using mock implementations to test functionality in isolation.

Key Changes:

  • Upgraded Go version from 1.21 to 1.23 in build workflow to match go.mod
  • Fixed artifact name collisions by making them unique per OS/architecture combination
  • Added automated test workflow that runs on push and pull requests

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
.github/workflows/main.yml Updated Go version to 1.23 and fixed artifact naming to include matrix variables, preventing upload conflicts
.github/workflows/test.yml New workflow for running go test -v ./... on push/PR to main branch
client/controller/controller_test.go Added unit tests for NewAgent and getDefaultShell with cross-platform considerations
backend/internal/websocket/hub_test.go Added comprehensive tests for websocket hub including connection handling, authentication, and message broadcasting
backend/internal/service/service_test.go Added tests for core service methods including session management, terminal creation, and input forwarding

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Read auth success
var authResp types.Message
ws.ReadJSON(&authResp)

Copilot AI Dec 2, 2025

Copy link

Choose a reason for hiding this comment

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

Error return values from ws.WriteJSON and ws.ReadJSON should be checked. While this is test code, ignoring errors can lead to confusing test failures if the WebSocket communication fails.

Suggested change
ws.ReadJSON(&authResp)
if err := ws.ReadJSON(&authResp); err != nil {
t.Fatalf("ReadJSON (authResp) failed: %v", err)
}

Copilot uses AI. Check for mistakes.

// Read session state (sent automatically after register)
var stateResp types.Message
ws.ReadJSON(&stateResp)

Copilot AI Dec 2, 2025

Copy link

Choose a reason for hiding this comment

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

Error return value from ws.ReadJSON should be checked. Ignoring this error could cause the test to fail in confusing ways if the session state message is not received as expected.

Suggested change
ws.ReadJSON(&stateResp)
if err := ws.ReadJSON(&stateResp); err != nil {
t.Fatalf("ReadJSON (session_state) failed: %v", err)
}

Copilot uses AI. Check for mistakes.
Comment on lines +170 to +176
// Read session state (sent automatically after register)
var stateResp types.Message
ws.ReadJSON(&stateResp)
if stateResp.Type != "session_state" {
// It might be possible we get the broadcast before the state if we are too fast?
// But in registerClient, session state is sent in a goroutine with sleep.
// So likely we receive it.

Copilot AI Dec 2, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The comment mentions uncertainty about message ordering but doesn't handle the case where session_state is not received. Consider adding a more robust check or timeout mechanism to verify the session state message is received before proceeding with the broadcast test. For example:

// Read session state with timeout handling
var stateResp types.Message
if err := ws.ReadJSON(&stateResp); err != nil {
    t.Logf("Warning: Failed to read session state: %v", err)
}
Suggested change
// Read session state (sent automatically after register)
var stateResp types.Message
ws.ReadJSON(&stateResp)
if stateResp.Type != "session_state" {
// It might be possible we get the broadcast before the state if we are too fast?
// But in registerClient, session state is sent in a goroutine with sleep.
// So likely we receive it.
// Read session state (sent automatically after register) with timeout handling
var stateResp types.Message
ws.SetReadDeadline(time.Now().Add(1 * time.Second))
err := ws.ReadJSON(&stateResp)
ws.SetReadDeadline(time.Time{}) // Clear deadline for further reads
if err != nil {
t.Fatalf("Failed to read session_state message: %v", err)
}
if stateResp.Type != "session_state" {
t.Logf("Warning: Expected session_state, got %s", stateResp.Type)

Copilot uses AI. Check for mistakes.
Comment on lines +185 to +187
// Wait a bit to ensure client is fully registered
time.Sleep(200 * time.Millisecond)

Copilot AI Dec 2, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] Using a fixed time.Sleep(200 * time.Millisecond) to wait for client registration can make tests flaky under load or in slower CI environments. Consider using a more deterministic synchronization mechanism, such as a channel-based signal or a polling loop with timeout. For example:

// Poll for client registration with timeout
timeout := time.After(1 * time.Second)
ticker := time.NewTicker(10 * time.Millisecond)
defer ticker.Stop()

registered := false
for !registered {
    select {
    case <-timeout:
        t.Fatal("Timeout waiting for client registration")
    case <-ticker.C:
        hub.mu.RLock()
        _, registered = hub.clients["client1"]
        hub.mu.RUnlock()
    }
}
Suggested change
// Wait a bit to ensure client is fully registered
time.Sleep(200 * time.Millisecond)
// Wait deterministically for client registration
timeout := time.After(1 * time.Second)
ticker := time.NewTicker(10 * time.Millisecond)
defer ticker.Stop()
registered := false
for !registered {
select {
case <-timeout:
t.Fatal("Timeout waiting for client registration")
case <-ticker.C:
hub.mu.RLock()
_, registered = hub.clients["client1"]
hub.mu.RUnlock()
}
}

Copilot uses AI. Check for mistakes.

This branch had an error being deployed

1 failed deployment
Preview — 7651e6d5 Deployed Dec 2, 2025 by vercel[bot]
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