Skip to content

Commit

Permalink
New backend based on loco (#392)
Browse files Browse the repository at this point in the history
* added new entities and repositories

* added first (but useless) controller

* started on implementing account controller

* Getting started on a completely new backend using different technologies

* Started work on new schema

* added transaction tables

* move back to a single permissions table

* added contracts and tags

* added budget tables

* added file attachment support

* updated compose file

* Inited loco-project

Add todo because transaction type has some problems

* schema optimizations

- added global bank accounts
- added type to transaction
- added purpose and note to transactions

* removed useless api_key column

* Added missing schemas and data

- expanded schema
- added currency data

* added some more workspace files

* hopefully finalized schema

- removed inheritance
- fixed budget tables

* More basic setup

* A lot of schema and setup work

* updated crates

* removed useless `linked_transactions` table

* Some more dev fixes

* more initial setup work

* updated dependencies

* Yeah some restructure

* hopefully fixed basic workflows

* added entities and removed some other stuff

* Basic OpenApi setup

* updated rust

* remvoed uuids

* More auth, services, snowflakes etc.

* enhance snowflake generator + added scheduler

* used initializers & clippy fixes

* some improvvements idk

* Updated crates

* Errors and auth start

* Errors and auth start

* use scheduler

* Allow 0 as node id

* More errors and other shit

* renamed a response

* enhanced docker image builds

* Added verify endpoint to users

* Replaced basic macro with proc_macro for enhanced code generation

* enhanced macro with utoipa response generation

* added some more docs

* implemented new macro

* improved released profile

* updated config + storage integration

* mapped all loco errors

* added instance manager

* Improved instance handling and removed cleanup task

* completed user controller

* added session controller

* finished session controller

* made details field optional

* fixed docs

* added status endpoints

* temporary route fixes

Fixes: loco-rs/loco#1116

* Fixed docker builds (hopefully)

* started fixing tests

* some improvements

* added comments on how to solve the ValidationError thing

* fixed model::users tests

* fixed build and test workflow

* added test case for openapi routes

* added some new test + fixed a few endpoints and schema issues

* added more tests

Note:
Somehow if we run tests only the first one succeeds and closes the pool

* fixed all remaining tests + db error

* fixed `.env.dist`

* added extra build step to test ci

* fixed insta building
  • Loading branch information
DenuxPlays authored Jan 2, 2025
1 parent 3906f5c commit c06d536
Show file tree
Hide file tree
Showing 388 changed files with 17,814 additions and 2,328 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/backend-build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,25 @@ env:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --release --verbose
run: cargo build --release

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Instal nextst
uses: taiki-e/install-action@v2
with:
tool: nextest
- name: Run installation script
run: bash bin/install.bash
- name: Start Docker Container
run: docker compose up -d
- name: Build tests
run: cargo nextest run --workspace --no-run
- name: Run tests
run: cargo test --release --verbose --workspace
run: bash bin/test.bash
4 changes: 2 additions & 2 deletions .github/workflows/backend-docker-compose-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: ./backend
file: ./backend/docker/rust/Dockerfile
file: ./backend/Dockerfile
platforms: linux/amd64
load: true

Expand All @@ -48,6 +48,6 @@ jobs:
uses: docker/build-push-action@v6
with:
context: ./backend
file: ./backend/docker/rust/Dockerfile
file: ./backend/Dockerfile
platforms: linux/arm64
load: true
30 changes: 0 additions & 30 deletions .github/workflows/backend-e2e-tests.yaml

This file was deleted.

98 changes: 0 additions & 98 deletions .github/workflows/backend-publish-docker-images.yaml

This file was deleted.

10 changes: 5 additions & 5 deletions .github/workflows/backend-rust-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# cargo audit
- name: Install cargo-audit
run: cargo install --force cargo-audit
- name: Run cargo-audit
run: cargo audit --ignore RUSTSEC-2023-0071 # Marvin attack (RSA) crate. Being worked on.
- uses: rustsec/audit[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./backend
ignore: RUSTSEC-2023-0071, RUSTSEC-2024-0370

clippy:
env:
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/publish-edge-docker-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Publish Edge Docker Images

on:
push:
branches:
- main
paths:
- 'backend/**'

concurrency:
group: "edge-docker-images"
cancel-in-progress: false

env:
REGISTRY: ghcr.io

jobs:
backend-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
IMAGE_NAME: jt-foss/backend
# Set default working directory
defaults:
run:
working-directory: ./backend # Change the working directory to /backend
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=edge
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./backend
file: ./backend/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
68 changes: 68 additions & 0 deletions .github/workflows/publish-prod-docker-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Publish Production Docker Images

on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
paths:
- 'backend/**'

concurrency:
group: "prod-docker-images"
cancel-in-progress: false

env:
REGISTRY: ghcr.io
IMAGE_NAME: jt-foss/backend

jobs:
backend-image:
if: github.event_name == 'create' && github.event.ref_type == 'tag'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
IMAGE_NAME: jt-foss/backend
# Set default working directory
defaults:
run:
working-directory: ./backend # Change the working directory to /backend
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./backend
file: ./backend/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
5 changes: 5 additions & 0 deletions backend/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[alias]
loco = "run --"
loco-rl = "run --release --"
loco-tool = "run --bin tool --"
playground = "run --example playground"
13 changes: 13 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
target
Dockerfile
docs
logs
.github
.dockerignore
.git
.gitignore
.idea
.editorconfig
.env
.env.dist
rust-toolchain.toml
1 change: 0 additions & 1 deletion backend/.editorconfig

This file was deleted.

1 change: 1 addition & 0 deletions backend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../.editorconfig
Loading

0 comments on commit c06d536

Please sign in to comment.