Skip to content

Commit

Permalink
Merge pull request #37 from OneLiteFeatherNET/feat/lib
Browse files Browse the repository at this point in the history
Feat/lib
  • Loading branch information
Randoooom authored Mar 14, 2024
2 parents 2ac563b + 9463591 commit 36aa5e4
Show file tree
Hide file tree
Showing 61 changed files with 3,547 additions and 125 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ name: Continuous integration

on:
workflow_dispatch:
push:
branches:
- main
paths:
- "**.rs"
pull_request:
merge_group:

Expand Down
183 changes: 183 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
name: Continuous integration

on:
workflow_dispatch:
push:
branches:
- main

jobs:
check:
name: check
runs-on: ubuntu-latest
steps:
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- name: Checkout Sources
uses: actions/checkout@v3

- name: Setup cache
uses: Swatinem/rust-cache@v2

- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-make

- name: Run check
run: cargo make check

clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: clippy
profile: minimal

- name: Checkout Sources
uses: actions/checkout@v3

- name: Setup cache
uses: Swatinem/rust-cache@v2

- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-make

- name: Run clippy
run: cargo make clippy

test:
needs: [ clippy, check ]
name: tests
runs-on: ubuntu-latest
steps:
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
profile: minimal

- name: Checkout Sources
uses: actions/checkout@v3

- name: Setup cache
uses: Swatinem/rust-cache@v2

- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-make

- name: Tests
run: cargo make test

docs-lint:
name: lint docs
runs-on: ubuntu-latest
steps:
- uses: pnpm/action-setup@v2
with:
version: 8

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- name: Checkout Sources
uses: actions/checkout@v3

- name: Setup cache
uses: Swatinem/rust-cache@v2

- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-make

- name: Run docs lint
uses: actions-rs/cargo@v1
with:
command: make
args: docs_lint

build-docs:
name: build docs
runs-on: ubuntu-latest
steps:
- uses: pnpm/action-setup@v2
with:
version: 8

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- name: Checkout Sources
uses: actions/checkout@v3

- name: Setup cache
uses: Swatinem/rust-cache@v2

- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-make

- name: Build docs
uses: actions-rs/cargo@v1
with:
command: make
args: docs_build

- name: Archive artifact
run: |
tar \
--dereference --hard-dereference \
-cvf "$RUNNER_TEMP/pages.tar" \
docs/
- name: Upload artifact
id: upload-artifact
uses: actions/upload-artifact@v4
with:
name: pages
path: ${{ runner.temp }}/pages.tar
retention-days: 1
if-no-files-found: error

deploy-docs:
needs: [build-docs]
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}/nightly
steps:
- name: Deploy to pages
id: deployment
uses: actions/deploy-pages@v4
with:
artifact_name: "pages"
17 changes: 15 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@ name = "feedback-fusion"
version = "0.1.0"
edition = "2021"
license = "MIT"
default-run = "main"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[[bin]]
name = "main"
path = "src/main.rs"

[[bin]]
name = "docs"
path = "src/docs.rs"

[[bin]]
name = "bindings"
path = "src/bindings.rs"

[dependencies]
aliri = "0.6.2"
Expand Down Expand Up @@ -35,6 +46,7 @@ tower = { version = "0.4.13", features = ["limit", "buffer"] }
tower-http = { version = "0.4.4", features = ["trace"] }
tracing = "0.1.39"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
ts-rs = { version = "7.0.0", optional = true }
typed-builder = "0.18.0"
utoipa = { version = "4.1.0", features = ["yaml", "chrono"] }
validator = { version = "0.16", features = ["derive"] }
Expand All @@ -48,10 +60,11 @@ test-log = "0.2.14"
[features]
default = ["all-databases"]

docs = []
all-databases = ["postgres", "mysql"]
postgres = ["rbdc-pg"]
mysql = ["rbdc-mysql"]

test = []
docs = []
bindings = ["ts-rs"]

38 changes: 31 additions & 7 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ args = ["i"]
[tasks.docs_generate]
dependencies = ["docs_init"]
command = "cargo"
args = ["run", "--features", "docs"]
args = ["run", "--bin", "docs", "--features", "docs"]

[tasks.docs_preview]
dependencies = ["docs_generate"]
Expand All @@ -21,11 +21,20 @@ args = ["redocly", "preview-docs", "target/openapi.yaml"]

[tasks.check]
command = "cargo"
args = ["check"]
args = ["check", "--bin", "main"]

[tasks.clippy]
command = "cargo"
args = ["clippy", "--features", "postgres", "--", "-D", "warnings"]
args = [
"clippy",
"--bin",
"main",
"--features",
"postgres",
"--",
"-D",
"warnings",
]

[tasks.oidc-server-mock]
script = "docker compose -f testing/oidc-mock/docker-compose.yaml up -d"
Expand All @@ -35,15 +44,13 @@ script = "docker compose -f testing/oidc-mock/docker-compose.yaml up -d"
script = "docker run --name postgres -e POSTGRES_PASSWORD=password -e POSTGRES_USERNAME=postgres -p 5150:5432 -d postgres && sleep 1"

