Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

Commit

Permalink
feat: Add SphereFS read/write to FFI (#141)
Browse files Browse the repository at this point in the history
This change also adds automated Swift testing to our Github Actions workflow.

BREAKING CHANGE: Some FFI interfaces now have simplified interfaces.
  • Loading branch information
cdata authored Nov 14, 2022
1 parent 14dae2f commit 26e34ac
Show file tree
Hide file tree
Showing 21 changed files with 603 additions and 102 deletions.
94 changes: 72 additions & 22 deletions .github/workflows/noosphere_apple_build.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,63 @@
on:
- workflow_call
- workflow_dispatch
workflow_call:
inputs:
for-test:
type: boolean
default: false
workflow_dispatch:
inputs:
for-test:
description: 'MacOS x86_64 support only'
type: boolean
default: false

name: 'Build Noosphere artifacts (Apple)'

jobs:
determine-build-matrix:
name: 'Determine build matrix'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
env:
FOR_TEST: ${{ inputs.for-test }}
run: |
if [[ $FOR_TEST == true ]]; then
targets=("x86_64-apple-darwin")
else
targets=(
"aarch64-apple-ios"
"x84_64-apple-ios"
"aarch64-apple-ios-sim"
"x86_64-apple-darwin"
"aarch64-apple-darwin"
)
fi
echo -n 'matrix={"include":[' >> $GITHUB_OUTPUT
target_out=""
for target in "${targets[@]}"; do
target_json="{\"target\":\"$target\"}"
if [ -z "$target_out" ]; then
target_out="$target_json"
else
target_out="$target_out,$target_json"
fi
done
echo -n "$target_out ]}" >> $GITHUB_OUTPUT
# Build Noosphere out of the noosphere crate for Apple targets
noosphere-apple-build:
name: 'Build Noosphere libraries (Apple)'
needs: ['determine-build-matrix']
strategy:
fail-fast: false
matrix:
include:
# iOS
- target: aarch64-apple-ios
# iOS Simulator
- target: x86_64-apple-ios
- target: aarch64-apple-ios-sim
# Mac OS
- target: x86_64-apple-darwin
- target: aarch64-apple-darwin

fail-fast: true
matrix: ${{ fromJSON(needs.determine-build-matrix.outputs.matrix) }}
runs-on: macos-12
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -92,14 +129,17 @@ jobs:
runs-on: macos-12
steps:
- uses: actions/download-artifact@v3
if: ${{ !inputs.for-test }}
- name: 'Make a universal library'
if: ${{ !inputs.for-test }}
run: |
lipo -create \
./lib_${{ matrix.legacy_target }}/libnoosphere.a \
./lib_${{ matrix.future_target }}/libnoosphere.a \
-output ./libnoosphere.a
- uses: actions/upload-artifact@v3
if: ${{ !inputs.for-test }}
with:
name: lib_${{ matrix.platform }}-universal
path: libnoosphere.a
Expand All @@ -113,15 +153,25 @@ jobs:
steps:
- uses: actions/download-artifact@v3
- name: 'Generate XCFramework'
env:
FOR_TEST: ${{ inputs.for-test }}
run: |
xcodebuild -create-xcframework \
-library ./lib_macos-universal/libnoosphere.a \
-headers ./include/ \
-library ./lib_ios-simulator-universal/libnoosphere.a \
-headers ./include/ \
-library ./lib_aarch64-apple-ios/libnoosphere.a \
-headers ./include/ \
-output ./LibNoosphere.xcframework
if [ "$FOR_TEST" = true ]; then
xcodebuild -create-xcframework \
-library ./lib_x86_64-apple-darwin/libnoosphere.a \
-headers ./include/ \
-output ./LibNoosphere.xcframework
else
xcodebuild -create-xcframework \
-library ./lib_macos-universal/libnoosphere.a \
-headers ./include/ \
-library ./lib_ios-simulator-universal/libnoosphere.a \
-headers ./include/ \
-library ./lib_aarch64-apple-ios/libnoosphere.a \
-headers ./include/ \
-output ./LibNoosphere.xcframework
fi
zip -r ./libnoosphere-apple-xcframework.zip ./LibNoosphere.xcframework
- uses: actions/upload-artifact@v3
with:
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,34 @@ jobs:
libnoosphere-apple-xcframework.zip.sha256
tag_name: ${{ needs['release-please'].outputs.noosphere_release_tag_name }}

update-swift-noosphere-binary-target:
name: 'Update SwiftNoosphere binary target'
needs: ['release-please', 'noosphere-release-artifacts']
runs-on: ubuntu-latest
steps:
- name: 'Download XCode Framework artifact'
uses: actions/download-artifact@v3
with:
name: libnoosphere_apple_framework

- name: 'Generate checksum'
id: generate-checksum
run: |
CHECKSUM=`openssl dgst -r -sha256 ./libnoosphere-apple-xcframework.zip | cut -d " " -f 1`
echo "checksum=\"$CHECKSUM\"" >> $GITHUB_OUTPUT
- name: 'Modify Package.swift'
run: |
URL="https://github.com/subconsciousnetwork/noosphere/releases/download/${{ needs.release-please.outputs.noosphere_release_tag_name }}/libnoosphere-apple-xcframework.zip"
sed -i '' -e "s#url: \"[^\"]*\",#url: \"$URL\",#" ./Package.swift
sed -i '' -e "s#checksum: \"[^\"]*\"),#checksum: \"${{ steps.generate-checksum.checksum }}\"),#" ./Package.swift
# TODO(#135): Evaluate if we want to automatically check this change in
# and push it to the project repository
- uses: actions/upload-artifact@v3
with:
name: swift-package-manifest
path: ./Package.swift

# Publishes crates to crates.io in dependency order. This command is
# idempotent and won't re-publish crates that are already published, so it's
# safe for us to run it indiscriminately
Expand Down
32 changes: 30 additions & 2 deletions .github/workflows/run_test_suite.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
on: [push, pull_request]
on:
push:
branches: [main]
pull_request:

name: Run test suite

jobs:
run-test-suite:
build-noosphere-apple-artifacts:
name: 'Build Noosphere artifacts (Apple)'
uses: ./.github/workflows/noosphere_apple_build.yaml
with:
for-test: true

run-test-suite-mac-os:
runs-on: macos-12
needs: ['build-noosphere-apple-artifacts']
steps:
- uses: actions/checkout@v2
- name: 'Download XCode Framework artifact'
uses: actions/download-artifact@v3
with:
name: libnoosphere_apple_framework

- name: 'Run Swift tests'
run: |
unzip ./libnoosphere-apple-xcframework.zip
sed -i '' -e "s#url: \"[^\"]*\",#path: \"./LibNoosphere.xcframework\"),#" ./Package.swift
sed -i '' -e "s#checksum: \"[^\"]*\"),##" ./Package.swift
swift build
swift test
run-test-suite-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
8 changes: 1 addition & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue)
[![Discord](https://img.shields.io/discord/1003419732516552724.svg?logo=discord&colorB=7289DA)](https://discord.gg/HmHypb6DCj)

# Noosphere
<picture>
<source media="(prefers-color-scheme: dark)" srcset="design/images/noosphere-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="design/images/noosphere-light.svg">
<img alt="Noosphere" src="design/images/noosphere-light.svg">
</picture>

> Noosphere (noun):
>
> 1. Planetary consciousness. A hypothetical new evolutionary phenomena rising out of the biosphere.
> 2. A protocol for thought.
Expand Down Expand Up @@ -38,4 +43,3 @@ Apache-2.0: https://www.apache.org/licenses/license-2.0
[design]: https://github.com/subconsciousnetwork/noosphere/tree/main/design/
[roadmap]: https://github.com/orgs/subconsciousnetwork/projects/1/views/4
[noosphere-kanban]: https://github.com/orgs/subconsciousnetwork/projects/1/views/8

Loading

0 comments on commit 26e34ac

Please sign in to comment.