Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate: pip-tools → poetry #1976

Merged
merged 109 commits into from Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
fe4c1ae
update deps
hnthh Sep 15, 2023
8b74c9f
migrate to poetry pyproject deps
hnthh Sep 15, 2023
b49cbde
add forgotten deps, update makefile `deps` cmd
hnthh Sep 15, 2023
2fb142a
add flake rules to pyproject, fix makefile `lint` cmd
hnthh Sep 15, 2023
dcf8b1c
rewrite pyproject isort settings in alphabetical order
hnthh Sep 15, 2023
f7b972e
fix makefile `fmt` cmd
hnthh Sep 15, 2023
f1e0c7f
fix makefile `worker` cmd
hnthh Sep 15, 2023
a19f516
fix makefile `server` cmd, add `manage` var, refactor `lint` with it
hnthh Sep 15, 2023
00ef496
remove makefile `-deps` cmds
hnthh Sep 15, 2023
e8519e8
add/apply `poetry-src` makefile var
hnthh Sep 15, 2023
10eaa36
remove old pyproject
hnthh Sep 15, 2023
9f36b14
remove old requirements (txt) files
hnthh Sep 15, 2023
063589e
adapt readme
hnthh Sep 15, 2023
2a1e50d
rewrite ci.yml using poetry/ rebuild action [1st try]
hnthh Sep 15, 2023
e752f6c
change crossplatform ci `build` job
hnthh Sep 16, 2023
3879736
fix ci 71-line syntax error
hnthh Sep 16, 2023
64a649d
fix merge conflicts
hnthh Sep 16, 2023
121c526
change ci `needs:` jobname
hnthh Sep 16, 2023
4796461
adapt dockerfile
hnthh Sep 16, 2023
7239851
bring qemu, buildx back
hnthh Sep 16, 2023
40ad15f
change python version source in jobs
hnthh Sep 16, 2023
42d7c0c
change setup python ci step, fix dockerfile
hnthh Sep 16, 2023
42f3214
read python version from .env
hnthh Sep 16, 2023
d8ecd9a
add print env step
hnthh Sep 16, 2023
b47650d
add outputs to build action
hnthh Sep 16, 2023
5466c0c
add id to rebuild action
hnthh Sep 16, 2023
5bae5ad
fix syntax err in 21-line
hnthh Sep 16, 2023
55a59ae
bring envs copying back to build action
hnthh Sep 16, 2023
fbdd70f
test ci with hardcoded python version
hnthh Sep 16, 2023
ba26247
take python installation out of action file
hnthh Sep 16, 2023
fb79b68
add poetry caching
hnthh Sep 16, 2023
a8f2b08
add `activate poetry venv` step
hnthh Sep 16, 2023
1d4e5a6
disable pseudo-tty allocation
hnthh Sep 16, 2023
628b451
change poetry venv activate cmd
hnthh Sep 16, 2023
da23816
replace poetry venv activating to lint, test steps
hnthh Sep 16, 2023
d22401b
back to old capitalized step names
hnthh Sep 16, 2023
5820bad
fit crossplatform ci
hnthh Sep 16, 2023
39e97c3
fix checkouts
hnthh Sep 16, 2023
65053e2
remove packages
hnthh Sep 16, 2023
0667f47
rename makefile var
hnthh Oct 19, 2023
669f705
bump project version
hnthh Oct 19, 2023
de8966f
change author credentials
hnthh Oct 19, 2023
056a8b0
relocate `a12n` app/tests
hnthh Oct 19, 2023
edbec60
relocate `amocrm` app/tests
hnthh Oct 19, 2023
329c60c
relocate `banking` app/tests
hnthh Oct 19, 2023
a140262
relocate `chains` app/tests
hnthh Oct 19, 2023
26434c1
relocate `diplomas` app/tests
hnthh Oct 19, 2023
bd116a7
relocate `homework` app/tests
hnthh Oct 19, 2023
54c1036
relocate `magnets` app/tests
hnthh Oct 19, 2023
b5b7a5a
relocate `mailing` app/tests
hnthh Oct 19, 2023
c6ffb85
relocate `notion` app/tests
hnthh Oct 19, 2023
47fdf05
relocate `orders` app/tests, `stripebank` tests
hnthh Oct 19, 2023
64f051e
relocate `products` app/tests
hnthh Oct 19, 2023
557d894
relocate `stripebank` app
hnthh Oct 19, 2023
94513fa
relocate `studying` app/tests
hnthh Oct 19, 2023
ca25b19
relocate `tinkoff` app/tests
hnthh Oct 19, 2023
85dde3a
relocate `users` app/tests, fix `orders` tests
hnthh Oct 19, 2023
af91f8c
rename `app` → `core`
hnthh Oct 19, 2023
97e9586
alphabetize, structure installed apps
hnthh Oct 19, 2023
9566e9b
relocate all factories, fixtures
hnthh Oct 19, 2023
7bca2f2
alphabetize pytest options in pyproject
hnthh Oct 19, 2023
8147070
remove redundant pytest envs after poetry env plugin installation
hnthh Oct 19, 2023
afc0ca2
fix makefile cmds
hnthh Oct 19, 2023
a2c0feb
.env.env.ci
hnthh Oct 19, 2023
1c5ef4f
rewrite ci
hnthh Oct 19, 2023
ab7b36b
fix merge conflicts
hnthh Oct 19, 2023
cb4b30f
add ci poetry dotenv installation step
hnthh Oct 19, 2023
fbacde6
add poetry dotenv installation to dockerfile
hnthh Oct 19, 2023
06cca99
fix syntax error in dockerfile
hnthh Oct 19, 2023
4233c90
change environ path, remove plugin, check if everything ok except build
hnthh Oct 20, 2023
c4fe6e5
Update README.md
f213 Oct 20, 2023
81726ab
fix locales, environ strategy
hnthh Oct 21, 2023
192ba26
rename `copy envs` ci step
hnthh Oct 21, 2023
85cb306
rename `rebuild` ci step
hnthh Oct 21, 2023
900fec8
lowerize ci step names
hnthh Oct 21, 2023
2fa1e41
downgrade celery
hnthh Oct 21, 2023
f3fa35e
add get poetry version ci step
hnthh Oct 21, 2023
1d64d93
add upload/download python version steps, export poetry deps step to ci
hnthh Oct 21, 2023
fcdd1f1
save/download python/poetry version differently
hnthh Oct 21, 2023
5e4dc1b
add shell property
hnthh Oct 21, 2023
34d5f54
fix env name errors
hnthh Oct 21, 2023
ad8d682
add correct python version source to worker/scheduler build steps
hnthh Oct 21, 2023
e737a06
try to read poetry version outside crossplatform action
hnthh Oct 21, 2023
6712da6
remove redundant artifact create/download moves
hnthh Oct 21, 2023
e09c54d
rename get poetry version step
hnthh Oct 21, 2023
6b20c2b
change env path in docker compose file
hnthh Oct 23, 2023
e572ce8
install poetry via snok actions, add poetry version env
hnthh Oct 23, 2023
45e2e28
add ya dockerfile stage
hnthh Oct 23, 2023
2e77e38
remove `deps-export` cmd from makefile/ci
hnthh Oct 23, 2023
fb83641
add poetry version env to all build steps
hnthh Oct 23, 2023
822cb94
install ci deps if cache-hit not exists
hnthh Oct 25, 2023
d57f6eb
update dockerfile image
hnthh Oct 25, 2023
4e222ea
django-stubs upgrade
f213 Oct 27, 2023
3eac694
Renovate should know about poetry either
f213 Oct 27, 2023
afab008
Pinned python 3.11, cuz flake8-django fails on 3.12
f213 Oct 27, 2023
df88938
Added rope for vim guys like me
f213 Oct 27, 2023
ebd633f
Multistage build for uwsgi
f213 Oct 27, 2023
4934bf8
Docker: dropped build packages from the production image
f213 Oct 27, 2023
3a7dcfc
Got rid of env.poetry-version
f213 Oct 27, 2023
4025dbd
Empty commit to make sure caches are fine
f213 Oct 27, 2023
a6fca86
Caching mypy runs
f213 Oct 27, 2023
8ba81f2
Empty commit to make sure mypy cache is fine
f213 Oct 27, 2023
19bb11a
UWSGI version bump, reduced docker caches size
f213 Oct 27, 2023
9815a68
Large runner for tests
f213 Oct 28, 2023
f386c08
More test threads!
f213 Oct 28, 2023
67b9409
Another big runner
f213 Oct 28, 2023
3a7d692
Speed up poetry installation
f213 Oct 28, 2023
f8385c5
Better docker layer caching
f213 Oct 28, 2023
b3e913f
Tests: caching APT
f213 Oct 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .dockerignore
Expand Up @@ -2,3 +2,5 @@ venv/
storage/
.vscode/
.env
.git
tests/
42 changes: 42 additions & 0 deletions .github/actions/build/action.yml
@@ -0,0 +1,42 @@
name: build