[tasks.postgres_tests]
env = { DATABASE = "POSTGRES", POSTGRES_USERNAME = "postgres", POSTGRES_PASSWORD = "password", POSTGRES_ENDPOINT = "localhost:5150", POSTGRES_DATABASE = "postgres", "OIDC_DISCOVERY_URL" = "http://localhost:5151", OIDC_CLIENT_ID = "client", OIDC_CLIENT_SECRET = "secret", RUST_LOG = "DEBUG", OIDC_SCOPE = "api:feedback-fusion" }
env = { DATABASE = "POSTGRES", POSTGRES_USERNAME = "postgres", POSTGRES_PASSWORD = "password", POSTGRES_ENDPOINT = "localhost:5150", POSTGRES_DATABASE = "postgres", "OIDC_DISCOVERY_URL" = "http://localhost:5151", OIDC_CLIENT_ID = "client", OIDC_CLIENT_SECRET = "secret", OIDC_SCOPE = "api:feedback-fusion" }
command = "cargo"
args = [
"test",
"--no-default-features",
"--features",
"postgres,test",
"--test",
"http_tests",
"--",
"--nocapture",
"--test-threads=1",
Expand Down Expand Up @@ -78,4 +85,21 @@ args = [
[tasks.docs_build]
dependencies = ["docs_lint"]
command = "npx"
args = ["redocly", "build-docs", "target/openapi.yaml", "-o", "docs/index.html"]
args = ["redocly", "build-docs", "target/openapi.yaml", "-o", "docs/rest/index.html"]

[tasks.generate_bindings]
command = "cargo"
args = [
"run",
"--bin",
"bindings",
"--no-default-features",
"--features",
"bindings,postgres",
]

[tasks.export_bindings]
script = '''for f in bindings/*.ts; do [ "$f" != "bindings/index.ts" ] && echo "export * from './$(basename "$f" .ts)';" ; done > bindings/index.ts'''

[tasks.bindings]
run_task = { name = ["generate_bindings", "export_bindings"] }
5 changes: 5 additions & 0 deletions bindings/CreateFeedbackPromptFieldRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FeedbackPromptInputOptions } from "./FeedbackPromptInputOptions";
import type { FeedbackPromptInputType } from "./FeedbackPromptInputType";

export interface CreateFeedbackPromptFieldRequest { title: string, type: FeedbackPromptInputType, options: FeedbackPromptInputOptions, }
3 changes: 3 additions & 0 deletions bindings/CreateFeedbackPromptRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export interface CreateFeedbackPromptRequest { title: string, active: boolean, }
3 changes: 3 additions & 0 deletions bindings/CreateFeedbackTargetRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export interface CreateFeedbackTargetRequest { name: string, description: string | null, }
3 changes: 3 additions & 0 deletions bindings/FeedbackPrompt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export interface FeedbackPrompt { id: string, title: string, target: string, active: boolean, updated_at: Date, created_at: Date, }
5 changes: 5 additions & 0 deletions bindings/FeedbackPromptField.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FeedbackPromptInputOptions } from "./FeedbackPromptInputOptions";
import type { FeedbackPromptInputType } from "./FeedbackPromptInputType";

export interface FeedbackPromptField { id: string, title: string, prompt: string, type: FeedbackPromptInputType, options: FeedbackPromptInputOptions, updated_at: Date, created_at: Date, }
5 changes: 5 additions & 0 deletions bindings/FeedbackPromptFieldData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { RatingResponse } from "./RatingResponse";
import type { TextResponse } from "./TextResponse";

export type FeedbackPromptFieldData = TextResponse | RatingResponse;
4 changes: 4 additions & 0 deletions bindings/FeedbackPromptFieldResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FeedbackPromptFieldData } from "./FeedbackPromptFieldData";

export interface FeedbackPromptFieldResponse { id: string, response: string, field: string, data: FeedbackPromptFieldData, }
5 changes: 5 additions & 0 deletions bindings/FeedbackPromptInputOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { RatingOptions } from "./RatingOptions";
import type { TextOptions } from "./TextOptions";

export type FeedbackPromptInputOptions = TextOptions | RatingOptions;
3 changes: 3 additions & 0 deletions bindings/FeedbackPromptInputType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type FeedbackPromptInputType = "text" | "rating";
3 changes: 3 additions & 0 deletions bindings/FeedbackPromptResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export interface FeedbackPromptResponse { id: string, prompt: string, created_at: Date, }
3 changes: 3 additions & 0 deletions bindings/FeedbackTarget.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export interface FeedbackTarget { id: string, name: string, description: string | null, updated_at: Date, created_at: Date, }
4 changes: 4 additions & 0 deletions bindings/GetFeedbackPromptResponsesResponseWrapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FeedbackPromptFieldResponse } from "./FeedbackPromptFieldResponse";

export type GetFeedbackPromptResponsesResponseWrapper = Record<string, Array<FeedbackPromptFieldResponse>>;
4 changes: 4 additions & 0 deletions bindings/Page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FeedbackPromptField } from "./FeedbackPromptField";

export interface Page<T> { records: Array<T>, total: number, page_no: number, }
4 changes: 4 additions & 0 deletions bindings/PutFeedbackPromptFieldRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FeedbackPromptInputOptions } from "./FeedbackPromptInputOptions";

export interface PutFeedbackPromptFieldRequest { title: string | null, options: FeedbackPromptInputOptions | null, }
3 changes: 3 additions & 0 deletions bindings/PutFeedbackPromptRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export interface PutFeedbackPromptRequest { title: string | null, active: boolean | null, }
Loading

0 comments on commit 36aa5e4

Please sign in to comment.