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

chore(release): v0.2.8? #58

Merged
merged 8 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
57 changes: 25 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,37 @@
name: Release Workflow
name: Gituhb release
on:
push:
branches:
- main
branches: main

jobs:
release:
name: Release
name: Perform release
runs-on: ubuntu-latest

permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Rust
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Build and Test
run: cargo build --release && cargo test
- name: Cocogitto release
id: release
uses: oknozor/cocogitto-action@v3
with:
release: true
check-latest-tag-only: true
git-user: 'elcharitas'
git-user-email: 'jona'

- name: Bump Version
run: cargo bump patch
- name: Print version
run: "echo '${{ steps.release.outputs.version }}'"

- name: Commit and Push Changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -a -m "Bump version"
git push
- name: Generate Changelog
run: cog changelog --at ${{ steps.release.outputs.version }} -t full_hash > GITHUB_CHANGELOG.md

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload github release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.BUMPED_VERSION }}
release_name: Release ${{ env.BUMPED_VERSION }}
body: |
This is the release of the project.
Version: ${{ env.BUMPED_VERSION }}
draft: false
prerelease: false
body_path: GITHUB_CHANGELOG.md
tag_name: ${{ steps.release.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
40 changes: 21 additions & 19 deletions Cargo.lock

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

23 changes: 23 additions & 0 deletions cog.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from_latest_tag = true
ignore_merge_commits = false
generate_mono_repository_global_tag = true
branch_whitelist = []
skip_untracked = false
pre_bump_hooks = []
post_bump_hooks = []
pre_package_bump_hooks = []
post_package_bump_hooks = []

[git_hooks]

[commit_types]

[changelog]
path = "CHANGELOG.md"
authors = [
{ signature = "Jonathan Irhodia", username = "elcharitas" }
]

[bump_profiles]

[packages]
6 changes: 3 additions & 3 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ngyn"
version = "0.2.6"
version = "0.2.7"
edition = "2021"
description = "Modular backend framework for web applications"
license = "MIT"
Expand All @@ -11,8 +11,8 @@ path = "src/lib.rs"
[dependencies]
async-std = { version = "1.6.0", features = ["attributes"] }
nject = "0.3.0"
ngyn_macros = { path = "../macros", version = "0.2.6" }
ngyn_shared = { path = "../shared", version = "0.2.6" }
ngyn_macros = { path = "../macros", version = "0.2.7" }
ngyn_shared = { path = "../shared", version = "0.2.7" }
tide = { version = "0.16.0", optional = true }
vercel_runtime = { version = "1.1.0", optional = true }

Expand Down
8 changes: 5 additions & 3 deletions crates/core/src/platforms/vercel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl VercelApplication {

pub async fn handle(self, request: Request) -> Result<Response<Body>, Error> {
let mut res = ngyn_shared::NgynResponse::from_status(404);
res.body("Route not found");
res.send("Route not found");

let (parts, body) = request.into_parts();

Expand All @@ -54,15 +54,17 @@ impl VercelApplication {
body.to_vec(),
));
// change the status code to 200 to prevent vercel from returning a 404
res.set_status(200).body("");
res.set_status(200).send("");
handler.handle(&req, &mut res);
// await the response and reassign
res = res.await;
break; // Exit the loop once a route is found
}
}

Ok(Response::builder()
.status(res.status())
.body(res.raw().into())
.body(res.body_raw().into())
.unwrap())
}
}
4 changes: 2 additions & 2 deletions crates/macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ngyn_macros"
version = "0.2.6"
version = "0.2.7"
edition = "2021"
description = "Modular backend framework for web applications"
license = "MIT"
Expand All @@ -9,7 +9,7 @@ license = "MIT"
nject = "0.3.0"
syn = "2.0.29"
quote = "1.0.33"
ngyn_shared = { path = "../shared", version = "0.2.6" }
ngyn_shared = { path = "../shared", version = "0.2.7" }

