Skip to content

Add GitHub Actions workflow to build and run demos on macOS#3

Merged
dustturtle merged 4 commits intomainfrom
copilot/add-demo-for-oc-swift
Feb 27, 2026
Merged

Add GitHub Actions workflow to build and run demos on macOS#3
dustturtle merged 4 commits intomainfrom
copilot/add-demo-for-oc-swift

Conversation

Copy link

Copilot AI commented Feb 27, 2026

Adds a CI workflow that builds and runs both the Swift and ObjC demos on macOS, where Network.framework is available.

Workflow (.github/workflows/demo.yml)

  • Swift Demoswift build --target SwiftDemo + run all 5 interactive demos via piped stdin
  • ObjC Demo — compile with clang -fobjc-arc (required for __weak refs in GCDAsyncSocket.m) linking Foundation + Network frameworks, then run
  • Swift Testsswift test on macOS

Triggers on push/PR to main and workflow_dispatch. Scoped to permissions: contents: read.

ObjC build command

clang -fobjc-arc -framework Foundation -framework Network \
      -I ObjC/NWAsyncSocketObjC/include \
      ObjC/NWAsyncSocketObjC/NWStreamBuffer.m \
      ObjC/NWAsyncSocketObjC/NWSSEParser.m \
      ObjC/NWAsyncSocketObjC/NWReadRequest.m \
      ObjC/NWAsyncSocketObjC/GCDAsyncSocket.m \
      ObjC/ObjCDemo/main.m \
      -o ObjCDemo

Note: -fobjc-arc is required — GCDAsyncSocket.m uses __weak references throughout for block retain-cycle avoidance.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Swift demo: Examples/SwiftDemo/main.swift (SPM executable target)
- ObjC demo: ObjC/ObjCDemo/main.m (build with clang on macOS)
- Both demos cover: StreamBuffer, SSEParser, UTF-8 safety, ReadRequest, socket usage
- Interactive menu-driven interface for testing individual components
- Updated README with demo instructions and file structure

Co-authored-by: dustturtle <[email protected]>
Copilot AI changed the title [WIP] Add demo for user testing in OC and Swift versions Add interactive demo apps for Swift and Objective-C Feb 27, 2026
- Swift demo: build + run all 5 demos via SPM on macOS
- ObjC demo: compile with clang + run all 5 demos on macOS
- Swift tests: run full test suite on macOS (Network.framework available)
- Triggers: push/PR to main, manual workflow_dispatch
- Minimal permissions (contents: read)

Co-authored-by: dustturtle <[email protected]>
Copilot AI changed the title Add interactive demo apps for Swift and Objective-C Add interactive demos and CI workflow for Swift and ObjC on macOS Feb 27, 2026
GCDAsyncSocket.m uses __weak references throughout which require
Automatic Reference Counting (ARC) to be enabled.

Co-authored-by: dustturtle <[email protected]>
Copilot AI changed the title Add interactive demos and CI workflow for Swift and ObjC on macOS Add GitHub Actions workflow to build and run demos on macOS Feb 27, 2026
@dustturtle dustturtle marked this pull request as ready for review February 27, 2026 07:44
Copilot AI review requested due to automatic review settings February 27, 2026 07:44
@dustturtle dustturtle merged commit f40505e into main Feb 27, 2026
3 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds macOS CI coverage for the repository’s interactive demos (Swift + Objective-C) and exposes the Swift demo as an SPM executable, so demo builds/runs are continuously validated where Network.framework is available.

Changes:

  • Add a GitHub Actions workflow to build/run SwiftDemo + ObjCDemo on macOS and run swift test.
  • Add an SPM executable product/target for SwiftDemo and include the Swift demo source under Examples/.
  • Add interactive demo sources for Swift and Objective-C and document how to run/build them in the README.

Reviewed changes

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

Show a summary per file
File Description
README.md Documents the new demo entry points and how to build/run them.
Package.swift Adds SwiftDemo as an SPM executable product/target.
Examples/SwiftDemo/main.swift Implements the interactive Swift demo covering core components and NWAsyncSocket usage.
ObjC/ObjCDemo/main.m Implements the interactive Objective-C demo covering core ObjC components and GCDAsyncSocket usage.
.github/workflows/demo.yml Adds macOS CI jobs to build/run demos and run Swift tests.

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


- name: Run Swift Demo (all demos)
run: |
printf 'a\n\n\n\n\n\nq\n' | swift run SwiftDemo
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

This step runs swift run SwiftDemo after already building the target, which will typically trigger another build. Consider using swift run --skip-build SwiftDemo (or remove the separate build step) to reduce CI time and avoid redundant compilation.

Suggested change
printf 'a\n\n\n\n\n\nq\n' | swift run SwiftDemo
printf 'a\n\n\n\n\n\nq\n' | swift run --skip-build SwiftDemo

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +26
- name: Run Swift Demo (all demos)
run: |
printf 'a\n\n\n\n\n\nq\n' | swift run SwiftDemo

Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The stdin sequence provides 6 blank lines after selecting a, but the demo only prompts 5 times to “Press Enter to continue” when running all demos. The extra newline will be read as an empty menu choice and print an "Invalid choice" message before q is consumed; adjust the number of newlines so the run is clean and less brittle.

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +47
- name: Run ObjC Demo (all demos)
run: |
printf 'a\n\n\n\n\n\nq\n' | ./ObjCDemo

Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

Same as the Swift demo step: the stdin sequence has 6 blank lines after a, but the ObjC demo waits for Enter 5 times when running all demos. The extra newline becomes an empty menu selection and results in an "Invalid choice" iteration before quitting; tighten the input to exactly match the prompts.

Copilot uses AI. Check for mistakes.
Comment on lines +262 to +270
```bash
clang -framework Foundation \
-I ObjC/NWAsyncSocketObjC/include \
ObjC/NWAsyncSocketObjC/NWStreamBuffer.m \
ObjC/NWAsyncSocketObjC/NWSSEParser.m \
ObjC/NWAsyncSocketObjC/NWReadRequest.m \
ObjC/NWAsyncSocketObjC/GCDAsyncSocket.m \
ObjC/ObjCDemo/main.m \
-o ObjCDemo
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The ObjC demo build command in the README is missing -fobjc-arc and -framework Network. GCDAsyncSocket.m uses __weak (requires ARC) and links against Network.framework symbols, so the documented command will fail to compile/link on macOS. Update the command to match the workflow/PR description flags.

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +22
// Build (from repository root):
// clang -framework Foundation \
// -I ObjC/NWAsyncSocketObjC/include \
// ObjC/NWAsyncSocketObjC/NWStreamBuffer.m \
// ObjC/NWAsyncSocketObjC/NWSSEParser.m \
// ObjC/NWAsyncSocketObjC/NWReadRequest.m \
// ObjC/NWAsyncSocketObjC/GCDAsyncSocket.m \
// ObjC/ObjCDemo/main.m \
// -o ObjCDemo
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The build instructions in this file’s header comment omit -fobjc-arc and -framework Network. Since ObjC/NWAsyncSocketObjC/GCDAsyncSocket.m uses __weak and Network.framework APIs, the documented clang invocation will fail unless those flags are included.

Copilot uses AI. Check for mistakes.
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.

3 participants