Skip to content

Commit

Permalink
feat: Add JSON-PRC API (#417)
Browse files Browse the repository at this point in the history
Includes:
  - re-purposing of feature flags
    * metrics is always a thing (on)
    * monitoring is the gated feature
    * The websocket-server flag is gone, we only gate push notifications
  - JSON-RPC setup and RPC method register
  - Prometheus exposition format to JSON parser

Other features and other fixes:

- [x] e2e testing of run workflow
- [x] #407
- [x] #410
- [x] #418
- [x] #424
- [x] #354
- [x] #409
- [x] #425
- [x] #426
- [x] #429
- [x] #433
- [x] #435
- [x] #421
- [x] #436
- [x] #437
- [x] #444
- [x] #438
- [x] #390
- [x] #451
- [x] #456

---------

Signed-off-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com>
Signed-off-by: Zeeshan Lakhani <zeeshan.lakhani@gmail.com>
Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com>
Co-authored-by: Hugo Dias <hugomrdias@gmail.com>
  • Loading branch information
3 people committed Nov 29, 2023
1 parent 47238ae commit 9b67136
Show file tree
Hide file tree
Showing 145 changed files with 11,282 additions and 5,904 deletions.
2 changes: 2 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ threads-required = 1
[profile.ci]
retries = { backoff = "exponential", count = 3, delay = "30s", jitter = true, max-delay = "300s" }
failure-output = "immediate-final"
leak-timeout = "800ms"
slow-timeout = { period = "120s", terminate-after = 2 }
fail-fast = false

[test-groups]
Expand Down
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use_flake

export RUST_LOG=homestar=debug,homestar_runtime=debug,libp2p=info,libp2p_gossipsub::behaviour=debug,tarpc=info,tower_http=debug,moka=debug
export RUST_LOG=homestar=debug,homestar_runtime=debug,libp2p=info,libp2p_gossipsub::behaviour=debug,tarpc=info,tower_http=debug,jsonrpsee_server=debug,moka=debug
export RUST_BACKTRACE=full
export RUSTFLAGS="--cfg tokio_unstable"
91 changes: 81 additions & 10 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

# for debugging
# pull_request:
# branches: [ '**' ]
# branches: ['**']

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -29,14 +29,19 @@ jobs:
include:
- target: aarch64-unknown-linux-gnu
- target: aarch64-unknown-linux-musl
npm: linux-arm64
- target: aarch64-apple-darwin
os: macos-latest
npm: darwin-arm64
- target: x86_64-unknown-linux-gnu
- target: x86_64-unknown-linux-musl
npm: linux-x64
- target: x86_64-apple-darwin
os: macos-latest
npm: darwin-x64
- target: x86_64-pc-windows-msvc
os: windows-latest
npm: windows-x64
- target: x86_64-unknown-freebsd

permissions:
Expand Down Expand Up @@ -94,25 +99,91 @@ jobs:
include: LICENSE,README.md
token: ${{ secrets.GITHUB_TOKEN }}

build-packages:
npm-publish:
needs: binary-builds
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-unknown-linux-musl
os: linux
arch: arm64
- target: x86_64-unknown-linux-musl
os: linux
arch: x64
- target: aarch64-apple-darwin
os: darwin
arch: arm64
- target: x86_64-apple-darwin
os: darwin
arch: x64
- target: x86_64-pc-windows-msvc
os: windows
arch: x64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: 'https://registry.npmjs.org'
- name: Install cargo get
run: cargo install cargo-get
- name: Prepare os/arch packages
shell: bash
env:
node_os: ${{ matrix.os }}
node_arch: ${{ matrix.arch }}
node_pkg: homestar-${{ matrix.os }}-${{ matrix.arch }}
run: |
export node_version=$(cargo get workspace.package.version)
echo "node_pkg=${node_pkg}" >> "$GITHUB_ENV"
cd homestar-runtime/npm
mkdir -p "${node_pkg}/bin"
envsubst < package.json.tmpl > "${node_pkg}/package.json"
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: ${{ matrix.target }}
path: 'homestar-runtime/npm/${{ env.node_pkg }}/bin'
- name: Publish production
if: github.event_name == 'release' && github.event.action == 'published'
run: |
cd "homestar-runtime/npm/${{ env.node_pkg }}"
npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish RC
if: github.event_name == 'workflow_dispatch'
run: |
cd "homestar-runtime/npm/${{ env.node_pkg }}"
npm version $(cargo get package.version)-rc.$(date +%s) --git-tag-version false
npm publish --access public --tag rc
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

env:
LINUX_TARGET: x86_64-unknown-linux-musl

build-packages:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
- target: x86_64-unknown-linux-musl
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install musl-tools
run: sudo apt update && sudo apt install -y musl-dev musl-tools
if: matrix.target == 'x86_64-unknown-linux-musl'

- name: Install Rust toolchain
id: toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ env.LINUX_TARGET }}
targets: ${{ matrix.target }}

- name: Override rust-toolchain.toml
run: rustup override set ${{steps.toolchain.outputs.name}}
Expand All @@ -131,18 +202,18 @@ jobs:
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
shared-key: check-${{ env.LINUX_TARGET }}-ubuntu-latest
shared-key: check-${{ matrix.target }}-ubuntu-latest

- name: Create .deb
run: cargo deb -p homestar-runtime --target ${{ env.LINUX_TARGET }} --output homestar.deb
run: cargo deb -p homestar-runtime --target ${{ matrix.target }} --variant ${{ matrix.target }} --output homestar.deb

- name: Create .rpm
run: cargo generate-rpm -p homestar-runtime --target ${{ env.LINUX_TARGET }} --output homestar.rpm
run: cargo generate-rpm -p homestar-runtime --target ${{ matrix.target }} --variant ${{ matrix.target }} --output homestar.rpm

- name: Upload Release Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.LINUX_TARGET }}
name: ${{ matrix.target }}
path: |
*.deb
*.rpm
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests_and_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ jobs:

- name: Run Tests (no-default-features)
if: ${{ matrix.default-features == 'none' }}
run: cargo nextest run --workspace --profile ci --no-default-features --features "test-utils"
run: cargo nextest run --profile ci --no-default-features --features "test-utils"

- name: Run Doc Tests
if: ${{ matrix.default-features == 'all' }}
Expand All @@ -199,7 +199,8 @@ jobs:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' }}
env:
RUSTFLAGS: -Ctarget-feature=+crt-static
RUSTFLAGS: -Dwarnings -Ctarget-feature=+crt-static
CARGO_INCREMENTAL: 0
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -241,12 +242,11 @@ jobs:

- name: Run Tests (no-default-features)
if: ${{ matrix.default-features == 'none' }}
run: cargo nextest run --workspace --profile ci --no-default-features --features "test-utils"
run: cargo nextest run --profile ci --no-default-features --features "test-utils"

- name: Run Doc Tests
if: ${{ matrix.default-features == 'all' }}
run: cargo test --doc --workspace
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }}

run-docs:
needs: changes
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ report.json
homestar.err
homestar.out
homestar.pid
homestar.log*

# locks
homestar-wasm/Cargo.lock
Expand All @@ -54,3 +55,6 @@ examples/**/tmp/*

# nix build results
/result

# npm packages
homestar-runtime/npm/binaries
2 changes: 2 additions & 0 deletions .ignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ LICENSE
.pre-commit-config.yaml

**/fixtures
*.ipfs*
*.db

## examples
examples/websocket-relay/relay-app
Loading

0 comments on commit 9b67136

Please sign in to comment.