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
47 changes: 47 additions & 0 deletions .github/workflows/test_backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Test Backend

on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
workflow_dispatch:

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: Rename env file
run : mv .env.example .env
working-directory: backend
- run: docker compose -f docker-compose.test.yml down -v --remove-orphans
working-directory: backend
- run: docker compose -f docker-compose.test.yml up -d db
working-directory: backend
- name: Setup environment
run: uv run bash prestart.sh
working-directory: backend
- name: Run tests
run: uv run bash tests-start.sh "Coverage for ${{ github.sha }}"
working-directory: backend
- run: docker compose -f docker-compose.test.yml down -v --remove-orphans
working-directory: backend
- name: Store coverage files
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: backend/htmlcov
include-hidden-files: true
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@

Explore the API documentation at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs).

## Running GitHub Actions Locally

To test your GitHub Actions workflows locally before pushing to GitHub, you can use [`nektos/act`](https://github.com/nektos/act). This tool allows you to simulate GitHub Actions workflows using Docker.

Here is a simple guide for how to do this [here](./docs/how-to-run-github-action-locally.md).

## Setup Instructions

### Backend Setup
Expand Down
6 changes: 3 additions & 3 deletions backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ POSTGRES_USER=postgres
POSTGRES_PASSWORD=changethis

# AI
AI_MODEL=
AI_API_KEY=
AI_MODEL="dummy_model"
AI_API_KEY="dummy_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."
CARD_GENERATION_PROMPT="I want to generate a flashcard on a specific topic. The contents of the flashcard should provide helpful information that aim to help the learner retain the concepts given. The flashcard must follow this format: Front (Question/Prompt): A clear and concise question or term to test recall. 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. Important: Use valid Markdown format for the back of the flashcard."
CARD_GENERATION_PROMPT="I want to generate a flashcard on a specific topic. The contents of the flashcard should provide helpful information that aim to help the learner retain the concepts given. The flashcard must follow this format: Front (Question/Prompt): A clear and concise question or term to test recall. 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. Important: Use valid Markdown format for the back of the flashcard."
14 changes: 14 additions & 0 deletions backend/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
db:
image: postgres:latest
restart: always
ports:
- "5432:5432"
env_file:
- .env
environment:
- PGDATA=/var/lib/postgresql/data/pgdata
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set}
- POSTGRES_USER=${POSTGRES_USER?Variable not set}
- POSTGRES_DB=${POSTGRES_DB?Variable not set}
- POSTGRES_SERVER=db
2 changes: 1 addition & 1 deletion backend/tests-start.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ alembic upgrade head

python tests/tests_pre_start.py

coverage run --source=app -m pytest
coverage run --source=src -m pytest
coverage report --show-missing
coverage html --title "${@-coverage}"
58 changes: 58 additions & 0 deletions docs/how-to-run-github-action-locally.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# How to Run GitHub Actions Locally Using `act`

This guide explains how to use [`nektos/act`](https://github.com/nektos/act) to run GitHub Actions locally on your machine for fast feedback and workflow testing.

## 🛠 Prerequisites

- Docker installed and running (compatible with Linux, macOS, or Windows)
- `act` installed: See the official documentation for installation instructions:
👉 https://github.com/nektos/act#installation

## ⚙️ Basic Usage

To run your default workflow locally:

```bash
act
```

To run a specific event:

```bash
act pull_request
```

To run a specific job from your workflow file:

```bash
act -j job-name
```

To run a specific workflow:

```bash
act -W workflow-file-name
```

## 🧪 Dry Run Mode

To preview what `act` will do without actually running the jobs:

```bash
act --dryrun
```

## 🐛 Troubleshooting

- `Cannot connect to the Docker daemon`: ensure Docker is running and you are not overriding `DOCKER_HOST`.
- `platform mismatch`: use `--container-architecture linux/amd64` when needed.

## ✅ Summary

| Command | Description |
|--------|-------------|
| `act` | Run all jobs locally |
| `act -j <job>` | Run a specific job |
| `act -W <workflow>` | Run a specific workflow |
| `act pull_request` | Simulate a PR event |
| `act --dryrun` | Preview actions without running |