Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add OpenRPC API docs and associated JSON Schemas #534

Merged
merged 78 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
d1c7b95
feat: Add TaggedSchema trait
bgins Jan 14, 2024
aa93468
feat: Add OpenRPC document generator
bgins Jan 16, 2024
42e560c
feat: Add API and schema generator
bgins Jan 16, 2024
e07dca5
feat: Add health schema
bgins Jan 18, 2024
c2d1a21
refactor: Remove internal tagging
bgins Jan 18, 2024
a648159
feat: Add initial network notification implementations
bgins Jan 18, 2024
5eb7318
feat: Add OpenRPC x-messages extension
bgins Jan 19, 2024
0e55222
feat: Add health API method
bgins Jan 19, 2024
d0cb604
chore: Add IPLD schema generator
bgins Jan 23, 2024
ef12a0b
chore: Update import
bgins Jan 23, 2024
9b88f19
feat: Add workflow schema
bgins Jan 23, 2024
6b8e09e
chore: Add network event emitter
bgins Jan 24, 2024
7a905d6
feat: Add receipt and receipt notification schemas
bgins Jan 25, 2024
111d7eb
refactor: Add NodeInfo struct
bgins Jan 25, 2024
be9ec07
feat: Add node info schema
bgins Jan 25, 2024
bb5bcd3
feat: Add unsubscribe API methods
bgins Jan 25, 2024
8b7c687
feat: Add metrics schema
bgins Jan 26, 2024
674c44b
chore: Set homestar as default binary
bgins Jan 26, 2024
e134d7f
test: Add network notification testing apparatus
bgins Jan 29, 2024
9e0c53b
test: Fix nodeinfo test
bgins Jan 29, 2024
66f2b76
feat: Add mDNS discovered notification
bgins Jan 29, 2024
b6de6f8
wip: Add rendezvous discovery notifications
bgins Jan 30, 2024
cebd548
spawn + cache
zeeshanlakhani Jan 30, 2024
9001e97
wip: More work on discovery notifications
bgins Jan 31, 2024
448f379
async cache
zeeshanlakhani Jan 31, 2024
86de5ed
feat: Finish discovery notifications, schemas, and test upgrades
bgins Feb 1, 2024
6edfe10
chore: Update redial test notifications
bgins Feb 1, 2024
0120c55
feat: Add listen and connection error notifications
bgins Feb 1, 2024
2c75407
chore: Add network notification display impl
bgins Feb 1, 2024
110fc5a
chore: Smarter use of key consts
bgins Feb 1, 2024
121ad7e
feat: Add gossip notifications and schemas
bgins Feb 1, 2024
823afbd
feat: Add receipt DHT notifications
bgins Feb 2, 2024
146eb4e
feat: Add workflow info DHT notifications
bgins Feb 2, 2024
bf79525
feat: Add receipt quorum notifications
bgins Feb 2, 2024
2562599
feat: Add workflow info quorum notifications
bgins Feb 2, 2024
acb4b42
feat: Add request response notifications
bgins Feb 3, 2024
9ad2516
chore: Remove vestiges of old swarm notifications
bgins Feb 3, 2024
4c60317
chore: Remove unused feature flag
bgins Feb 5, 2024
38fdf6a
feat: Add OpenRPC API doc and JSON Schemas
bgins Feb 5, 2024
943cbf0
feat: Add OpenRPC discover endpoint
bgins Feb 6, 2024
b5ffd81
test: Consolidate connection tests
bgins Feb 6, 2024
191c3e3
test: Separate out node info test
bgins Feb 6, 2024
e0ec4cf
test: Add OpenRPC discovery endpoint test
bgins Feb 6, 2024
102cac7
chore: Merge branch 'main' into bgins/schemas-and-api-docs
bgins Feb 6, 2024
ea1d420
test: Stabilize mDNS connect test
bgins Feb 7, 2024
b855285
test: Add subscribe_network_events test helper
bgins Feb 7, 2024
7b9ed11
chore: Merge branch 'main' into bgins/schemas-and-api-docs
bgins Feb 7, 2024
436187a
test: Refactor rendezvous tests
bgins Feb 7, 2024
6f8998a
test: Refactor mDNS tests
bgins Feb 7, 2024
fc70e06
test: Less backtrace noize
bgins Feb 7, 2024
fcca2f7
feat: Add schemas generation workflow
bgins Feb 7, 2024
4a54efd
chore: Rename subscribe workflow param to tasks
bgins Feb 7, 2024
dfaf407
chore: Tinker with schemas action
bgins Feb 8, 2024
d9d2d15
chore(schemas): update OpenRPC API doc and JSON schemas
bgins Feb 8, 2024
e2160e2
chore: More tinkering
bgins Feb 8, 2024
6e6efea
chore: Remove unneeded feature flag
bgins Feb 8, 2024
ecc4e4f
chore: Move schema generator into non-published crate
bgins Feb 8, 2024
873b417
chore: Add missing websocket-notify flags
bgins Feb 8, 2024
dd0f631
chore: More schemas action tweaks
bgins Feb 8, 2024
a0fd065
chore: More schemas action tinkering part two
bgins Feb 8, 2024
05545ab
chore: Merge branch 'main' into bgins/schemas-and-api-docs
bgins Feb 8, 2024
7d85584
chore: More schema action tinkering part three
bgins Feb 8, 2024
30854db
chore: More tinkering part four
bgins Feb 8, 2024
54fc095
chore: Clean up schema action
bgins Feb 8, 2024
63e778c
chore: Update homestar-schemas version
bgins Feb 8, 2024
0526463
chore: Update dependabot action modified file check
bgins Feb 8, 2024
ac554e6
chore: Only run schemas action on push to main
bgins Feb 8, 2024
8fe6b45
chore: Align OpenRPC API version with workspace
bgins Feb 9, 2024
42f6379
chore: Update param structure values
bgins Feb 9, 2024
9326cc5
chore: Remove unused Ipld from schema stubs
bgins Feb 9, 2024
1b608ba
chore: docker + feature flag apply correction
zeeshanlakhani Feb 9, 2024
bacf7a2
chore: Make network notification imports explicit
bgins Feb 9, 2024
5de960f
chore: Update schema generation action checout ref
bgins Feb 9, 2024
2202635
chore: Break network notifications into modules
bgins Feb 12, 2024
1c84b24
chore: Update schemars version
bgins Feb 12, 2024
a611a48
chore: Update schema id module paths
bgins Feb 12, 2024
d4d196c
chore: Use minor version derive-getters
bgins Feb 13, 2024
590135a
chore: Document OpenRPC API and schemas
bgins Feb 13, 2024
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 @@ -10,7 +10,9 @@
!**/migrations
!diesel.toml
!**/wit
!**/schemas/api.json

