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

on:
push:
branches: [ main ]
pull_request:
types: [ opened, synchronize, reopened, closed ]

permissions:
contents: read

jobs:
test-gptzero:
name: Test GPTZero SDK
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
cd packages/gptzero
pip install -e ".[dev]"

- name: Run tests
run: |
cd packages/gptzero
pytest tests/ -v --cov=gptzero --cov-report=term-missing --cov-report=xml

- name: Upload coverage
uses: codecov/codecov-action@v4
with:
file: packages/gptzero/coverage.xml
flags: gptzero
name: gptzero-coverage
if: always()

test-api:
name: Test GPTZero API
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
cd packages/gptzero
pip install -e .
cd ../gptzero-api
pip install -e ".[dev]"

- name: Run linting
run: |
cd packages/gptzero-api
ruff check src/

test-sdk:
name: Test GPTZero SDK Client
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
cd packages/gptzero-sdk
pip install -e ".[dev]"

- name: Run linting
run: |
cd packages/gptzero-sdk
ruff check src/

lint:
name: Lint All Packages
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install ruff
run: pip install ruff

- name: Lint gptzero
run: |
cd packages/gptzero
ruff check src/ tests/

- name: Lint gptzero-api
run: |
cd packages/gptzero-api
ruff check src/

- name: Lint gptzero-sdk
run: |
cd packages/gptzero-sdk
ruff check src/

- name: Lint gptzero-service
run: |
cd packages/gptzero-service
ruff check src/
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ __pycache__
# distribution
build
dist
*.egg-info

# coverage
.coverage
htmlcov
coverage.xml

# environment
.env
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-added-large-files
- id: check-symlinks
Expand All @@ -14,14 +14,14 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.0
rev: v0.14.0
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.6.0
rev: 0.9.0
hooks:
- id: uv-lock
- id: uv-export
110 changes: 74 additions & 36 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,74 @@
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y \
python3 \
python3-pip \
python3-venv \
python3-dev \
build-essential \
curl \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*

RUN ln -s /usr/bin/python3 /usr/bin/python

WORKDIR /service

RUN python -m venv /service/.venv

ENV PATH="/service/.venv/bin:$PATH"

COPY requirements.txt .

RUN python -m pip install --upgrade pip
RUN python -m pip install --no-cache-dir -r requirements.txt

COPY src/ ./

RUN chmod +x authenticity/resources/c2patool/v0.16.1/Linux/c2patool

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

CMD ["/service/.venv/bin/streamlit", "run", "handler.py", "--server.port=8501", "--server.address=0.0.0.0"]
# Multi-stage Dockerfile for running both API and Service

FROM ubuntu:24.04 AS base

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y \
python3 \
python3-pip \
python3-venv \
python3-dev \
build-essential \
curl \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*

RUN ln -s /usr/bin/python3 /usr/bin/python

WORKDIR /app

# Create virtual environment
RUN python -m venv /app/.venv
ENV PATH="/app/.venv/bin:$PATH"

# Upgrade pip
RUN python -m pip install --upgrade pip

# Copy all packages
COPY packages/ /app/packages/

# Install gptzero (core SDK)
RUN cd /app/packages/gptzero && pip install --no-cache-dir -e .

# Install gptzero-api
RUN cd /app/packages/gptzero-api && pip install --no-cache-dir -e .

# Install gptzero-sdk
RUN cd /app/packages/gptzero-sdk && pip install --no-cache-dir -e .

# Install gptzero-service
RUN cd /app/packages/gptzero-service && pip install --no-cache-dir -e .

# Make c2patool executable
RUN chmod +x /app/packages/gptzero/resources/c2patool/v0.16.1/Linux/c2patool || true

# Expose ports
EXPOSE 8000 8501

# Health check for both services
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl --fail http://localhost:8000/health && curl --fail http://localhost:8501/_stcore/health

# Create startup script
RUN echo '#!/bin/bash\n\
set -e\n\
echo "Starting GPTZero API on port 8000..."\n\
uvicorn gptzero_api.api:app --host 0.0.0.0 --port 8000 &\n\
API_PID=$!\n\
echo "API started with PID $API_PID"\n\
\n\
echo "Waiting for API to be ready..."\n\
sleep 5\n\
\n\
echo "Starting GPTZero Service on port 8501..."\n\
export GPTZERO_API_URL=http://localhost:8000\n\
streamlit run /app/packages/gptzero-service/src/handler.py --server.port=8501 --server.address=0.0.0.0 &\n\
SERVICE_PID=$!\n\
echo "Service started with PID $SERVICE_PID"\n\
\n\
# Wait for both processes\n\
wait $API_PID $SERVICE_PID\n\
' > /app/start.sh && chmod +x /app/start.sh

CMD ["/app/start.sh"]
36 changes: 36 additions & 0 deletions Dockerfile.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y \
python3 \
python3-pip \
python3-venv \
python3-dev \
build-essential \
curl \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*

RUN ln -s /usr/bin/python3 /usr/bin/python

WORKDIR /service

RUN python -m venv /service/.venv

ENV PATH="/service/.venv/bin:$PATH"

COPY requirements.txt .

RUN python -m pip install --upgrade pip
RUN python -m pip install --no-cache-dir -r requirements.txt

COPY src/ ./

RUN chmod +x authenticity/resources/c2patool/v0.16.1/Linux/c2patool

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

CMD ["/service/.venv/bin/streamlit", "run", "handler.py", "--server.port=8501", "--server.address=0.0.0.0"]
Loading