-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4a82ea
commit 2eaf95a
Showing
9 changed files
with
3,289 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Build and test HTTP File Server | ||
on: | ||
pull_request: | ||
branches: [main] | ||
paths: | ||
- "http-file-server/rust/**" | ||
|
||
env: | ||
working-directory: "./http-file-server" | ||
jobs: | ||
build_and_test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: wasmcloud/common-actions/install-wash@main | ||
- name: Add wasm32-unknown-unknown | ||
run: rustup target add wasm32-unknown-unknown | ||
- name: Build actor | ||
run: cargo build | ||
working-directory: ${{ env.working-directory }} | ||
- name: Check formatting | ||
run: cargo fmt -- --check | ||
shell: bash | ||
working-directory: ${{ env.working-directory }}/hello | ||
|
||
- name: Check lints with clippy | ||
run: | | ||
rustup component add clippy | ||
cargo clippy | ||
working-directory: ${{ env.working-directory }}/hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Release HTTP File Server to GHCR | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
paths: | ||
- "http-file-server/**" | ||
tags: | ||
- "http-file-server-v*" | ||
env: | ||
# For the release action, you'll have to set the following variables | ||
WASH_ISSUER_KEY: ${{ secrets.COSMONIC_ACCOUNT_OFFICIAL }} | ||
WASH_SUBJECT_KEY: ${{ secrets.AWESOME_COSMONIC_HELLO_WORLD_KEY }} | ||
working-directory: "./http-file-server" | ||
jobs: | ||
build_signed_actor: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: wasmcloud/common-actions/install-wash@main | ||
- name: Add wasm32-unknown-unknown | ||
run: rustup target add wasm32-unknown-unknown | ||
working-directory: ${{ env.working-directory }}/rust | ||
# Once you've written unit tests for your actor, you can uncomment | ||
# the two lines below to automatically run tests | ||
# - name: Test actor | ||
# run: cargo test --target x86_64-unknown-linux-gnu -- --nocapture | ||
- name: Build and sign wasmCloud actor | ||
env: | ||
WASH_ISSUER_KEY: ${{ env.WASH_ISSUER_KEY }} | ||
WASH_SUBJECT_KEY: ${{ env.WASH_SUBJECT_KEY }} | ||
run: wash build | ||
shell: bash | ||
working-directory: ${{ env.working-directory }} | ||
- name: Upload signed actor to GH Actions | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: wasmcloud-actor | ||
path: ${{ env.working-directory }}/hello.tar | ||
|
||
artifact_release: | ||
needs: build_signed_actor | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: wasmcloud/common-actions/install-wash@main | ||
- name: Download signed actor | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: wasmcloud-actor | ||
path: ${{ env.working-directory }} | ||
- name: Extract files from tar file | ||
run: tar -xvf hello.tar | ||
shell: bash | ||
working-directory: ${{ env.working-directory }} | ||
- name: Determine actor name | ||
run: | | ||
echo "actor-name=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].name')" >> $GITHUB_ENV | ||
working-directory: ${{ env.working-directory }}/hello | ||
- name: Determine actor version | ||
if: startswith(github.ref, 'refs/tags/') # Only run on tag push | ||
run: | | ||
echo "actor-version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].version')" >> $GITHUB_ENV | ||
working-directory: ${{ env.working-directory }}/hello | ||
- name: Determine actor version (main) | ||
if: ${{ !startswith(github.ref, 'refs/tags/') }} | ||
run: | | ||
echo "actor-version=latest" >> $GITHUB_ENV | ||
working-directory: ${{ env.working-directory }}/hello | ||
- name: Push actor to GHCR | ||
uses: wasmcloud/common-actions/oci-artifact-release@main | ||
with: | ||
artifact-path: ${{ env.working-directory }}/hello/build/${{ env.actor-name }}_s.wasm | ||
oci-url: ${{ secrets.GHCR_PUSH_URL }} | ||
oci-repository: ${{ env.actor-name }} | ||
oci-version: ${{ env.actor-version }} | ||
oci-username: ${{ github.actor }} | ||
oci-password: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# HTTP File Server | ||
|
||
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 | ||
|
||
Click on the button below to launch the XKCD Generator on Cosmonic Now: | ||
|
||
[![Deploy on Cosmonic](https://cosmonic.com/badge/deploy.svg)](https://new.cosmonic.app/?yaml=https://raw.githubusercontent.com/cosmonic/awesome-cosmonic/http-file-server/http-file-server.wadm.yaml) | ||
|
||
Once everything is up and running, you can run through all of the operations by following the | ||
annotated commands below: | ||
|
||
```bash | ||
export MY_WORMHOLE="your-wormhole-goes-here.cosmonic.app" | ||
|
||
# to upload a file | ||
export MESSAGE="Hello there\!" | ||
curl -w "%{http_code}" -H 'Content-Type: text/plain' "https://$MY_WORMHOLE.cosmonic.app/myfile.txt" -d "$MESSAGE" | ||
|
||
# to download a file | ||
curl "https://$MY_WORMHOLE.cosmonic.app/myfile.txt" | ||
|
||
# to edit a file, post again | ||
export MESSAGE="$MESSAGE General Kenobi\!" | ||
curl -w "%{http_code}" -H 'Content-Type: text/plain' "https://$MY_WORMHOLE.cosmonic.app/myfile.txt" -d "$MESSAGE" | ||
|
||
# download the file again | ||
curl "https://$MY_WORMHOLE.cosmonic.app/myfile.txt" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# This is a full example of how to run the blobby example. | ||
# This requires you to have WADM running: https://github.com/wasmCloud/wadm/ | ||
# You can deploy this example with a simple command: | ||
# | ||
# `wash app deploy wadm.yaml` | ||
|
||
apiVersion: core.oam.dev/v1beta1 | ||
kind: Application | ||
metadata: | ||
name: blobby | ||
annotations: | ||
version: v0.0.1 | ||
description: "wasmCloud HTTP Server" | ||
spec: | ||
components: | ||
- name: blobby | ||
type: actor | ||
properties: | ||
image: wasmcloud.azurecr.io/blobby:0.2.0 | ||
traits: | ||
- type: spreadscaler | ||
properties: | ||
replicas: 1 | ||
- type: linkdef | ||
properties: | ||
target: httpserver | ||
- type: linkdef | ||
properties: | ||
target: blobstore | ||
values: | ||
ROOT: "/tmp" | ||
|
||
# Capability Providers | ||
- name: httpserver | ||
type: capability | ||
properties: | ||
image: cosmonic.azurecr.io/httpserver_wormhole:0.6.2 | ||
contract: wasmcloud:httpserver | ||
- name: blobstore | ||
type: capability | ||
properties: | ||
image: wasmcloud.azurecr.io/blobstore_fs:0.3.1 | ||
contract: wasmcloud:blobstore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build] | ||
target = "wasm32-unknown-unknown" |
Oops, something went wrong.