Skip to content

Commit

Permalink
Restructure development- and deployment-related configs and assets
Browse files Browse the repository at this point in the history
  • Loading branch information
bkis committed Jan 16, 2025
1 parent c6d497d commit 75af4ea
Show file tree
Hide file tree
Showing 23 changed files with 476 additions and 468 deletions.
116 changes: 58 additions & 58 deletions .github/workflows/server-tests.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
name: Run Server Tests

on:
push:
branches:
- development
- main
paths:
- "Tekst-API/tekst/**"
- "Tekst-API/tests/**"
- "Tekst-API/pyproject.toml"
- "Tekst-API/uv.lock"
- ".github/workflows/server-tests.yml"
pull_request:
branches:
- development
paths:
- "Tekst-API/tekst/**"
- "Tekst-API/tests/**"
- "Tekst-API/pyproject.toml"
- "Tekst-API/uv.lock"
- ".github/workflows/server-tests.yml"
workflow_dispatch:
push:
branches:
- development
- main
paths:
- "Tekst-API/tekst/**"
- "Tekst-API/tests/**"
- "Tekst-API/pyproject.toml"
- "Tekst-API/uv.lock"
- ".github/workflows/server-tests.yml"
pull_request:
branches:
- development
paths:
- "Tekst-API/tekst/**"
- "Tekst-API/tests/**"
- "Tekst-API/pyproject.toml"
- "Tekst-API/uv.lock"
- ".github/workflows/server-tests.yml"
workflow_dispatch:

jobs:
tests:
runs-on: ubuntu-latest
tests:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./Tekst-API
defaults:
run:
working-directory: ./Tekst-API

steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.5.7"
enable-cache: true
cache-dependency-glob: "./Tekst-API/uv.lock"
- name: Install Python
uses: actions/setup-python@v5
with:
python-version-file: "./Tekst-API/pyproject.toml"
- name: Install dependencies
run: uv sync
- name: Configure sysctl limits for ES
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Start test service stack
run: |
docker compose -f dev/compose.yml --profile test -p tekst-testing up --detach
printf "Waiting for MongoDB service"; while ! $(curl -f http://127.0.0.1:27017 > /dev/null 2>&1); do sleep 1; printf "."; done; printf "\n"
printf "Waiting for Elasticsearch service"; while ! $(curl -f http://127.0.0.1:9200 > /dev/null 2>&1); do sleep 1; printf "."; done; printf "\n"
- name: Cancel on setup error
if: failure()
uses: andymckay/[email protected]
- name: Run tests
if: always()
run: TEKST_DEV_MODE=true TEKST_CUSTOM_ENV_FILE=.env.test TEKST_EMAIL__SMTP_STARTTLS=false uv run coverage run -m pytest && uv run coverage lcov
- name: Coveralls
uses: coverallsapp/github-action@v2
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.5.7"
enable-cache: true
cache-dependency-glob: "./Tekst-API/uv.lock"
- name: Install Python
uses: actions/setup-python@v5
with:
python-version-file: "./Tekst-API/pyproject.toml"
- name: Install dependencies
run: uv sync
- name: Configure sysctl limits for ES
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Start test service stack
run: |
docker compose -f ../dev/compose.yml --profile test -p tekst-testing up --detach
printf "Waiting for MongoDB service"; while ! $(curl -f http://127.0.0.1:27017 > /dev/null 2>&1); do sleep 1; printf "."; done; printf "\n"
printf "Waiting for Elasticsearch service"; while ! $(curl -f http://127.0.0.1:9200 > /dev/null 2>&1); do sleep 1; printf "."; done; printf "\n"
- name: Cancel on setup error
if: failure()
uses: andymckay/[email protected]
- name: Run tests
if: always()
run: TEKST_DEV_MODE=true TEKST_CUSTOM_ENV_FILE=.env.test TEKST_EMAIL__SMTP_STARTTLS=false uv run coverage run -m pytest && uv run coverage lcov
- name: Coveralls
uses: coverallsapp/github-action@v2
16 changes: 0 additions & 16 deletions Taskfile.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Tekst-API/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ HEALTHCHECK \
RUN groupadd -g 1000 tekst && \
useradd -m -u 1000 -g tekst tekst

COPY ./deployment/gunicorn/gunicorn_conf.py ./
COPY ./deployment/entrypoint.sh /
COPY ./entrypoint.sh /

USER tekst

VOLUME /etc/gunicorn/
EXPOSE 8000

ENTRYPOINT ["/entrypoint.sh"]
12 changes: 6 additions & 6 deletions Tekst-API/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ For general information on Tekst, visit the [Tekst repository](https://github.co

## Development

1. Clone this repository via `git clone https://github.com/VedaWebProject/Tekst-API.git`
2. This project is configured to use [uv](https://docs.astral.sh/uv/) as its project management tool. You can install **uv**** from [here](https://docs.astral.sh/uv/getting-started/installation/).
3. Install the project and its dependencies (from the project directory): `uv sync`
4. You can now use
- `uv run fastapi dev tekst/app.py` to run the dev server
- [...and so on](https://docs.astral.sh/uv/reference/cli/)
1. Clone the parent repository via `git clone https://github.com/VedaWebProject/Tekst.git`
2. This project (in `Tekst-API/`) is configured to use [uv](https://docs.astral.sh/uv/) as its project management tool. You can install **uv**** from [here](https://docs.astral.sh/uv/getting-started/installation/).
3. Install the project and its dependencies (from the `Tekst-API/` project directory): `uv sync`
4. Run the development environment
- `uv run fastapi dev tekst/app.py` to run the dev server ([...and so on](https://docs.astral.sh/uv/reference/cli/))
- Local development also needs all the services running (MongoDB, Elasticsearch + some optional extras). The easiest way is to use the development compose stack in `../dev/compose.yml`. This also contains a Caddy (web server) that manages routing of requests to the client dev server and the API. See [this](Taskfile.yml) for reference.
5. The project has some *very* convenient tasks configured that can be run with [Task](https://taskfile.dev/) (a task runner). This is optional, but it helps *a lot*. You can install it form [here](https://taskfile.dev/installation/). Tasks can then be run via `task <taskname>`. You'll get a commented overview of the configured tasks if you run `task` without any arguments (or look [here](Taskfile.yml)).
Loading

0 comments on commit 75af4ea

Please sign in to comment.