Skip to content

Commit

Permalink
Merge pull request #3 from valentin994/add-sqlx
Browse files Browse the repository at this point in the history
added migration, added database to main.rs, updated readme
  • Loading branch information
valentin994 authored May 10, 2024
2 parents d2de76b + ef32014 commit 3a7f5ea
Show file tree
Hide file tree
Showing 9 changed files with 1,061 additions and 42 deletions.
44 changes: 24 additions & 20 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,38 @@ on:

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-Dwarnings"

jobs:
pre-build:
name: Format & Lint
clippy_check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Format and Lint
steps:
- uses: actions/checkout@v4
- name: Run Clippy
run: |
cd ./backend
cargo fmt
cargo check
cargo clippy
cd backend
cargo clippy --all-targets --all-features
build:
test:
name: Integration Tests
runs-on: ubuntu-latest

services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: mysecretpassword
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build and run API
env:
DATABASE_URL: postgres://postgres:mysecretpassword@localhost:5432
run: |
cd backend
ls
cargo run &
- name: Run tests
run: |
cd ./backend
cargo test --verbose
cargo run & cargo test
48 changes: 45 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,51 @@
ForgeCMS
---
A lightning fast rust based CMS.
A lightning fast rust based CMS.

Contributions
---
## Installation
The CMS is built with axum for managing the requests, and with sqlx & slqx-cli for managing the database.
Out of the box there will be a review table that is initilized with the server. There is a docker compose
set up to bootstrap everything, but if you already have a setup database you can run the server independently
wih:

```sh
$ cd ./backend
$ cargo run --release
```

Or if you want to bootstrap from scratch use:
```sh
$ docker compose up
```
If you want the containers to run in the background run with `-d` which is detached mode:
```sc
$ docker compose up -d
```

To strip everything down run:
```sh
$ docker compose down
```

If you do any changes to the code and want to apply those changes, run:
```sh
$ docker compose build
$ docker compose up
```

## Database
This project uses postgres as its database of choice.
When starting the application you will have these tables created:
- reviews

If you want to add more tables you can do that with the [sqlx-cli](https://crates.io/crates/sqlx-cli).

## CICD
The projects uses GitHub Actions for delivery. We are running two jobs, one is [clippy](https://doc.rust-lang.org/nightly/clippy/continuous_integration/github_actions.html) for lint and format.
The other job is Integration test, in which we test every route on a dummy server.


## Contributions
If you want to contribute you are more than welcome. Please open a pull request and write tests for your PR.
After all tests and conditions pass I'll take a look into it and merge it.

Loading

0 comments on commit 3a7f5ea

Please sign in to comment.