Add GitHub Actions workflow to build and run demos on macOS#3
Add GitHub Actions workflow to build and run demos on macOS#3dustturtle merged 4 commits intomainfrom
Conversation
- 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]>
- 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]>
GCDAsyncSocket.m uses __weak references throughout which require Automatic Reference Counting (ARC) to be enabled. Co-authored-by: dustturtle <[email protected]>
There was a problem hiding this comment.
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
SwiftDemoand include the Swift demo source underExamples/. - 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 |
There was a problem hiding this comment.
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.
| 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 |
| - name: Run Swift Demo (all demos) | ||
| run: | | ||
| printf 'a\n\n\n\n\n\nq\n' | swift run SwiftDemo | ||
|
|
There was a problem hiding this comment.
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.
| - name: Run ObjC Demo (all demos) | ||
| run: | | ||
| printf 'a\n\n\n\n\n\nq\n' | ./ObjCDemo | ||
|
|
There was a problem hiding this comment.
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.
| ```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 |
There was a problem hiding this comment.
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.
| // 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 |
There was a problem hiding this comment.
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.
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 build --target SwiftDemo+ run all 5 interactive demos via piped stdinclang -fobjc-arc(required for__weakrefs in GCDAsyncSocket.m) linking Foundation + Network frameworks, then runswift teston macOSTriggers on push/PR to
mainandworkflow_dispatch. Scoped topermissions: 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 ObjCDemoNote:
-fobjc-arcis required — GCDAsyncSocket.m uses__weakreferences 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.