runs:
using: composite

steps:
hnthh marked this conversation as resolved.
Show resolved Hide resolved
- name: load cached poetry installation
id: cached-poetry
uses: actions/cache@v3
with:
path: ~/.local
key: poetry-v1-${{ hashFiles('pyproject.toml') }}

- name: install poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.6.1

- name: install python
id: setup-python
uses: actions/setup-python@v4
with:
cache: 'poetry'
python-version-file: 'pyproject.toml'

- name: make sure poetry lockfile is up to date
run: poetry check --lock && echo Lockfile is ok, $(poetry --version)
shell: bash

- name: save python version to the env
run: echo "python-version=${{ steps.setup-python.outputs.python-version }}" >> $GITHUB_ENV
shell: bash

- name: install deps
hnthh marked this conversation as resolved.
Show resolved Hide resolved
if: steps.setup-python.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
shell: bash

- name: restore default environment
run: cp src/core/.env.ci src/core/.env
shell: bash
121 changes: 48 additions & 73 deletions .github/workflows/ci.yml
@@ -1,45 +1,35 @@
---
name: CI


on:
push:
branches:
- master
pull_request:

jobs:
build:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: checkout
uses: actions/checkout@v3
hnthh marked this conversation as resolved.
Show resolved Hide resolved

- uses: actions/setup-python@v4
id: setup-python
with:
python-version-file: '.python-version'
- name: build
uses: ./.github/actions/build

