Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
**/node_modules
**/.gradle
/foreign/swift/.build
/bdd/swift/**/.build
/examples/swift/**/.build
/foreign/java/**/build
/bdd/java/build
/examples/java/**/build
Expand Down
7 changes: 6 additions & 1 deletion .github/actions/swift/pre-merge/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ runs:
uses: ./.github/actions/utils/setup-swift

# swift-format ships with the toolchain; the configuration lives in
# foreign/swift/.swift-format.
# foreign/swift/.swift-format and covers the examples and the BDD runner
# too, which compile in their own lanes.
- name: Format Check
shell: bash
if: inputs.task == 'lint'
run: |
cd foreign/swift
swift format lint --strict --recursive Sources Tests Examples Package.swift
cd ../..
for package in examples/swift/getting-started bdd/swift/tests; do
swift format lint --strict --recursive --configuration foreign/swift/.swift-format "$package/Sources" "$package/Package.swift"
done

# A warning-free build is the lint gate the Swift compiler provides: the
# SDK builds in Swift 6 language mode with strict concurrency checking.
Expand Down
16 changes: 10 additions & 6 deletions .github/actions/utils/setup-swift/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ inputs:
description: "Cache key segment naming the package that builds in the job; one constant per package so every lane shares one cache"
required: false
default: "sdk"
package-path:
description: "Directory of the SwiftPM package whose build directory is cached"
required: false
default: "foreign/swift"

runs:
using: "composite"
Expand Down Expand Up @@ -83,11 +87,11 @@ runs:
uses: actions/cache@v6.1.0
with:
path: |
foreign/swift/.build/checkouts
foreign/swift/.build/repositories
foreign/swift/.build/artifacts
foreign/swift/.build/debug
foreign/swift/.build/release
key: swiftpm-${{ runner.os }}-${{ steps.swift.outputs.version }}-${{ inputs.cache-key }}-${{ hashFiles('foreign/swift/Package.resolved') }}
${{ inputs.package-path }}/.build/checkouts
${{ inputs.package-path }}/.build/repositories
${{ inputs.package-path }}/.build/artifacts
${{ inputs.package-path }}/.build/debug
${{ inputs.package-path }}/.build/release
key: swiftpm-${{ runner.os }}-${{ steps.swift.outputs.version }}-${{ inputs.cache-key }}-${{ hashFiles(format('{0}/Package.resolved', inputs.package-path)) }}
restore-keys: |
swiftpm-${{ runner.os }}-${{ steps.swift.outputs.version }}-${{ inputs.cache-key }}-
15 changes: 14 additions & 1 deletion .github/config/components.yml
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,13 @@ components:
bdd-swift:
depends_on:
- "rust-server"
- "rust-sdk"
- "sdk-swift"
- "bdd-infrastructure"
- "ci-infrastructure"
paths:
- "bdd/swift/**"
- "bdd/scenarios/deferred_polling.feature"
- "bdd/scenarios/**"
tasks: ["bdd-swift"]

examples-rust:
Expand Down Expand Up @@ -563,6 +564,18 @@ components:
- "scripts/utils.sh"
tasks: ["examples-java"]

examples-swift:
depends_on:
- "rust-server"
- "rust-sdk" # All SDKs depend on core SDK changes
- "sdk-swift"
- "ci-infrastructure"
paths:
- "examples/swift/**"
- "scripts/run-examples-from-readme.sh"
- "scripts/utils.sh"
tasks: ["examples-swift"]

web-ui:
paths:
- "web/**"
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/_test_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ jobs:
with:
download-deps: "false"

- name: Setup Swift for examples
if: matrix.task == 'examples-swift'
uses: ./.github/actions/utils/setup-swift
with:
cache-key: "examples"
package-path: "examples/swift/getting-started"

# Built before the server starts, so each example run only executes.
- name: Build Swift examples
if: matrix.task == 'examples-swift'
run: swift build --package-path examples/swift/getting-started -Xswiftc -warnings-as-errors

- name: Test Go examples
if: matrix.task == 'examples-go'
working-directory: examples/go
Expand Down Expand Up @@ -178,6 +190,10 @@ jobs:
if: matrix.task == 'examples-java'
run: ./scripts/run-examples-from-readme.sh --language java

- name: Run Swift examples
if: matrix.task == 'examples-swift'
run: ./scripts/run-examples-from-readme.sh --language swift

- name: Upload reports
if: always()
uses: actions/upload-artifact@v7
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ This checkout moves the binary protocol to 0.12.0 and the metadata snapshot form
- [Node.js (TypeScript)](https://www.npmjs.com/package/apache-iggy)
- [Go](https://pkg.go.dev/github.com/apache/iggy/foreign/go)

[C++](https://github.com/apache/iggy/tree/master/foreign/cpp) and [PHP](https://github.com/apache/iggy/tree/master/foreign/php) are work in progress.
[C++](https://github.com/apache/iggy/tree/master/foreign/cpp), [PHP](https://github.com/apache/iggy/tree/master/foreign/php), and [Swift](https://github.com/apache/iggy/tree/master/foreign/swift) are work in progress.

---

Expand Down
14 changes: 13 additions & 1 deletion bdd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ bdd/
│ ├── Dockerfile # PHP BDD test container
│ ├── phpunit.xml.dist
│ └── tests/
├── swift/ # Swift SDK BDD implementation
│ ├── Dockerfile # Swift BDD test container
│ └── tests/ # SwiftPM package with the Gherkin runner and steps
├── docker-compose.yml # Base: SDK test clients (always included)
├── docker-compose.server.yml # Single iggy-server test setup
├── docker-compose.cluster.yml # Leader + follower test setup
Expand All @@ -50,7 +53,7 @@ bdd/

```bash
# Usage: ../scripts/run-bdd-tests.sh [--coverage] <sdk> [feature]
# sdk: rust | python | php | go | go-race | node | csharp | java | all | clean (default: all)
# sdk: rust | python | php | go | go-race | node | csharp | java | cpp | swift | all | clean (default: all)
# feature: basic_messaging | leader_redirection | raw_command | session_contract | stream_crud | all (default: all)

# Run all features for all SDKs
Expand All @@ -64,6 +67,7 @@ bdd/
../scripts/run-bdd-tests.sh csharp
../scripts/run-bdd-tests.sh java
../scripts/run-bdd-tests.sh php
../scripts/run-bdd-tests.sh swift

# Run only basic_messaging feature for Rust SDK
../scripts/run-bdd-tests.sh rust basic_messaging
Expand Down Expand Up @@ -135,6 +139,14 @@ The Java implementation is located in `java/src/test/`

The PHP implementation is located in `bdd/php/tests/` and runs through PHPUnit.

### For Swift SDK

The Swift implementation is located in `bdd/swift/tests/`, a SwiftPM package with a small Gherkin
runner that walks the shared feature files and drives the SDK. It runs every feature but
`leader_redirection` and `stream_crud`. Outside Docker, set `IGGY_TCP_ADDRESS`,
`IGGY_TCP_ADDRESS_NO_QUORUM`, `IGGY_ROOT_USERNAME`, and `IGGY_ROOT_PASSWORD`, then run
`swift run iggy-bdd`, with `BDD_FEATURE` to pick one feature.

### Adding New Scenarios

Add new `.feature` files to the `bdd/scenarios/` directory and implement the corresponding step definitions in each SDK's test directory.
27 changes: 12 additions & 15 deletions bdd/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,37 +234,34 @@ services:
networks:
- iggy-bdd-network

cpp-bdd:
image: iggy-bdd-cpp
swift-bdd:
image: iggy-bdd-swift
build:
context: ..
dockerfile: bdd/cpp/Dockerfile
dockerfile: bdd/swift/Dockerfile
environment:
- IGGY_ROOT_USERNAME=iggy
- IGGY_ROOT_PASSWORD=iggy
- BDD_FEATURE=${BDD_FEATURE:-all}
volumes:
- ./scenarios/basic_messaging.feature:/app/features/basic_messaging.feature
- ./scenarios/raw_command.feature:/app/features/raw_command.feature
- ./scenarios/stream_options.feature:/app/features/stream_options.feature
- ./scenarios/resource_options_patch.feature:/app/features/resource_options_patch.feature
- ./scenarios/metadata_changes.feature:/app/features/metadata_changes.feature
- ./scenarios/session_contract.feature:/app/features/session_contract.feature
- ./scenarios/deferred_polling.feature:/app/features/deferred_polling.feature
networks:
- iggy-bdd-network

# Runs only the deferred polling feature.
swift-bdd:
image: iggy-bdd-swift
cpp-bdd:
image: iggy-bdd-cpp
build:
context: ..
dockerfile: bdd/swift/Dockerfile
dockerfile: bdd/cpp/Dockerfile
environment:
- IGGY_ROOT_USERNAME=iggy
- IGGY_ROOT_PASSWORD=iggy
- BDD_FEATURE=${BDD_FEATURE:-all}
volumes:
- ./scenarios/basic_messaging.feature:/app/features/basic_messaging.feature
- ./scenarios/raw_command.feature:/app/features/raw_command.feature
- ./scenarios/stream_options.feature:/app/features/stream_options.feature
- ./scenarios/resource_options_patch.feature:/app/features/resource_options_patch.feature
- ./scenarios/metadata_changes.feature:/app/features/metadata_changes.feature
- ./scenarios/session_contract.feature:/app/features/session_contract.feature
- ./scenarios/deferred_polling.feature:/app/features/deferred_polling.feature
networks:
- iggy-bdd-network
Expand Down
21 changes: 13 additions & 8 deletions bdd/swift/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@
# specific language governing permissions and limitations
# under the License.

# Swift BDD runner: builds the Swift SDK and the runner, which parses the
# mounted feature files and runs their scenarios on the SDK. The toolchain
# matches .github/actions/utils/setup-swift.
FROM swift:6.4.0
# The Swift version and Ubuntu release the Linux CI lanes install.
FROM swift:6.4.0-resolute

WORKDIR /app

# The SDK is a path dependency of the runner, so it keeps its place
# relative to the runner as in the repository.
COPY foreign/swift ./foreign/swift
COPY bdd/swift ./bdd/swift
COPY bdd/scenarios/deferred_polling.feature ./features/
COPY bdd/swift/tests/Package.swift bdd/swift/tests/Package.resolved ./bdd/swift/tests/

WORKDIR /app/bdd/swift/tests
RUN swift package resolve

RUN cd bdd/swift/runner && swift build --product iggy-bdd
COPY bdd/swift/tests/Sources ./Sources
COPY bdd/scenarios /app/bdd/scenarios
RUN swift build -Xswiftc -warnings-as-errors

CMD ["/app/bdd/swift/runner/.build/debug/iggy-bdd", "/app/features"]
CMD ["swift", "run", "--skip-build", "iggy-bdd"]
109 changes: 0 additions & 109 deletions bdd/swift/runner/Sources/Gherkin.swift

This file was deleted.

Loading
Loading