Compare commits
1 commit
81c160a50e
...
1b3dfef45b
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b3dfef45b |
5 changed files with 101 additions and 143 deletions
|
|
@ -86,4 +86,82 @@ jobs:
|
||||||
- name: Test
|
- name: Test
|
||||||
run: npm run test
|
run: npm run test
|
||||||
working-directory: frontend
|
working-directory: frontend
|
||||||
|
|
||||||
|
docker-backend:
|
||||||
|
name: Build and Push Backend Image
|
||||||
|
runs-on: docker
|
||||||
|
needs: [check-backend]
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repo
|
||||||
|
uses: https://github.com/actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: https://github.com/docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to Forgejo Container Registry
|
||||||
|
uses: https://github.com/docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ gitea.server_url }}
|
||||||
|
username: ${{ gitea.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata
|
||||||
|
id: meta
|
||||||
|
uses: https://github.com/docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ gitea.server_url }}/${{ gitea.repository }}/backend
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=sha,prefix={{branch}}-
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
uses: https://github.com/docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: ./backend
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
|
docker-frontend:
|
||||||
|
name: Build and Push Frontend Image
|
||||||
|
runs-on: docker
|
||||||
|
needs: [check-frontend]
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repo
|
||||||
|
uses: https://github.com/actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: https://github.com/docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to Forgejo Container Registry
|
||||||
|
uses: https://github.com/docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ gitea.server_url }}
|
||||||
|
username: ${{ gitea.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata
|
||||||
|
id: meta
|
||||||
|
uses: https://github.com/docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ gitea.server_url }}/${{ gitea.repository }}/frontend
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=sha,prefix={{branch}}-
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
uses: https://github.com/docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: ./frontend
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,86 +0,0 @@
|
||||||
name: Docker Build
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ main ]
|
|
||||||
|
|
||||||
env:
|
|
||||||
# Should speed up builds.
|
|
||||||
CARGO_INCREMENTAL: 0
|
|
||||||
# Should reduce the size of ./target to improve cache load/store.
|
|
||||||
CARGO_PROFILE_TEST_DEBUG: 0
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker-backend:
|
|
||||||
name: Build and Push Backend Image
|
|
||||||
runs-on: docker
|
|
||||||
steps:
|
|
||||||
- name: Checkout Repo
|
|
||||||
uses: https://github.com/actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: https://github.com/docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Login to Forgejo Container Registry
|
|
||||||
uses: https://github.com/docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ gitea.server_url }}
|
|
||||||
username: ${{ gitea.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Extract metadata
|
|
||||||
id: meta
|
|
||||||
uses: https://github.com/docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ gitea.server_url }}/${{ gitea.repository }}/backend
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=sha,prefix={{branch}}-
|
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
|
|
||||||
- name: Build and push image
|
|
||||||
uses: https://github.com/docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: ./backend
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
docker-frontend:
|
|
||||||
name: Build and Push Frontend Image
|
|
||||||
runs-on: docker
|
|
||||||
steps:
|
|
||||||
- name: Checkout Repo
|
|
||||||
uses: https://github.com/actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: https://github.com/docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Login to Forgejo Container Registry
|
|
||||||
uses: https://github.com/docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ gitea.server_url }}
|
|
||||||
username: ${{ gitea.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Extract metadata
|
|
||||||
id: meta
|
|
||||||
uses: https://github.com/docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ gitea.server_url }}/${{ gitea.repository }}/frontend
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=sha,prefix={{branch}}-
|
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
|
|
||||||
- name: Build and push image
|
|
||||||
uses: https://github.com/docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: ./frontend
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
15
backend/Cargo.lock
generated
15
backend/Cargo.lock
generated
|
|
@ -289,7 +289,6 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower-http",
|
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"uuid",
|
"uuid",
|
||||||
|
|
@ -3491,20 +3490,6 @@ dependencies = [
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tower-http"
|
|
||||||
version = "0.6.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.9.3",
|
|
||||||
"bytes",
|
|
||||||
"http 1.3.1",
|
|
||||||
"pin-project-lite",
|
|
||||||
"tower-layer",
|
|
||||||
"tower-service",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tower-layer"
|
name = "tower-layer"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use axum::{Router, routing::get};
|
use axum::{Router, routing::get};
|
||||||
use tower_http::cors::{Any, CorsLayer};
|
use tower_http::cors::{CorsLayer, Any};
|
||||||
|
|
||||||
mod database;
|
mod database;
|
||||||
mod models;
|
mod models;
|
||||||
|
|
@ -17,12 +17,8 @@ async fn main() {
|
||||||
let cors = if std::env::var("RUST_ENV").unwrap_or_default() == "production" {
|
let cors = if std::env::var("RUST_ENV").unwrap_or_default() == "production" {
|
||||||
CorsLayer::new()
|
CorsLayer::new()
|
||||||
.allow_origin([
|
.allow_origin([
|
||||||
"https://tiramisu.one"
|
"https://tiramisu.one".parse::<axum::http::HeaderValue>().unwrap(),
|
||||||
.parse::<axum::http::HeaderValue>()
|
"https://*.tiramisu.one".parse::<axum::http::HeaderValue>().unwrap()
|
||||||
.unwrap(),
|
|
||||||
"https://*.tiramisu.one"
|
|
||||||
.parse::<axum::http::HeaderValue>()
|
|
||||||
.unwrap(),
|
|
||||||
])
|
])
|
||||||
.allow_methods(Any)
|
.allow_methods(Any)
|
||||||
.allow_headers(Any)
|
.allow_headers(Any)
|
||||||
|
|
|
||||||
|
|
@ -52,12 +52,9 @@ describe('API Client', () => {
|
||||||
|
|
||||||
const result = await apiClient.listTasks()
|
const result = await apiClient.listTasks()
|
||||||
|
|
||||||
expect(mockFetch).toHaveBeenCalledWith(
|
expect(mockFetch).toHaveBeenCalledWith('/api/tasks', {
|
||||||
'http://localhost:3000/api/tasks',
|
headers: { 'Content-Type': 'application/json' },
|
||||||
{
|
})
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
}
|
|
||||||
)
|
|
||||||
expect(result).toEqual(mockTasks)
|
expect(result).toEqual(mockTasks)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -97,12 +94,9 @@ describe('API Client', () => {
|
||||||
|
|
||||||
const result = await apiClient.getTask(mockTask.id)
|
const result = await apiClient.getTask(mockTask.id)
|
||||||
|
|
||||||
expect(mockFetch).toHaveBeenCalledWith(
|
expect(mockFetch).toHaveBeenCalledWith(`/api/tasks/${mockTask.id}`, {
|
||||||
`http://localhost:3000/api/tasks/${mockTask.id}`,
|
headers: { 'Content-Type': 'application/json' },
|
||||||
{
|
})
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
}
|
|
||||||
)
|
|
||||||
expect(result).toEqual(mockTask)
|
expect(result).toEqual(mockTask)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -136,14 +130,11 @@ describe('API Client', () => {
|
||||||
|
|
||||||
const result = await apiClient.createTask(newTaskData)
|
const result = await apiClient.createTask(newTaskData)
|
||||||
|
|
||||||
expect(mockFetch).toHaveBeenCalledWith(
|
expect(mockFetch).toHaveBeenCalledWith('/api/tasks', {
|
||||||
'http://localhost:3000/api/tasks',
|
method: 'POST',
|
||||||
{
|
headers: { 'Content-Type': 'application/json' },
|
||||||
method: 'POST',
|
body: JSON.stringify(newTaskData),
|
||||||
headers: { 'Content-Type': 'application/json' },
|
})
|
||||||
body: JSON.stringify(newTaskData),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
expect(result).toEqual(mockTask)
|
expect(result).toEqual(mockTask)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -183,14 +174,11 @@ describe('API Client', () => {
|
||||||
|
|
||||||
const result = await apiClient.updateTask(mockTask.id, updateData)
|
const result = await apiClient.updateTask(mockTask.id, updateData)
|
||||||
|
|
||||||
expect(mockFetch).toHaveBeenCalledWith(
|
expect(mockFetch).toHaveBeenCalledWith(`/api/tasks/${mockTask.id}`, {
|
||||||
`http://localhost:3000/api/tasks/${mockTask.id}`,
|
method: 'PUT',
|
||||||
{
|
headers: { 'Content-Type': 'application/json' },
|
||||||
method: 'PUT',
|
body: JSON.stringify(updateData),
|
||||||
headers: { 'Content-Type': 'application/json' },
|
})
|
||||||
body: JSON.stringify(updateData),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
expect(result).toEqual(updatedTask)
|
expect(result).toEqual(updatedTask)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -223,13 +211,10 @@ describe('API Client', () => {
|
||||||
const result = await apiClient.deleteTask(mockTask.id)
|
const result = await apiClient.deleteTask(mockTask.id)
|
||||||
expect(result).toBeNull()
|
expect(result).toBeNull()
|
||||||
|
|
||||||
expect(mockFetch).toHaveBeenCalledWith(
|
expect(mockFetch).toHaveBeenCalledWith(`/api/tasks/${mockTask.id}`, {
|
||||||
`http://localhost:3000/api/tasks/${mockTask.id}`,
|
method: 'DELETE',
|
||||||
{
|
headers: { 'Content-Type': 'application/json' },
|
||||||
method: 'DELETE',
|
})
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should handle delete errors', async () => {
|
it('should handle delete errors', async () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue