From 5e06c10c276314c089085f12e674ede4b5ef7a42 Mon Sep 17 00:00:00 2001 From: "ryan.li" Date: Sun, 20 Apr 2025 21:57:37 +0800 Subject: [PATCH 1/8] Add workflow of testing backend --- .github/workflows/test_backend.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/test_backend.yml diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml new file mode 100644 index 0000000..8755dec --- /dev/null +++ b/.github/workflows/test_backend.yml @@ -0,0 +1,28 @@ +name: Test Backend + +on: + push: + branches: + - "*" + pull_request: + branches: + - main + +jobs: + test-backend: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v5 + with: + version: "latest" + enable-cache: true + - name: Run tests + run: uv run pytest + working-directory: backend From 93ea9edce035eedd1514b240f7ac2cb1b61bd0cb Mon Sep 17 00:00:00 2001 From: "ryan.li" Date: Sun, 20 Apr 2025 22:32:18 +0800 Subject: [PATCH 2/8] Add lint action for backend --- .github/workflows/lint_backend.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/lint_backend.yml diff --git a/.github/workflows/lint_backend.yml b/.github/workflows/lint_backend.yml new file mode 100644 index 0000000..b9c9211 --- /dev/null +++ b/.github/workflows/lint_backend.yml @@ -0,0 +1,26 @@ +name: Lint Backend + +on: + push: + branches: + - "*" + pull-request: + branches: + - "main" + +jobs: + lint-backend: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Run Ruff Format + run: uv run ruff format src --check + working-directory: backend + - name: Run Ruff Lint + run: uv run ruff check src + working-directory: backend From 9884e5053d048efd35f7f819f0610528c9d3e283 Mon Sep 17 00:00:00 2001 From: "ryan.li" Date: Sun, 20 Apr 2025 22:33:55 +0800 Subject: [PATCH 3/8] Fix typo --- .github/workflows/lint_backend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint_backend.yml b/.github/workflows/lint_backend.yml index b9c9211..4b9f603 100644 --- a/.github/workflows/lint_backend.yml +++ b/.github/workflows/lint_backend.yml @@ -4,7 +4,7 @@ on: push: branches: - "*" - pull-request: + pull_request: branches: - "main" From 74891ea81d9de8522729f4342dcdc9ad73822fcd Mon Sep 17 00:00:00 2001 From: "ryan.li" Date: Sun, 20 Apr 2025 22:35:03 +0800 Subject: [PATCH 4/8] Add uv installed --- .github/workflows/lint_backend.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/lint_backend.yml b/.github/workflows/lint_backend.yml index 4b9f603..cfbc961 100644 --- a/.github/workflows/lint_backend.yml +++ b/.github/workflows/lint_backend.yml @@ -18,6 +18,11 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.12" + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v5 + with: + version: "latest" + enable-cache: true - name: Run Ruff Format run: uv run ruff format src --check working-directory: backend From c28b0fb6cddadfef50900e19a0c6ccb6cd83f39d Mon Sep 17 00:00:00 2001 From: "ryan.li" Date: Sun, 20 Apr 2025 22:59:29 +0800 Subject: [PATCH 5/8] Add frontend lint --- .github/workflows/lint_frontend.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/lint_frontend.yml diff --git a/.github/workflows/lint_frontend.yml b/.github/workflows/lint_frontend.yml new file mode 100644 index 0000000..c67ee0d --- /dev/null +++ b/.github/workflows/lint_frontend.yml @@ -0,0 +1,28 @@ +name: Lint Frontend + +on: + push: + branches: + - "*" + pull_request: + branches: + - "main" + +jobs: + lint-frontend: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "20" + - name: Install pnpm + run: npm install -g pnpm + - name: Install dependencies + run: pnpm install + working-directory: frontend + - name: Run lint + run: pnpm run lint + working-directory: frontend From 43cbe5a4a99bfe820cae5d790da4c1dce2ecb58d Mon Sep 17 00:00:00 2001 From: "ryan.li" Date: Mon, 21 Apr 2025 21:01:54 +0800 Subject: [PATCH 6/8] Test lint workflow while pull_request --- .github/workflows/lint_backend.yml | 2 +- .github/workflows/lint_frontend.yml | 2 +- backend/.env.example | 25 ------------------------- backend/src/main.py | 4 +++- frontend/.env.example | 3 --- 5 files changed, 5 insertions(+), 31 deletions(-) delete mode 100644 backend/.env.example delete mode 100644 frontend/.env.example diff --git a/.github/workflows/lint_backend.yml b/.github/workflows/lint_backend.yml index cfbc961..752823e 100644 --- a/.github/workflows/lint_backend.yml +++ b/.github/workflows/lint_backend.yml @@ -3,7 +3,7 @@ name: Lint Backend on: push: branches: - - "*" + - "main" pull_request: branches: - "main" diff --git a/.github/workflows/lint_frontend.yml b/.github/workflows/lint_frontend.yml index c67ee0d..a7a086f 100644 --- a/.github/workflows/lint_frontend.yml +++ b/.github/workflows/lint_frontend.yml @@ -3,7 +3,7 @@ name: Lint Frontend on: push: branches: - - "*" + - "main" pull_request: branches: - "main" diff --git a/backend/.env.example b/backend/.env.example deleted file mode 100644 index acbfb43..0000000 --- a/backend/.env.example +++ /dev/null @@ -1,25 +0,0 @@ -# Environment: local, staging, production -ENVIRONMENT=local - -PROJECT_NAME="FlashNotes" - -# Backend -BACKEND_CORS_ORIGINS="http://127.0.0.1:5173,http://localhost,http://localhost:5173,https://localhost,https://localhost:5173" -SECRET_KEY=fake-key -FIRST_SUPERUSER=admin@example.com -FIRST_SUPERUSER_PASSWORD=changethis -USERS_OPEN_REGISTRATION=True - - -# Postgres -POSTGRES_SERVER=localhost -POSTGRES_PORT=5432 -POSTGRES_DB=app -POSTGRES_USER=postgres -POSTGRES_PASSWORD=changethis - -# AI -AI_MODEL= -AI_API_KEY= - -COLLECTION_GENERATION_PROMPT="I want to generate flashcards on a specific topic for efficient studying. Please create a set of flashcards covering key concepts, definitions, important details, and examples, with a focus on progressively building understanding of the topic. The flashcards should aim to provide a helpful learning experience by using structured explanations, real-world examples and formatting. Each flashcard should follow this format: Front (Question/Prompt): A clear and concise question or term to test recall, starting with introductory concepts and moving toward more complex details. Back (Answer): If the front is a concept or topic, provide a detailed explanation, broken down into clear paragraphs with easy-to-understand language. If possible, include a real-world example, analogy or illustrative diagrams to make the concept more memorable and relatable. If the front is a vocabulary word (for language learning), provide a direct translation in the target language. Optional Hint: A short clue to aid recall, especially for more complex concepts. Important: Use valid Markdown format for the back of the flashcard." diff --git a/backend/src/main.py b/backend/src/main.py index 91ba021..8d4f6a7 100644 --- a/backend/src/main.py +++ b/backend/src/main.py @@ -22,7 +22,8 @@ def custom_generate_unique_id(route: APIRoute) -> str: app.add_middleware( CORSMiddleware, allow_origins=[ - str(origin).strip("/") for origin in settings.BACKEND_CORS_ORIGINS + # str(origin).strip("/") for origin in settings.BACKEND_CORS_ORIGINS + "*" ], allow_credentials=True, allow_methods=["*"], @@ -31,3 +32,4 @@ def custom_generate_unique_id(route: APIRoute) -> str: app.include_router(api_router, prefix=settings.API_V1_STR) add_pagination(app) + diff --git a/frontend/.env.example b/frontend/.env.example deleted file mode 100644 index f11436c..0000000 --- a/frontend/.env.example +++ /dev/null @@ -1,3 +0,0 @@ -VITE_API_URL=http://localhost:8000 -VITE_POSTHOG_API_KEY= -VITE_POSTHOG_HOST= From 4dd942f21f902cc37e5bcecac4acb77e3034b912 Mon Sep 17 00:00:00 2001 From: "ryan.li" Date: Mon, 21 Apr 2025 21:54:18 +0800 Subject: [PATCH 7/8] Modify the biome config --- frontend/biome.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/biome.json b/frontend/biome.json index d0021e8..8ca830e 100644 --- a/frontend/biome.json +++ b/frontend/biome.json @@ -4,11 +4,11 @@ "enabled": true }, "files": { - "ignore": ["node_modules", "src/routeTree.gen.ts", "src/components/ui"] + "ignore": ["node_modules", "src/routeTree.gen.ts", "src/components/ui", "src/client/*"] }, "linter": { "enabled": true, - "ignore": ["src/components/ui"], + "ignore": ["src/components/ui", "src/client/*"], "rules": { "recommended": true, "suspicious": { @@ -25,7 +25,7 @@ "indentStyle": "space", "indentWidth": 2, "lineWidth": 100, - "ignore": ["src/components/ui", "src/assets/*"] + "ignore": ["src/components/ui", "src/client/*", "src/assets/*"] }, "javascript": { "formatter": { From bae996827a3bc7e03d441b8e7b0ad5fc1a93d37f Mon Sep 17 00:00:00 2001 From: "ryan.li" Date: Mon, 21 Apr 2025 21:56:56 +0800 Subject: [PATCH 8/8] Add diff arg in backend lint --- .github/workflows/lint_backend.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint_backend.yml b/.github/workflows/lint_backend.yml index 752823e..0d88401 100644 --- a/.github/workflows/lint_backend.yml +++ b/.github/workflows/lint_backend.yml @@ -23,8 +23,8 @@ jobs: with: version: "latest" enable-cache: true - - name: Run Ruff Format - run: uv run ruff format src --check + - name: Run Ruff Format With Diff + run: uv run ruff format src --check --diff working-directory: backend - name: Run Ruff Lint run: uv run ruff check src