Skip to content

Commit

Permalink
Added poetry (#158)
Browse files Browse the repository at this point in the history
Added poetry, adjusted the docs as needed.
  • Loading branch information
TreyWW authored Jan 30, 2024
1 parent 8a03660 commit 5d9b8df
Show file tree
Hide file tree
Showing 13 changed files with 1,463 additions and 129 deletions.
41 changes: 28 additions & 13 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Backend Tests

on: [push, pull_request]
on: [ push, pull_request ]

env:
DOCKER_COMPOSE_PATH: ./infrastructure/backend/docker-compose.ci.yml
Expand All @@ -9,28 +8,44 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

#----------------------------------------------
# install and configure poetry
#----------------------------------------------

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: false
virtualenvs-in-project: false
installer-parallel: true

#----------------------------------------------
# install docker compose
# setup + configure docker compose
#----------------------------------------------

- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Set up environment variables
run: cp .env.github_actions .env

- name: Copy docker compose file
run: cp $DOCKER_COMPOSE_PATH ./docker-compose.yml
run: cp $DOCKER_COMPOSE_PATH ./docker-compose.yml

- name: Install Python dependencies
uses: py-actions/py-dependency-install@v4
with:
path: requirements.gh_actions.txt
#----------------------------------------------
# run docker compose & tests
#----------------------------------------------

- name: Build and run docker-compose.ci.yml
run: docker-compose up -d
run: docker compose up -d --wait --wait-timeout 30

- name: Run the test scripts
run: |
docker-compose exec -T myfinances_django ./infrastructure/backend/scripts/tests/views.sh
docker compose exec -T myfinances_django ./infrastructure/backend/scripts/tests/views.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ user-friendly platform to streamline these tasks.
- Docker Compose
- HTMX
- HyperScript
- Additional requirements can be found in the `requirements.txt` file.
- Additional requirements can be found in the `pyproject.toml` file (or by using `poetry show`).

### Installation

Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ user-friendly platform to streamline these tasks.
- Docker Compose
- HTMX
- HyperScript
- Additional requirements can be found in the `requirements.txt` file.
- Additional requirements can be found in the `pyproject.toml` file (or by using `poetry show`).

### Installation

Expand Down
5 changes: 3 additions & 2 deletions docs/getting-setup/other-environments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

1. [Fork our repo (click to view guide)](getting-setup/other-environments/fork)
2. [Setup environment variables (click to view guide)](getting-setup/other-environments/env-variables)
3. [Setup dependencies (click to view guide)](getting-setup/other-environments/dependencies)
3. [Setup dependencies (click to view guide)](https://python-poetry.org/docs/#installing-manually)

[Install Poetry](https://python-poetry.org/docs/#installing-manually)
```bash
pip install -r requirements.txt
poetry install
```

4. [Setup our frontend (click to view guide)](getting-setup/other-environments/frontend)
Expand Down
5 changes: 3 additions & 2 deletions docs/getting-setup/other-environments/django.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

!> Make sure you have followed all of our previous steps in this section before doing this

1. Install our dependencies using `pip`
1. Install our dependencies
using `python poetry` [click here for installation guide](https://python-poetry.org/docs/#installing-manually)

```bash
pip install -r requirements.txt
poetry install
```

2. Setup your database [(click to view our guide)](getting-setup/databases/)
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-setup/pycharm/django.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ and run server. For more details, view the page for your environment below

<br>

!> Before continuing, please install all requirements.txt. Go to `requirements.txt`, right click, press "`Install All Packages`"
!> Before continuing, please install all of our dependencies via `poetry install`"

9. To refresh the cache, go back to settings, project, and interpreter and install "Django" if not already there

Expand Down
20 changes: 9 additions & 11 deletions infrastructure/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Dockerfile
FROM python:3.12-alpine

# Set the working directory
RUN pip install poetry==1.7.1

ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR=/tmp/poetry_cache

WORKDIR /MyFinances

COPY . .
Expand All @@ -12,20 +17,13 @@ RUN apk --no-cache --update add \
musl-dev \
gcc \
mariadb-dev \
git \
libffi-dev

RUN pip install --upgrade pip \
&& pip install mysql mariadb mysqlclient -r requirements.txt
libffi-dev

CMD ["git","--version"]
RUN poetry install --without dev,mysql --no-root && rm -rf $POETRY_CACHE_DIR

# Set the entrypoint
#COPY ../scripts /infrastructure/scripts/
RUN chmod +x infrastructure/backend/scripts/*
RUN chmod +x infrastructure/backend/scripts/tests/*
ENTRYPOINT ["sh", "infrastructure/backend/scripts/entrypoint.sh"]

# Expose ports
EXPOSE 10012
EXPOSE 9012
35 changes: 6 additions & 29 deletions infrastructure/backend/docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,10 @@ services:
- '9012:9012'
volumes:
- .:/myfinances
# - myfinances_static_volume:/mnt/static/
# networks:
# - myfinances_network
environment:
TEST: "True"
SECRET_KEY: mysecretkey
URL: 127.0.0.1
PROXY_IP: localhost
BRANCH: debug
DEBUG: "True"

# nginx:
# restart: always
# image: nginx:latest
# ports:
# - '10012:10012'
# depends_on:
# - myfinances_django
# networks:
# - myfinances_network
# volumes:
# - /var/run/docker.sock:/tmp/docker.sock:ro
# - myfinances_static_volume:/srv/http/static/
# - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
# command: /bin/bash -c "nginx -g 'daemon off;'"
#volumes:
# myfinances_static_volume:
#networks:
# myfinances_network:
# driver: bridge
SECRET_KEY: "some!random!secret!key!use!online!generator!to!get"
URL: "127.0.0.1"
PROXY_IP: "localhost"
BRANCH: "debug"
DEBUG: "true"
DATABASE_TYPE: "sqlite3"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{

"name": "myfinances",
"version": "1.0.0",
"version": "0.1.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
Loading

0 comments on commit 5d9b8df

Please sign in to comment.