Skip to content

Commit

Permalink
Merge pull request #1 from ruzniaievdm/ruzniaievdm/feat/gh-actions
Browse files Browse the repository at this point in the history
feat: add github actions
  • Loading branch information
ruzniaievdm authored Jul 3, 2024
2 parents 0786bfd + e1252fc commit 4062015
Show file tree
Hide file tree
Showing 8 changed files with 4,699 additions and 584 deletions.
44 changes: 20 additions & 24 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,29 @@
name: Python application

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read
branches: [main]

jobs:
build:

runs-on: ubuntu-latest
runs-on: self-hosted

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies with poetry
run: |
python -m pip install --upgrade pip
pip install poetry==1.7.0
poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root --only test
- name: Lint with poetry
run: |
make app-lint
- name: Test with pytest
run: |
make app-test
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies with poetry
run: |
python -m pip install --upgrade pip
pip install poetry==1.7.0
poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root --only test
- name: Lint with Ruff
run: |
pip install ruff
ruff --output-format=github .
continue-on-error: true
- name: Test with pytest
run: |
app-test
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ RUN poetry config virtualenvs.create false && poetry install --no-interaction --
FROM app-builder as app-dev
CMD python manage.py runserver 0.0.0.0:8000

# App build test
FROM app-builder as app-test

RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root --only test


# Web build
FROM node:17-alpine AS web-builder

Expand Down
13 changes: 5 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ up:

load-fixtures:
docker compose run --rm app bash -c "./manage.py loaddata backend/fixtures/users.json \
backend/fixtures/conversations.json \
backend/fixtures/messages.json"
backend/fixtures/conversations.json \
backend/fixtures/messages.json"

restart:
docker-compose restart
Expand Down Expand Up @@ -48,7 +48,7 @@ migrate:
docker compose run --rm app python manage.py migrate

app-shell:
docker-compose exec -it app bash
docker-compose exec app bash

web-shell:
docker compose run --rm web sh
Expand All @@ -66,13 +66,10 @@ db-console:
docker-compose exec -it db psql -U postgres postgres

app-test:
docker-compose run --rm app-test bash -c "poetry run pytest"

app-lint:
docker-compose run --rm app-test bash -c "poetry run pylint backend"
docker-compose run --rm app-test bash -c "poetry run pytest && poetry run pylint backend"

web-test:
docker-compose run --rm web-test sh -c "npm run test"
docker-compose run --rm web-test sh -c "CI=true npm run lint && npm run test -- --coverage"

test: \
web-test \
Expand Down
324 changes: 161 additions & 163 deletions backend/poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ channels = "^3.0.4"
redis = "^5.0.1"
# django-eventstream = "^4.5.1"
black = "^24.2.0"
pytz = "^2024.1"

[tool.poetry.group.test]
optional = true
Expand Down
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,27 @@ services:
volumes:
- pgdata:/var/lib/postgresql/data

app-test:
image: app-test
container_name: chat-app-test
build:
context: .
target: app-test
volumes:
- ./backend:/app/backend
depends_on:
- db

web-test:
image: web-test
container_name: chat-web-test
build:
context: .
target: web-dev
volumes:
- ./frontend:/app/frontend
- node_modules:/app/frontend/node_modules

volumes:
pgdata:
redis_data:
Expand Down
Loading

0 comments on commit 4062015

Please sign in to comment.