mirror of
https://github.com/apple/swift-nio-imap
synced 2026-11-22 04:30:43 +00:00
Move examples into sub-dir (#834)
This commit is contained in:
1 parent
880366a417
commit
1057994e93
22 files changed
+190
-50
No files matched your search
@@ -33,3 +33,23 @@ jobs:
|
||||
# `main` toolchain this job builds with. Enable it until the dependency's guard is fixed
|
||||
# upstream (cf. apple/swift-collections #580/#584).
|
||||
additional_command_arguments: "-Xswiftc -enable-experimental-feature -Xswiftc InlineAlways"
|
||||
|
||||
examples:
|
||||
name: Build examples
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
example: [CLI, Proxy, Fuzzer, PerformanceTester]
|
||||
container:
|
||||
image: swift:6.0
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Build
|
||||
run: swift build --package-path "Examples/${{ matrix.example }}"
|
||||
- name: Test
|
||||
if: matrix.example == 'CLI'
|
||||
run: swift test --package-path "Examples/CLI"
|
||||
@@ -41,7 +41,27 @@ jobs:
|
||||
uses: apple/swift-nio/.github/workflows/macos_tests.yml@main
|
||||
with:
|
||||
runner_pool: general
|
||||
build_scheme: swift-nio-imap-Package
|
||||
build_scheme: swift-nio-imap
|
||||
swift_6_1_build_arguments_override: "-Xswiftc -Xfrontend -Xswiftc -require-explicit-sendable -Xswiftc -warnings-as-errors"
|
||||
swift_6_2_build_arguments_override: "-Xswiftc -Xfrontend -Xswiftc -require-explicit-sendable -Xswiftc -warnings-as-errors"
|
||||
swift_6_3_build_arguments_override: "-Xswiftc -Xfrontend -Xswiftc -require-explicit-sendable -Xswiftc -warnings-as-errors"
|
||||
|
||||
examples:
|
||||
name: Build examples
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
example: [CLI, Proxy, Fuzzer, PerformanceTester]
|
||||
container:
|
||||
image: swift:6.0
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Build
|
||||
run: swift build --package-path "Examples/${{ matrix.example }}"
|
||||
- name: Test
|
||||
if: matrix.example == 'CLI'
|
||||
run: swift test --package-path "Examples/CLI"
|
||||
@@ -1,5 +1,6 @@
|
||||
.DS_Store
|
||||
/.build
|
||||
Examples/*/.build
|
||||
/Packages
|
||||
/*.xcodeproj
|
||||
Package.pins
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
// swift-tools-version:6.0
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "imap-cli-example",
|
||||
platforms: [
|
||||
.macOS(.v15)
|
||||
],
|
||||
dependencies: [
|
||||
.package(name: "swift-nio-imap", path: "../.."),
|
||||
.package(url: "https://github.com/apple/swift-nio", from: "2.64.0"),
|
||||
.package(url: "https://github.com/apple/swift-nio-ssl", from: "2.24.0"),
|
||||
.package(url: "https://github.com/apple/swift-log", from: "1.4.4"),
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
name: "CLI",
|
||||
dependencies: [
|
||||
.target(name: "CLILib"),
|
||||
.product(name: "NIO", package: "swift-nio"),
|
||||
.product(name: "NIOSSL", package: "swift-nio-ssl"),
|
||||
.product(name: "Logging", package: "swift-log"),
|
||||
]
|
||||
),
|
||||
.target(
|
||||
name: "CLILib",
|
||||
dependencies: [
|
||||
.product(name: "NIOIMAP", package: "swift-nio-imap"),
|
||||
.product(name: "NIO", package: "swift-nio"),
|
||||
.product(name: "NIOSSL", package: "swift-nio-ssl"),
|
||||
.product(name: "Logging", package: "swift-log"),
|
||||
]
|
||||
),
|
||||
.testTarget(
|
||||
name: "CLILibTests",
|
||||
dependencies: [
|
||||
.target(name: "CLILib"),
|
||||
.product(name: "NIOIMAP", package: "swift-nio-imap"),
|
||||
.product(name: "NIO", package: "swift-nio"),
|
||||
.product(name: "NIOTestUtils", package: "swift-nio"),
|
||||
.product(name: "Logging", package: "swift-log"),
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,24 @@
|
||||
// swift-tools-version:6.0
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "imap-fuzzer-example",
|
||||
platforms: [
|
||||
.macOS(.v15)
|
||||
],
|
||||
dependencies: [
|
||||
.package(name: "swift-nio-imap", path: "../.."),
|
||||
.package(url: "https://github.com/apple/swift-nio", from: "2.64.0"),
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
name: "NIOIMAPFuzzer",
|
||||
dependencies: [
|
||||
.product(name: "NIOIMAP", package: "swift-nio-imap"),
|
||||
.product(name: "NIO", package: "swift-nio"),
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
File renamed without changes.
@@ -0,0 +1,22 @@
|
||||
// swift-tools-version:6.0
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "imap-performance-tester-example",
|
||||
platforms: [
|
||||
.macOS(.v15)
|
||||
],
|
||||
dependencies: [
|
||||
.package(name: "swift-nio-imap", path: "../..")
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
name: "NIOIMAPPerformanceTester",
|
||||
dependencies: [
|
||||
.product(name: "NIOIMAP", package: "swift-nio-imap")
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,26 @@
|
||||
// swift-tools-version:6.0
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "imap-proxy-example",
|
||||
platforms: [
|
||||
.macOS(.v15)
|
||||
],
|
||||
dependencies: [
|
||||
.package(name: "swift-nio-imap", path: "../.."),
|
||||
.package(url: "https://github.com/apple/swift-nio", from: "2.64.0"),
|
||||
.package(url: "https://github.com/apple/swift-nio-ssl", from: "2.24.0"),
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
name: "Proxy",
|
||||
dependencies: [
|
||||
.product(name: "NIOIMAP", package: "swift-nio-imap"),
|
||||
.product(name: "NIO", package: "swift-nio"),
|
||||
.product(name: "NIOSSL", package: "swift-nio-ssl"),
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,29 @@
|
||||
# Examples
|
||||
|
||||
This directory contains example projects built on top of `swift-nio-imap`.
|
||||
Each subdirectory is its **own standalone Swift package** that depends on the library
|
||||
in the repository root via a local path dependency (`.package(path: "../..")`).
|
||||
|
||||
Keeping them out of the root package means the library's own dependency graph stays
|
||||
minimal — consumers of `NIOIMAP` don't resolve example-only dependencies such as
|
||||
`swift-log` or `swift-nio-ssl`.
|
||||
|
||||
| Example | What it is |
|
||||
| --- | --- |
|
||||
| [`CLI`](CLI) | A command-line interface plus its supporting `CLILib` (with tests). |
|
||||
| [`Proxy`](Proxy) | An IMAP proxy that logs the traffic flowing through it. |
|
||||
| [`Fuzzer`](Fuzzer) | Fuzzing harness for the IMAP parser (`NIOIMAPFuzzer`). |
|
||||
| [`PerformanceTester`](PerformanceTester) | Micro-benchmarks for parsing/encoding (`NIOIMAPPerformanceTester`). |
|
||||
|
||||
## Building and running
|
||||
|
||||
Each example builds independently. From the repository root:
|
||||
|
||||
```sh
|
||||
swift build --package-path Examples/CLI
|
||||
swift run --package-path Examples/CLI CLI --help
|
||||
```
|
||||
|
||||
Because they are separate packages, `swift build` / `swift test` at the repository
|
||||
root builds only the library targets — not these examples. CI builds them via a
|
||||
dedicated `Build examples` job.
|
||||
@@ -10,18 +10,10 @@ let package = Package(
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/apple/swift-nio", from: "2.64.0"),
|
||||
.package(url: "https://github.com/apple/swift-nio-ssl", from: "2.24.0"),
|
||||
.package(url: "https://github.com/apple/swift-log", from: "1.4.4"),
|
||||
.package(url: "https://github.com/apple/swift-se0270-range-set.git", from: "1.0.1"),
|
||||
.package(url: "https://github.com/apple/swift-collections.git", "1.1.0"..<"2.0.0"),
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
name: "NIOIMAPPerformanceTester",
|
||||
dependencies: [
|
||||
"NIOIMAP"
|
||||
]
|
||||
),
|
||||
.target(
|
||||
name: "NIOIMAP",
|
||||
dependencies: [
|
||||
@@ -54,46 +46,5 @@ let package = Package(
|
||||
.product(name: "NIOTestUtils", package: "swift-nio"),
|
||||
]
|
||||
),
|
||||
|
||||
.executableTarget(
|
||||
name: "CLI",
|
||||
dependencies: [
|
||||
"CLILib"
|
||||
]
|
||||
),
|
||||
.target(
|
||||
name: "CLILib",
|
||||
dependencies: [
|
||||
"NIOIMAP",
|
||||
.product(name: "NIO", package: "swift-nio"),
|
||||
.product(name: "NIOSSL", package: "swift-nio-ssl"),
|
||||
.product(name: "Logging", package: "swift-log"),
|
||||
]
|
||||
),
|
||||
.testTarget(
|
||||
name: "CLILibTests",
|
||||
dependencies: [
|
||||
"CLILib",
|
||||
.product(name: "NIO", package: "swift-nio"),
|
||||
.product(name: "NIOTestUtils", package: "swift-nio"),
|
||||
]
|
||||
),
|
||||
|
||||
.executableTarget(
|
||||
name: "Proxy",
|
||||
dependencies: [
|
||||
"NIOIMAP",
|
||||
.product(name: "NIO", package: "swift-nio"),
|
||||
.product(name: "NIOSSL", package: "swift-nio-ssl"),
|
||||
]
|
||||
),
|
||||
|
||||
.executableTarget(
|
||||
name: "NIOIMAPFuzzer",
|
||||
dependencies: [
|
||||
"NIOIMAP",
|
||||
.product(name: "NIO", package: "swift-nio"),
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
Reference in new issue
Block a user