examples
homestar-functions
homestar-workspace-hack
homestar-schemas
2 changes: 1 addition & 1 deletion .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 🛡 Audit-Check

on:
schedule:
- cron: '0 0 * * *'
- cron: "0 0 * * *"

jobs:
security-audit:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: ☂ Code Coverage

on:
push:
branches: [ main ]
branches: [main]

pull_request:
branches: [ '*' ]
branches: ["*"]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependabot_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: Check for modified files
id: git-check
run: echo modified=$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi) >> $GITHUB_OUTPUT
run: echo modified=$(if [[ $(git diff) ]]; then echo "true"; else echo "false"; fi) >> $GITHUB_OUTPUT

- name: Push changes
if: steps.git-check.outputs.modified == 'true'
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/schemas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: 📄 Schemas

on:
push:
branches: [main]
# branches: [main, "**"]

permissions:
contents: write
pull-requests: write

jobs:
changes:
runs-on: ubuntu-latest
outputs:
rust: ${{ steps.filter.outputs.rust }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
rust:
- 'homestar-invocation/src/**'
- 'homestar-runtime/src/**'
- 'homestar-schemas/src/**'
- 'homestar-workflow/src/**'

schemas:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' }}
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.HOMESTAR_UPDATE_TOKEN }}

- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable

- name: Cache Project
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
shared-key: test-all-stable-ubuntu-latest
save-if: ${{ github.event_name == 'push' }}

- name: Sccache
uses: mozilla-actions/[email protected]

- name: Run generate schemas
run: cargo run -p homestar-schemas