[lib]
path = "src/lib.rs"
Expand Down
32 changes: 9 additions & 23 deletions crates/macros/src/common/controller_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn controller_macro(args: TokenStream, input: TokenStream) -> TokenStream {
let path = str_to_ident(format!("register_{}", route));
handle_routes.push(quote! {
#route => {
Self::#route_ident(Self::new(self.middlewares.clone()), &req, &mut res).await
Self::#route_ident(self, &req, &mut res).await
}
});
route_registry.push(quote! { controller.#path(); })
Expand All @@ -127,8 +127,9 @@ pub fn controller_macro(args: TokenStream, input: TokenStream) -> TokenStream {
#(#fields),*
}

impl #ident {
pub fn new(middlewares: Vec<std::sync::Arc<dyn ngyn::NgynMiddleware>>) -> Self {
#[ngyn::async_trait]
impl ngyn::NgynController for #ident {
fn new(middlewares: Vec<std::sync::Arc<dyn ngyn::NgynMiddleware>>) -> Self {
#(#add_middlewares)*
let mut controller = #ident {
routes: vec![],
Expand All @@ -138,28 +139,19 @@ pub fn controller_macro(args: TokenStream, input: TokenStream) -> TokenStream {
#(#route_registry)*
controller
}
}

#[ngyn::async_trait]
impl ngyn::NgynController for #ident {
fn name(&self) -> &str {
stringify!(#ident)
}

fn get_routes(&self) -> Vec<(
String,
String,
String,
)> {
self.routes.iter().map(|(path, http_method, handler)| {
(path.clone(), http_method.clone(), handler.clone())
}).collect()
fn get_routes(&self) -> Vec<(String, String, String)> {
self.routes.clone()
}

async fn handle(&self, handler: String, req: ngyn::NgynRequest, mut res: ngyn::NgynResponse) -> ngyn::NgynResponse {
for middleware in self.middlewares.clone() {
middleware.handle(&req, &res);
}
self.middlewares.iter().for_each(|middleware| {
middleware.handle(&req, &mut res);
});
match handler.as_str() {
#(#handle_routes)*
_ => {
Expand All @@ -168,12 +160,6 @@ pub fn controller_macro(args: TokenStream, input: TokenStream) -> TokenStream {
}
}
}

impl ngyn::NgynControllerInit for #ident {
fn new(middlewares: Vec<std::sync::Arc<dyn ngyn::NgynMiddleware>>) -> Self {
Self::new(middlewares)
}
}
};
expanded.into()
}
12 changes: 2 additions & 10 deletions crates/macros/src/common/injectable_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,17 @@ pub fn injectable_macro(_args: TokenStream, input: TokenStream) -> TokenStream {
#(#fields),*
}

impl #ident {
pub fn new() -> Self {
impl ngyn::NgynInjectable for #ident {
fn new() -> Self {
#ident {
#(#keys: ngyn::NgynProvider.provide()),*
}
}
}

impl ngyn::NgynInjectable for #ident {
fn name(&self) -> &str {
stringify!(#ident)
}
}

impl ngyn::NgynInjectableInit for #ident {
fn new() -> Self {
Self::new()
}
}
};
expanded.into()
}
7 changes: 7 additions & 0 deletions crates/macros/src/core/module_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, DeriveInput};

use crate::utils::{random_str_from, str_to_ident};

struct ModuleArgs {
imports: Vec<syn::Path>,
controllers: Vec<syn::Path>,
Expand Down Expand Up @@ -96,7 +98,12 @@ pub fn module_macro(args: TokenStream, input: TokenStream) -> TokenStream {
})
.collect();

let controller_ident = str_to_ident(random_str_from(ident.clone().to_string()));

let expanded = quote! {
// This is to make sure that the controller is imported
use ngyn::NgynController as #controller_ident;

#(#attrs)*
#[ngyn::dependency]
#vis struct #ident {
Expand Down
Loading
Loading