From df398724a6a108112e6caddfee4e41a0e31117da Mon Sep 17 00:00:00 2001 From: aish-where-ya Date: Thu, 31 Aug 2023 14:00:56 -0400 Subject: [PATCH] Allow templating for hello world and kvcounter Signed-off-by: aish-where-ya --- .github/workflows/release-hello-world.yml | 6 ++---- .github/workflows/release-kvcounter.yml | 6 ++---- .github/workflows/release-multichannelchat.yml | 8 ++++---- hello-world/rust/Cargo.toml | 2 +- hello-world/rust/README.md | 2 +- hello-world/rust/src/lib.rs | 4 ++-- hello-world/rust/wasmcloud.toml | 2 +- kvcounter/rust/Cargo.toml | 4 ++-- kvcounter/rust/src/lib.rs | 4 ++-- kvcounter/rust/wadm.yaml | 4 ++-- kvcounter/rust/wasmcloud.toml | 2 +- 11 files changed, 20 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release-hello-world.yml b/.github/workflows/release-hello-world.yml index 83dfee3..fca084c 100644 --- a/.github/workflows/release-hello-world.yml +++ b/.github/workflows/release-hello-world.yml @@ -6,7 +6,7 @@ on: paths: - "hello-world/**" tags: - - "hello-world-v*" + - "v*" env: # For the release action, you'll have to set the following variables WASH_ISSUER_KEY: ${{ secrets.COSMONIC_ACCOUNT_OFFICIAL }} @@ -29,9 +29,7 @@ jobs: env: WASH_ISSUER_KEY: ${{ env.WASH_ISSUER_KEY }} WASH_SUBJECT_KEY: ${{ env.WASH_SUBJECT_KEY }} - run: | - wash new actor --path rust hello - cd hello && wash build + run: make shell: bash working-directory: ${{ env.working-directory }} - name: Upload signed actor to GH Actions diff --git a/.github/workflows/release-kvcounter.yml b/.github/workflows/release-kvcounter.yml index cdb4d50..7e478df 100644 --- a/.github/workflows/release-kvcounter.yml +++ b/.github/workflows/release-kvcounter.yml @@ -6,7 +6,7 @@ on: paths: - "kvcounter/**" tags: - - "kvcounter-v*" + - "v*" env: # For the release action, you'll have to set the following variables WASH_ISSUER_KEY: ${{ secrets.COSMONIC_ACCOUNT_OFFICIAL }} @@ -29,9 +29,7 @@ jobs: env: WASH_ISSUER_KEY: ${{ env.WASH_ISSUER_KEY }} WASH_SUBJECT_KEY: ${{ env.WASH_SUBJECT_KEY }} - run: | - wash new actor --path rust kvcounter - wash build -p kvcounter + run: make shell: bash working-directory: ${{ env.working-directory }} - name: Upload signed actor to GH Actions diff --git a/.github/workflows/release-multichannelchat.yml b/.github/workflows/release-multichannelchat.yml index d55298b..6a148c0 100644 --- a/.github/workflows/release-multichannelchat.yml +++ b/.github/workflows/release-multichannelchat.yml @@ -38,16 +38,16 @@ jobs: run: rustup target add wasm32-unknown-unknown - name: Set wash subject key (api-gateway) - if: ${{ matrix.working-directory == 'multi-channel-chat/api-gateway' }} + if: ${{ matrix.artifact-name == 'api-gateway' }} run: echo "WASH_SUBJECT_KEY=${{ secrets.AWESOME_COSMONIC_MCC_APIGATEWAY_KEY }}" > $GITHUB_ENV - name: Set wash subject key (chatlog) - if: ${{ matrix.working-directory == 'multi-channel-chat/chatlog' }} + if: ${{ matrix.artifact-name == 'chatlog' }} run: echo "WASH_SUBJECT_KEY=${{ secrets.AWESOME_COSMONIC_MCC_CHATLOG_KEY }}" > $GITHUB_ENV - name: Set wash subject key (http-channel) - if: ${{ matrix.working-directory == 'multi-channel-chat/http-channel' }} + if: ${{ matrix.artifact-name == 'http-channel' }} run: echo "WASH_SUBJECT_KEY=${{ secrets.AWESOME_COSMONIC_MCC_HTTPCHANNEL_KEY }}" > $GITHUB_ENV - name: Set wash subject key (nats-channel) - if: ${{ matrix.working-directory == 'multi-channel-chat/nats-channel' }} + if: ${{ matrix.artifact-name == 'nats-channel' }} run: echo "WASH_SUBJECT_KEY=${{ secrets.AWESOME_COSMONIC_MCC_NATSCHANNEL_KEY }}" > $GITHUB_ENV - name: Build and sign wasmCloud actor diff --git a/hello-world/rust/Cargo.toml b/hello-world/rust/Cargo.toml index 83c20c9..2e80c57 100644 --- a/hello-world/rust/Cargo.toml +++ b/hello-world/rust/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "helloworld" +name = "{{project-name}}" version = "0.1.0" authors = [ "" ] edition = "2021" diff --git a/hello-world/rust/README.md b/hello-world/rust/README.md index a7753a0..9f4b556 100644 --- a/hello-world/rust/README.md +++ b/hello-world/rust/README.md @@ -1,3 +1,3 @@ -# HelloWorldActor +# {{ project-name }} Actor This application is an implementation of the HTTP server capability in Rust that returns "Hello, World!" in response to an HTTP request. diff --git a/hello-world/rust/src/lib.rs b/hello-world/rust/src/lib.rs index 25e8b89..70f39b7 100644 --- a/hello-world/rust/src/lib.rs +++ b/hello-world/rust/src/lib.rs @@ -3,11 +3,11 @@ use wasmcloud_interface_httpserver::{HttpRequest, HttpResponse, HttpServer, Http #[derive(Debug, Default, Actor, HealthResponder)] #[services(Actor, HttpServer)] -struct HelloWorldActor {} +struct {{to_pascal_case project-name}}Actor {} /// Implementation of the HTTP server capability #[async_trait] -impl HttpServer for HelloWorldActor { +impl HttpServer for {{to_pascal_case project-name}}Actor { async fn handle_request(&self, _ctx: &Context, _req: &HttpRequest) -> RpcResult { let message: &str = r#"Hello, World, from Cosmonic! diff --git a/hello-world/rust/wasmcloud.toml b/hello-world/rust/wasmcloud.toml index f62cdf5..1eb50be 100644 --- a/hello-world/rust/wasmcloud.toml +++ b/hello-world/rust/wasmcloud.toml @@ -1,4 +1,4 @@ -name = "helloworld" +name = "{{project-name}}" language = "rust" type = "actor" version = "0.1.0" diff --git a/kvcounter/rust/Cargo.toml b/kvcounter/rust/Cargo.toml index 5d5c026..c977648 100644 --- a/kvcounter/rust/Cargo.toml +++ b/kvcounter/rust/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "kvcounter" +name = "{{project-name}}" version = "0.1.0" authors = [ "" ] edition = "2021" [lib] crate-type = ["cdylib", "rlib"] -name = "kvcounter" +name = "{{to_snake_case project-name}}" [dependencies] async-trait = "0.1" diff --git a/kvcounter/rust/src/lib.rs b/kvcounter/rust/src/lib.rs index 6ac2ebe..3a99778 100644 --- a/kvcounter/rust/src/lib.rs +++ b/kvcounter/rust/src/lib.rs @@ -8,11 +8,11 @@ use ui::get_asset; #[derive(Debug, Default, Actor, HealthResponder)] #[services(Actor, HttpServer)] -struct KvCounterActor {} +struct {{to_pascal_case project-name}}Actor {} /// Implementation of HttpServer trait methods #[async_trait] -impl HttpServer for KvCounterActor { +impl HttpServer for {{to_pascal_case project-name}}Actor { async fn handle_request(&self, ctx: &Context, req: &HttpRequest) -> RpcResult { let trimmed_path: Vec<&str> = req.path.trim_matches('/').split('/').collect(); diff --git a/kvcounter/rust/wadm.yaml b/kvcounter/rust/wadm.yaml index 3b09edc..ff6e036 100644 --- a/kvcounter/rust/wadm.yaml +++ b/kvcounter/rust/wadm.yaml @@ -9,7 +9,7 @@ apiVersion: core.oam.dev/v1beta1 kind: Application metadata: - name: kvcounter + name: {{project-name}} annotations: version: v0.0.1 description: "wasmCloud Key Value Counter Example" @@ -18,7 +18,7 @@ spec: - name: kvcounter type: actor properties: - image: ghcr.io/{{github.REPOSITORY}}:kvcounter:0.1.0 + image: ghcr.io/{{github.REPOSITORY}}:{{project-name}}:0.1.0 traits: - type: spreadscaler properties: diff --git a/kvcounter/rust/wasmcloud.toml b/kvcounter/rust/wasmcloud.toml index e73a098..466572c 100644 --- a/kvcounter/rust/wasmcloud.toml +++ b/kvcounter/rust/wasmcloud.toml @@ -1,4 +1,4 @@ -name = "kvcounter" +name = "{{project-name}}" language = "rust" type = "actor" version = "0.1.0"