- name: Check for modified schemas
id: git-check
shell: bash
run: echo modified=$(if [[ $(git diff homestar-runtime/schemas/) ]]; then echo "true"; else echo "false"; fi) >> $GITHUB_OUTPUT

- name: Push changes
if: steps.git-check.outputs.modified == 'true'
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
git commit -am "chore(schemas): update OpenRPC API doc and JSON schemas"
git push
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ repos:
- id: check-merge-conflict
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: \.txt$
exclude: \.(txt|json)$
- id: check-yaml
- id: check-json
- id: check-added-large-files
Expand Down
84 changes: 78 additions & 6 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"homestar-functions/*",
"homestar-invocation",
"homestar-runtime",
"homestar-schemas",
"homestar-wasm",
"homestar-workflow",
"homestar-workspace-hack",
Expand Down Expand Up @@ -34,6 +35,7 @@ chrono = { version = "0.4", default-features = false, features = [
"clock",
"std",
] }
const_format = "0.2"
enum-assoc = "1.1"
enum-as-inner = "0.6"
faststr = { version = "0.2", default-features = false, features = ["serde"] }
Expand All @@ -51,7 +53,11 @@ libsqlite3-sys = { version = "0.27", default-features = false, features = [
"bundled",
] }
rand = { version = "0.8", default-features = false }
schemars = { version = "0.8", features = ["arrayvec", "url"] }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = { version = "1.0", default-features = false, features = [
"raw_value",
] }
serde_ipld_dagcbor = { version = "0.4", default-features = false, features = [
"std",
] }
Expand Down
6 changes: 5 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ RUN cargo init --lib homestar-invocation && \

RUN echo "fn main() {}" > ./homestar-runtime/src/main.rs

RUN mkdir -p ./homestar-runtime/src/test_utils/proc_macro ./homestar-runtime/migrations ./examples ./homestar-functions
RUN mkdir -p ./homestar-runtime/src/test_utils/proc_macro ./homestar-runtime/migrations \
./examples ./homestar-functions ./homestar-schemas
RUN bash -c 'pushd ./examples && cargo init dummy-app-examples && popd'
RUN bash -c 'pushd ./homestar-functions && cargo init dummy-app-fns && popd'
RUN cargo init homestar-schemas
RUN cargo init --lib homestar-workspace-hack

# copy cargo.*
Expand All @@ -43,6 +45,7 @@ COPY ../homestar-workflow/Cargo.toml ./homestar-workflow/
COPY ../homestar-wasm/Cargo.toml ./homestar-wasm/
COPY ../homestar-runtime/Cargo.toml ./homestar-runtime/
COPY ../homestar-runtime/migrations ./homestar-runtime/migrations
COPY ../homestar-runtime/schemas/api.json ./homestar-runtime/schemas/api.json
COPY ../homestar-runtime/src/test_utils/proc_macro ./homestar-runtime/src/test_utils/proc_macro

ENTRYPOINT ["/bin/bash"]
Expand Down Expand Up @@ -91,6 +94,7 @@ WORKDIR /home/runner

COPY --chown=homestar:homestar diesel.toml ./
COPY --chown=homestar:homestar ../homestar-runtime/migrations ./migrations
COPY --chown=homestar:homestar ../homestar-runtime/schemas ./schemas
COPY --chown=homestar:homestar --from=builder /usr/local/bin/homestar-runtime ./homestar
COPY --chown=homestar:homestar --from=builder /usr/local/bin/diesel /usr/local/bin/diesel
COPY --chown=homestar:homestar --from=builder /etc/*.db ./
Expand Down
3 changes: 3 additions & 0 deletions homestar-invocation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ doctest = true
anyhow = { workspace = true }
async-recursion = { version = "1.0", default-features = false }
byte-unit = { workspace = true }
const_format = { workspace = true }
diesel = { version = "2.1", default-features = false, features = [
"sqlite",
], optional = true }
Expand All @@ -36,7 +37,9 @@ homestar-workspace-hack = { workspace = true }
libipld = { workspace = true }
libsqlite3-sys = { workspace = true, optional = true }
rand = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
signature = "2.2"
thiserror = { workspace = true }
tracing = { workspace = true }
Expand Down
Loading
Loading