Skip to content

Commit

Permalink
flake8 config to pyproject, removed pre-commit, prune Employee old fi…
Browse files Browse the repository at this point in the history
…elds, add DEFAULT_AUTO_FIELD setting
  • Loading branch information
RomanMazyrin committed Dec 26, 2023
1 parent d7919d0 commit c19fbff
Show file tree
Hide file tree
Showing 13 changed files with 218 additions and 376 deletions.
5 changes: 3 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
.coverage
.dockerignore
.env
.flake8
.git/
.github/
.gitignore
Expand All @@ -19,4 +18,6 @@ docker-compose*
frontend_components/
htmlcov/
poetry.toml
static/
static/
tmp/
.actrc
12 changes: 0 additions & 12 deletions .flake8

This file was deleted.

100 changes: 38 additions & 62 deletions .github/workflows/main-ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,91 +1,67 @@
name: CI/CD main workflow


on:
push:
branches:
- master


jobs:

build:
test-lint:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'poetry'

- run: python install_poetry.py
- run: poetry install
- run: make lint
- run: make test

build-push:
runs-on: ubuntu-latest
needs: [test-lint]
steps:

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-single-buildx
- name: Build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
file: ./Dockerfile
load: true
push: true
tags: |
ghcr.io/romanmazyrin/salaries_project:latest
salaries_project_temp
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
lint:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Lint
run: docker run salaries_project_temp poetry run black . && poetry run flake8 .
ghcr.io/${{ github.repository }}:latest
tests:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Tests
run: docker run salaries_project_temp poetry run pytest -s .
push:
runs-on: ubuntu-latest
needs: [lint, tests]
steps:
- name: Push
uses: docker/build-push-action@v2
with:
file: ./Dockerfile
push: true
tags: |
ghcr.io/romanmazyrin/salaries_project:latest


deploy:
runs-on: ubuntu-latest
needs: [push]
steps:
- name: executing remote ssh docker stack deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
docker pull ghcr.io/romanmazyrin/salaries_project:latest
docker stack deploy -c salary_service/docker-compose.yml --with-registry-auth django_salaries
# deploy:
# runs-on: ubuntu-latest
# needs: [push]
# steps:
# - name: executing remote ssh docker stack deploy
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.HOST }}
# username: ${{ secrets.USERNAME }}
# key: ${{ secrets.KEY }}
# script: |
# docker pull ghcr.io/romanmazyrin/salaries_project:latest
# docker stack deploy -c salary_service/docker-compose.yml --with-registry-auth django_salaries

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ bin/
include/
venv/
.venv/
static/
static/
tmp/
24 changes: 0 additions & 24 deletions .pre-commit-config.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.11-alpine

LABEL org.opencontainers.image.source="https://github.com/RomanMazyrin/django_playground"
LABEL org.opencontainers.image.source="https://github.com/RomanMazyrin/Salaries-project"

# Create separate user
RUN addgroup --system app && adduser -S -G app app
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ $ poetry install
$ poetry shell
```

## Activate pre-commit hooks

```
$ poetry run pre-commit install
```

## Set environment variables

<br>
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ version: "3.8"

services:
salaries:
image: salaries:n1
build:
context: ./
dockerfile: ./Dockerfile
Expand All @@ -13,7 +12,7 @@ services:
DATABASE_URL: postgres://postgres:123456@db:5432/postgres
RUN_MIGRATIONS: 1
CREATE_SUPERUSER: 1
DJANGO_SUPERUSER_PASSWORD: 123456
DJANGO_SUPERUSER_PASSWORD: '123456'
DJANGO_SUPERUSER_USERNAME: admin
DJANGO_SUPERUSER_EMAIL: [email protected]
AMOCRM_ENTITIES_ENDPOINT_AUTH_KEY: xxxxxxx
Expand All @@ -23,7 +22,7 @@ services:
- db

db:
image: postgres:13-alpine
image: postgres:16-alpine
environment:
POSTGRES_PASSWORD: '123456'
volumes:
Expand Down
Loading

0 comments on commit c19fbff

Please sign in to comment.