Skip to content

Commit

Permalink
Examples: Loco x Seaography (#2270)
Browse files Browse the repository at this point in the history
* Examples: Loco x Seaography

* fmt

* Edit
  • Loading branch information
billy1624 committed Jun 26, 2024
1 parent c3cd3f3 commit 9fd5523
Show file tree
Hide file tree
Showing 60 changed files with 7,368 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ jobs:
examples/jsonrpsee_example,
examples/loco_example,
examples/loco_starter,
examples/loco_seaography,
examples/poem_example,
examples/proxy_gluesql_example,
examples/rocket_example,
Expand Down
3 changes: 3 additions & 0 deletions examples/loco_seaography/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[alias]
loco = "run --"
playground = "run --example playground"
6 changes: 6 additions & 0 deletions examples/loco_seaography/.devcontainer/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
POSTGRES_DB=loco_app
POSTGRES_USER=loco
POSTGRES_PASSWORD=loco
DATABASE_URL=postgres://loco:loco@db:5432/loco_app
REDIS_URL=redis://redis:6379
MAILER_HOST=mailer
8 changes: 8 additions & 0 deletions examples/loco_seaography/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM mcr.microsoft.com/devcontainers/rust:1

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends postgresql-client \
&& cargo install sea-orm-cli cargo-insta \
&& chown -R vscode /usr/local/cargo

COPY .env /.env
9 changes: 9 additions & 0 deletions examples/loco_seaography/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Loco",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"forwardPorts": [
3000
]
}
50 changes: 50 additions & 0 deletions examples/loco_seaography/.devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: "3"

services:
app:
build:
context: .
dockerfile: Dockerfile
command: sleep infinity
networks:
- db
- redis
- mailer
volumes:
- ../..:/workspaces:cached
env_file:
- .env
db:
image: postgres:15.3-alpine
restart: unless-stopped
ports:
- 5432:5432
networks:
- db
volumes:
- postgres-data:/var/lib/postgresql/data
env_file:
- .env
redis:
image: redis:latest
restart: unless-stopped
ports:
- 6379:6379
networks:
- redis
mailer:
image: mailtutan/mailtutan:latest
restart: unless-stopped
ports:
- 1080:1080
- 1025:1025
networks:
- mailer

volumes:
postgres-data:

networks:
db:
redis:
mailer:
107 changes: 107 additions & 0 deletions examples/loco_seaography/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: CI
on:
push:
branches:
- master
- main
pull_request:

env:
RUST_TOOLCHAIN: stable
TOOLCHAIN_PROFILE: minimal

jobs:
rustfmt:
name: Check Style
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
components: rustfmt
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
name: Run Clippy
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery -W rust-2018-idioms

test:
name: Run Tests
runs-on: ubuntu-latest

permissions:
contents: read

services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- "6379:6379"
postgres:
image: postgres
env:
POSTGRES_DB: postgres_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
# Set health checks to wait until postgres has started
options: --health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --all
env:
REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}}
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test
19 changes: 19 additions & 0 deletions examples/loco_seaography/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
**/config/local.yaml
**/config/*.local.yaml
**/config/production.yaml

# Generated by Cargo
# will have compiled files and executables
debug/
target/

# include cargo lock
!Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

uploads
7 changes: 7 additions & 0 deletions examples/loco_seaography/.rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
max_width = 100
comment_width = 80
wrap_comments = true
imports_granularity = "Crate"
use_small_heuristics = "Default"
group_imports = "StdExternalCrate"
format_strings = true
Loading

0 comments on commit 9fd5523

Please sign in to comment.