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

Adds CI steps for atmosphere #2

Merged
merged 1 commit into from
Nov 25, 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
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI

on:
push:
branches: ["main"]
pull_request:

env:
MINIMUM_LINE_COVERAGE_PERCENT: 0

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update && rustup component add rustfmt
- run: cargo fmt --check --all

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update && rustup component add clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-targets --workspace -- -D warnings -D clippy::all

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: "true"
- uses: isbang/[email protected]
with:
compose-file: "./tests/postgres.yml"
- run: rustup update
- uses: Swatinem/rust-cache@v2
- run: cargo test --workspace
env:
RUST_BACKTRACE: 1
DATABASE_URL: postgres://atmosphere:atmosphere@localhost:5432

typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- run: cargo install typos-cli || true
- run: typos
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Atmosphere is able to derive and generate the following queries:

### Field Queries

Each struct field that is marked with `#[sql(unique)]` becomes queriable.
Each struct field that is marked with `#[sql(unique)]` becomes queryable.

In the above example `b` was marked as unique so atmosphere implements:

Expand Down
2 changes: 1 addition & 1 deletion atmosphere-core/src/rel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ where
/// entities referring to `Self`, resolving by primary key, and deleting all such referring
/// entities.
#[async_trait]
pub trait ReferedBy<Other>
pub trait ReferredBy<Other>
where
Self: Table + Bind + Unpin + Sync,
Other: Table + Bind + RefersTo<Self> + Unpin + Sync,
Expand Down
8 changes: 4 additions & 4 deletions atmosphere-macros/src/derive/relationships.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn relationships(table: &Table) -> TokenStream {
E: ::sqlx::Executor<'e, Database = ::atmosphere::Driver>,
for<'q> <::atmosphere::Driver as ::sqlx::database::HasArguments<'q>>::Arguments:
::sqlx::IntoArguments<'q, ::atmosphere::Driver> + Send {
<#other as ::atmosphere::rel::ReferedBy<#ident>>::resolve_by(pk, executor).await
<#other as ::atmosphere::rel::ReferredBy<#ident>>::resolve_by(pk, executor).await
}
}

Expand All @@ -71,7 +71,7 @@ pub fn relationships(table: &Table) -> TokenStream {
E: ::sqlx::Executor<'e, Database = ::atmosphere::Driver>,
for<'q> <::atmosphere::Driver as ::sqlx::database::HasArguments<'q>>::Arguments:
::sqlx::IntoArguments<'q, ::atmosphere::Driver> + Send {
<#other as ::atmosphere::rel::ReferedBy<#ident>>::resolve(&self, executor).await
<#other as ::atmosphere::rel::ReferredBy<#ident>>::resolve(&self, executor).await
}

pub async fn #delete_self<'e, E>(
Expand All @@ -82,7 +82,7 @@ pub fn relationships(table: &Table) -> TokenStream {
E: ::sqlx::Executor<'e, Database = ::atmosphere::Driver>,
for<'q> <::atmosphere::Driver as ::sqlx::database::HasArguments<'q>>::Arguments:
::sqlx::IntoArguments<'q, ::atmosphere::Driver> + Send {
<#other as ::atmosphere::rel::ReferedBy<#ident>>::delete_all(&self, executor).await
<#other as ::atmosphere::rel::ReferredBy<#ident>>::delete_all(&self, executor).await
}
}

Expand All @@ -92,7 +92,7 @@ pub fn relationships(table: &Table) -> TokenStream {
}

#[automatically_derived]
impl ::atmosphere::rel::ReferedBy<#ident> for #other {}
impl ::atmosphere::rel::ReferredBy<#ident> for #other {}
));
}

Expand Down
1 change: 1 addition & 0 deletions atmosphere-macros/src/schema/relation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion atmosphere-macros/src/schema/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Parse for TableId {
}

let schema = schema.ok_or_else(|| {
syn::Error::new(input.span(), "`#[table]` requies a value for `schema`")
syn::Error::new(input.span(), "`#[table]` requires a value for `schema`")
})?;

let table = table.ok_or_else(|| {
Expand Down
9 changes: 9 additions & 0 deletions tests/postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "3.9"
services:
database:
image: postgres:16
environment:
POSTGRES_PASSWORD: atmosphere
POSTGRES_USER: atmosphere
ports:
- 127.0.0.1:5432:5432
Loading