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

Commit

Permalink
Merge pull request #188 from thomastaylor312/feat/make_blobby_real
Browse files Browse the repository at this point in the history
feat(blobby): Adds full functionality as a fileserver over http
  • Loading branch information
thomastaylor312 authored Jan 31, 2023
2 parents 8f84058 + 35a34c7 commit b8a7419
Show file tree
Hide file tree
Showing 12 changed files with 1,626 additions and 48 deletions.
33 changes: 27 additions & 6 deletions .github/workflows/blobby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ on:
push:
branches: [main]
paths:
- "actor/blobby/**"
- "actor/blobby/actor/**"
- "actor/blobby/testing/**"
tags:
- "blobby-v*"
pull_request:
branches: [main]
paths:
- "actor/blobby/**"
- "actor/blobby/actor/**"
- "actor/blobby/testing/**"

env:
CARGO_TERM_COLOR: always
working-directory: ./actor/blobby
WASH_ISSUER_KEY: ${{ secrets.WASMCLOUD_ACCOUNT_OFFICIAL }}
WASH_SUBJECT_KEY: ${{ secrets.WASMCLOUD_BLOBBY }}
working-directory: ./actor/blobby/actor

jobs:
rust_check:
Expand All @@ -33,10 +33,31 @@ jobs:
# The `--doc` is required for wasm, as cargo cannot execute wasm tests by default
test-options: "--verbose --doc"

build_artifact:
integration_test:
needs: rust_check
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: wasmcloud/common-actions/install-wash@main

- name: Add wasm32-unknown-unknown
run: rustup target add wasm32-unknown-unknown

- name: Build wasmcloud actor
run: wash build
working-directory: ${{ env.working-directory }}

- name: Run integration tests
working-directory: actor/blobby/testing/
run: cargo test -- --test-threads 1

build_artifact:
needs: integration_test
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
runs-on: ubuntu-20.04
env:
WASH_ISSUER_KEY: ${{ secrets.WASMCLOUD_ACCOUNT_OFFICIAL }}
WASH_SUBJECT_KEY: ${{ secrets.WASMCLOUD_BLOBBY }}
steps:
- uses: actions/checkout@v2
- uses: wasmcloud/common-actions/install-wash@main
Expand Down
2 changes: 1 addition & 1 deletion actor/blobby/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


## Build
/build
**/build
/dist/
/target
**target
Expand Down
60 changes: 55 additions & 5 deletions actor/blobby/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
# Blobby

This actor (we like to call it "Little Blobby Tables") is a simple file server showing the basic CRUD operations of the `wasmcloud:blobstore` contract
This actor (we like to call it "Little Blobby Tables") is a simple file server showing the basic
CRUD operations of the `wasmcloud:blobstore` contract.

Not only is this actor an example, it is also a fully-functional, HTTP-based fileserver that can be
fronted with any HTTP server implementation and any blobstore implementation (i.e. you could store
the uploaded files on a filesystem or in an s3 compatible store). It also has a full example of
integration testing for the actor

## Required Capability Claims

1. `wasmcloud:httpserver` to receive http requests
2. `wasmcloud:blobstore` to save the image to a blob
3. `wasmcloud:builtin:logging` so the actor can log

## Running this example

This example requires capability providers that fulfill the above contracts. The wasmCloud [HTTP Server](https://github.com/wasmCloud/capability-providers/tree/main/httpserver-rs) and [Filesystem](https://github.com/wasmCloud/capability-providers/tree/main/blobstore-fs) capability providers implement this functionality but you're welcome to use any implementation (like the [S3 Blobstore](https://github.com/wasmCloud/capability-providers/tree/main/blobstore-s3)).
This example requires capability providers that fulfill the above contracts. The wasmCloud [HTTP
Server](https://github.com/wasmCloud/capability-providers/tree/main/httpserver-rs) and
[Filesystem](https://github.com/wasmCloud/capability-providers/tree/main/blobstore-fs) capability
providers implement this functionality but you're welcome to use any implementation (like the [S3
Blobstore](https://github.com/wasmCloud/capability-providers/tree/main/blobstore-s3)).

Once you've installed **wash** and ran wasmCloud after following the [installation guide](https://wasmcloud.dev/overview/installation/), you can run this example actor and the wasmCloud providers with the following commands:
Once you've installed **wash** and ran wasmCloud after following the [installation
guide](https://wasmcloud.dev/overview/installation/), you can run this example actor and the
wasmCloud providers with the following commands:
```
$ wash ctl start actor wasmcloud.azurecr.io/blobby:0.1.0
$ wash ctl start actor wasmcloud.azurecr.io/blobby:0.2.0
# If you use a locally built actor, replace the actor ID below with your own
$ wash ctl link put MBY3COMRDLQYTX2AUTNB5D2WYAH5TUKNIMELDSQ5BUFZVV7CBUUIKEDR VBBQNNCGUKIXEWLL5HL5XJE57BS3GU5DMDOKZS6ROEWPQFHEDP6NGVZM wasmcloud:blobstore "ROOT=/tmp"
$ wash ctl link put MBY3COMRDLQYTX2AUTNB5D2WYAH5TUKNIMELDSQ5BUFZVV7CBUUIKEDR VAG3QITQQ2ODAOWB5TTQSDJ53XK3SHBEIFNK4AYJ5RKAX2UNSCAPHA5M wasmcloud:httpserver "ADDRESS=0.0.0.0:8080"
$ wash ctl start provider wasmcloud.azurecr.io/blobstore_fs:0.2.0 --skip-wait
$ wash ctl start provider wasmcloud.azurecr.io/httpserver:0.16.0 --skip-wait
```

Once everything is up and running, you can run through all of the operations by following the annotated commands below:
Once everything is up and running, you can run through all of the operations by following the
annotated commands below:

```console
# Create a file with some content
Expand Down Expand Up @@ -131,3 +145,39 @@ $ curl -v 'http://127.0.0.1:8080/myfile.txt'
<
* Connection #0 to host 127.0.0.1 left intact
```

## Development

This actor has two subdirectories. Due to the actor having a wasm32 target, we couldn't have the
integration tests in the same directory. The `actor` directory contains the actual code for the
actor and the `testing` directory contains the integration tests.

### Prerequisites

This actor requires a working Rust tool chain as well as
[`wash`](https://wasmcloud.dev/overview/installation/)

### Building the actor

Building the actor is fairly straightforward:

```console
$ cd actor
$ wash build
```

### Testing the actor

Testing the actor is just a bit more complex, but still fairly easy

```console
$ cd testing
$ cargo test -- --test-threads 1
```

This will automatically build your actor and then run the tests. The `--test-threads 1` only runs
one test at a time as a workaround until we can put in the work to automatically generate different
ports for everything that is starting up

Please note that these tests are currently being used as a testbed for actor integration testing. It
is likely we will try to wrap this up in some sort of testing tool in the future!
File renamed without changes.
3 changes: 2 additions & 1 deletion actor/blobby/Cargo.lock → actor/blobby/actor/Cargo.lock

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

3 changes: 2 additions & 1 deletion actor/blobby/Cargo.toml → actor/blobby/actor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blobby"
version = "0.1.0"
version = "0.2.0"
authors = [ "wasmCloud Team" ]
edition = "2021"

Expand All @@ -9,6 +9,7 @@ crate-type = ["cdylib", "rlib"]
name = "blobby"

[dependencies]
form_urlencoded = "1.0"
futures = "0.3"
http = "0.2"
lazy_static = "1"
Expand Down
Loading

0 comments on commit b8a7419

Please sign in to comment.