- uses: actions/cache@v3
id: cache-dependencies
- name: restore mypy cache
uses: actions/cache@v3
with:
path: |
venv
key: ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/*requirements.txt') }}

- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: |
python -m venv venv
. venv/bin/activate
pip install --upgrade pip pip-tools
pip-sync requirements.txt dev-requirements.txt

- name: Run the linter
run: |
. venv/bin/activate
cp src/app/.env.ci src/app/.env
make lint
path: .mypy_cache
key: mypy-cache-${{ github.ref_name }}
restore-keys: mypy-cache-master

- name: lint
run: make lint

test:
needs: build
runs-on: ubuntu-latest
needs: lint
runs-on: ubuntu-16x
services:
postgres:
image: postgres:13.9-alpine
Expand All @@ -60,32 +50,22 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
id: setup-python
with:
python-version-file: '.python-version'
- name: build
uses: ./.github/actions/build

- uses: actions/cache@v3
- name: install locale stuff
uses: awalsh128/cache-apt-pkgs-action@v1
with:
path: |
venv
key: ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/*requirements.txt') }}
packages: locales-all gettext
version: 1

- name: Install locale stuff
run: |
sudo apt-get update
sudo apt-get --no-install-recommends install -y locales-all gettext

- name: Run the tests
- name: test
env:
DATABASE_URL: postgres://postgres:secret@localhost:5432/postgres
REDISCLOUD_URL: redis://localhost:6379/5
run: |
. venv/bin/activate
cp src/app/.env.ci src/app/.env
make test
run: make test -e SIMULTANEOUS_TEST_JOBS=16

- name: Upload code coverage to codeclimate
- name: upload code coverage to codeclimate
uses: paambaati/codeclimate-action@v3.2.0
env:
CC_TEST_REPORTER_ID: dd4cac59d43b52ee4c29cfed9d5162098a49ff65d9e72003abc1fa65cd608f1d
Expand All @@ -97,38 +77,33 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: checkout
uses: actions/checkout@v3

- uses: actions/setup-python@v4
id: setup-python
with:
python-version-file: '.python-version'
- name: build
uses: ./.github/actions/build

- name: Set up QEMU
- name: set up qemu
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
- name: set up buildx
uses: docker/setup-buildx-action@v2

- name: Store default envfironment file to be runnable at the developer machine
run: cp src/app/.env.ci src/app/.env

- name: Generate image identifier
- name: generate image identifier
id: image
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository_owner }}

- name: Login to GitHub Container Registry
- name: login to ghcr
uses: docker/login-action@v2
if: ${{ github.ref == 'refs/heads/master' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build web image
- name: build web image
uses: docker/build-push-action@v3
with:
context: .
Expand All @@ -139,12 +114,12 @@ jobs:
ghcr.io/${{ steps.image.outputs.lowercase }}/monolith-web:${{ github.sha }}

build-args: |
PYTHON_VERSION=${{ steps.setup-python.outputs.python-version }}
PYTHON_VERSION=${{ env.python-version }}
RELEASE=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build worker image
- name: build worker image
uses: docker/build-push-action@v3
with:
context: .
Expand All @@ -154,12 +129,12 @@ jobs:
ghcr.io/${{ steps.image.outputs.lowercase }}/monolith-worker:latest
ghcr.io/${{ steps.image.outputs.lowercase }}/monolith-worker:${{ github.sha }}
build-args: |
PYTHON_VERSION=${{ steps.setup-python.outputs.python-version }}
PYTHON_VERSION=${{ env.python-version }}
RELEASE=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build scheduler image
- name: build scheduler image
uses: docker/build-push-action@v3
with:
context: .
Expand All @@ -169,7 +144,7 @@ jobs:
ghcr.io/${{ steps.image.outputs.lowercase }}/monolith-scheduler:latest
ghcr.io/${{ steps.image.outputs.lowercase }}/monolith-scheduler:${{ github.sha }}
build-args: |
PYTHON_VERSION=${{ steps.setup-python.outputs.python-version }}
PYTHON_VERSION=${{ env.python-version }}
RELEASE=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
Expand All @@ -179,10 +154,10 @@ jobs:
if: github.ref == 'refs/heads/master' && github.repository_owner == 'tough-dev-school'
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: checkout
uses: actions/checkout@v3

- name: Draft Sentry release
- name: draft sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
Expand All @@ -192,37 +167,37 @@ jobs:
environment: production
finalize: false

- name: Read image identifiers
- name: read image identifiers
id: image
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository_owner }}

- name: Update backend image
- name: update backend image
uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ secrets.DEPLOY_HOST }}
username: circle
key: ${{ secrets.DEPLOY_KEY }}
script: docker service update app_backend --image ghcr.io/${{ steps.image.outputs.lowercase }}/monolith-web:${{ github.sha }} --with-registry-auth

- name: Update celery worker image
- name: update celery worker image
uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ secrets.DEPLOY_HOST }}
username: circle
key: ${{ secrets.DEPLOY_KEY }}
script: docker service update app_worker --image ghcr.io/${{ steps.image.outputs.lowercase }}/monolith-worker:${{ github.sha }} --with-registry-auth

- name: Update celery amocrm worker image
- name: update celery amocrm worker image
uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ secrets.DEPLOY_HOST }}
username: circle
key: ${{ secrets.DEPLOY_KEY }}
script: docker service update app_amocrm-worker --image ghcr.io/${{ steps.image.outputs.lowercase }}/monolith-worker:${{ github.sha }} --with-registry-auth

- name: Update celery scheduler image
- name: update celery scheduler image
uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ secrets.DEPLOY_HOST }}
Expand All @@ -231,7 +206,7 @@ jobs:
script: |
docker service update app_scheduler --detach --image ghcr.io/${{ steps.image.outputs.lowercase }}/monolith-scheduler:${{ github.sha }} --with-registry-auth

- name: Finalize Sentry release
- name: finalize sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
Expand Down