Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ docs:
- changed-files:
- any-glob-to-any-file:
- '**/*.md'
- all-globs-to-all-files:
- '!frontend/**'
- '!backend/**'
- '!.github/**'
- '!scripts/**'
- '!.gitignore'
- '!.pre-commit-config.yaml'

internal:
- all:
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/generate-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Generate Client

on:
pull_request:
types:
- opened
- synchronize

jobs:
generate-client:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.FULL_STACK_FASTAPI_TEMPLATE_REPO_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: npm ci
working-directory: frontend
- run: pip install ./backend
- run: bash scripts/generate-client.sh
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
git add frontend/src/client
git diff --staged --quiet || git commit -m "✨ Autogenerate frontend client"
git push

# https://github.com/marketplace/actions/alls-green#why
generate-client-alls-green: # This job does nothing and is only used for the branch protection
if: always()
needs:
- generate-client
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

7 changes: 4 additions & 3 deletions .github/workflows/issue-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Issue Manager

on:
schedule:
- cron: "13 4 * * *"
- cron: "21 17 * * *"
issue_comment:
types:
- created
Expand All @@ -16,6 +16,7 @@ on:

permissions:
issues: write
pull-requests: write

jobs:
issue-manager:
Expand All @@ -35,8 +36,8 @@ jobs:
"delay": 864000,
"message": "Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs."
},
"changes-requested": {
"waiting": {
"delay": 2628000,
"message": "As this PR had requested changes to be applied but has been inactive for a while, it's now going to be closed. But if there's anyone interested, feel free to create a new PR."
"message": "As this PR has been waiting for the original user for a while but seems to be inactive, it's now going to be closed. But if there's anyone interested, feel free to create a new PR."
}
}
5 changes: 3 additions & 2 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ jobs:
working-directory: frontend
- run: docker compose build
- run: docker compose down -v --remove-orphans
- run: docker compose up -d
- run: docker compose up -d --wait
- name: Run Playwright tests
run: npx playwright test
run: npx playwright test --fail-on-flaky-tests --trace=retain-on-failure
working-directory: frontend
- run: docker compose down -v --remove-orphans
- uses: actions/upload-artifact@v4
Expand All @@ -52,6 +52,7 @@ jobs:
name: playwright-report
path: frontend/playwright-report/
retention-days: 30
include-hidden-files: true

# https://github.com/marketplace/actions/alls-green#why
e2e-alls-green: # This job does nothing and is only used for the branch protection
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
with:
name: coverage-html
path: backend/htmlcov
include-hidden-files: true

# https://github.com/marketplace/actions/alls-green#why
alls-green: # This job does nothing and is only used for the branch protection
Expand Down
5 changes: 5 additions & 0 deletions backend/app/api/routes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ def test_email(email_to: EmailStr) -> Message:
html_content=email_data.html_content,
)
return Message(message="Test email sent")


@router.get("/health-check/")
async def health_check() -> bool:
return True
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ services:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set}
- SENTRY_DSN=${SENTRY_DSN}

healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/api/v1/utils/health-check/"]
interval: 10s
timeout: 5s
retries: 5

build:
context: ./backend
args:
Expand Down
17 changes: 15 additions & 2 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The frontend is built with [Vite](https://vitejs.dev/), [React](https://reactjs.

## Frontend development

Before you begin, ensure that you have either the Node Version Manager (nvm) or Fast Node Manager (fnm) installed on your system.
Before you begin, ensure that you have either the Node Version Manager (nvm) or Fast Node Manager (fnm) installed on your system.

* To install fnm follow the [official fnm guide](https://github.com/Schniz/fnm#installation). If you prefer nvm, you can install it using the [official nvm guide](https://github.com/nvm-sh/nvm#installing-and-updating).

Expand All @@ -27,7 +27,7 @@ nvm install

```bash
# If using fnm
fnm use
fnm use

# If using nvm
nvm use
Expand Down Expand Up @@ -74,6 +74,19 @@ But it would be only to clean them up, leaving them won't really have any effect

## Generate Client

### Automatically

* Activate the backend virtual environment.
* From the top level project directory, run the script:

```bash
./scripts/generate-frontend-client.sh
```

* Commit the changes.

### Manually

* Start the Docker Compose stack.

* Download the OpenAPI JSON file from `http://localhost/api/v1/openapi.json` and copy it to a new file `openapi.json` at the root of the `frontend` directory.
Expand Down
1 change: 0 additions & 1 deletion frontend/biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"files": {
"ignore": [
"node_modules",
"src/client/",
"src/routeTree.gen.ts",
"playwright.config.ts",
"playwright-report"
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "tsc && vite build",
"lint": "biome check --apply-unsafe --no-errors-on-unmatched --files-ignore-unknown=true ./",
"preview": "vite preview",
"generate-client": "openapi-ts --input ./openapi.json --output ./src/client --client axios --exportSchemas true && biome format --write ./src/client"
"generate-client": "openapi-ts --input ./openapi.json --output ./src/client --client axios --exportSchemas true"
},
"dependencies": {
"@chakra-ui/icons": "2.1.1",
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/client/core/request.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import axios from "axios"
import type {
AxiosError,
AxiosInstance,
AxiosRequestConfig,
AxiosResponse,
AxiosInstance,
} from "axios"

import { ApiError } from "./ApiError"
Expand Down Expand Up @@ -151,12 +151,12 @@ export const getHeaders = async (
)

if (isStringWithValue(token)) {
headers.Authorization = `Bearer ${token}`
headers["Authorization"] = `Bearer ${token}`
}

if (isStringWithValue(username) && isStringWithValue(password)) {
const credentials = base64(`${username}:${password}`)
headers.Authorization = `Basic ${credentials}`
headers["Authorization"] = `Basic ${credentials}`
}

if (options.body !== undefined) {
Expand Down
Loading