Skip to content

Commit

Permalink
book: enable Swift Package tests
Browse files Browse the repository at this point in the history
* Downgrade `swift-tools-version` to 5.5

Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Nov 26, 2024
1 parent f858009 commit d212090
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 12 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ concurrency:
jobs:
check-book:
name: Check book
runs-on: ubuntu-latest
runs-on: macos-latest # Use macOS to check also Swift snippets
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install just
run: cargo install just

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.12"

# Required for kotlin snippets
- name: Set up Java 17
uses: actions/setup-java@v2
Expand Down Expand Up @@ -67,4 +72,4 @@ jobs:

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
uses: actions/deploy-pages@v3
5 changes: 4 additions & 1 deletion book/snippets/justfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test: rust python js kotlin
test: rust python js kotlin swift

rust:
cd rust && cargo build
Expand All @@ -11,3 +11,6 @@ js:

kotlin:
cd kotlin && just test

swift:
cd swift && just test
6 changes: 3 additions & 3 deletions book/snippets/swift/NostrSnippets/Package.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// swift-tools-version: 5.9
// swift-tools-version: 5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "NostrSnippets",
platforms: [.macOS(.v13)],
platforms: [.macOS(.v12)],
dependencies: [
.package(url: "https://github.com/rust-nostr/nostr-sdk-swift", from:"0.36.0")
.package(url: "https://github.com/rust-nostr/nostr-sdk-swift", from: "0.36.0")
],
targets: [
.executableTarget(
Expand Down
9 changes: 8 additions & 1 deletion book/snippets/swift/NostrSnippets/Sources/Keys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ import NostrSDK
import Foundation

func keys() {
// TODO
// ANCHOR: generate
let keys = Keys.generate()
print("Public key (hex): \(keys.publicKey.toHex())")
print("Secret key (hex): \(keys.secretKey.toHex())")

print("Public key (bech32): \(keys.publicKey.toBech32())")
print("Secret key (bech32): \(keys.secretKey.toBech32())")
// ANCHOR_END: generate
}
4 changes: 0 additions & 4 deletions book/snippets/swift/NostrSnippets/justfile

This file was deleted.

13 changes: 13 additions & 0 deletions book/snippets/swift/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env just --justfile

[macos]
test:
cd NostrSnippets && swift build && swift run

[linux]
test:
@echo "This command is not supported on Linux platforms (require macOS)."

[windows]
test:
@echo "This command is not supported on Windows platforms (require macOS)."
2 changes: 1 addition & 1 deletion book/src/sdk/signers/keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ To generate a new key pair use the `generate()` method:
<section>

```swift,ignore
{{#include ../../../snippets/swift/NostrSnippets/Sources/Keys.swift}}
{{#include ../../../snippets/swift/NostrSnippets/Sources/Keys.swift:generate}}
```

</section>
Expand Down

0 comments on commit d212090

Please sign in to comment.