From 092715592864cfc457ba939e412e1f8cf948d1f3 Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Wed, 6 Mar 2024 19:57:13 +0100 Subject: [PATCH 1/4] ci(github): replaces pip with uv --- .github/workflows/builds.yml | 24 +++++++++++++++-------- .github/workflows/scripts.yml | 4 ++-- .github/workflows/style.yml | 37 ++++++++++------------------------- 3 files changed, 28 insertions(+), 37 deletions(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 51a215c..3ac51a9 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -33,12 +33,20 @@ jobs: POSTGRES_USER: postgres POSTGRES_PASSWORD: pg_pwd OLLAMA_MODEL: tinydolphin:1.1b-v2.8-q4_0 - run: docker-compose up -d --build - - name: Debug - run: sleep 20 && docker-compose logs backend + run: docker compose up -d --build - name: Docker sanity check - run: nc -vz localhost 8050 - - name: Debug - run: docker-compose logs - - name: Ping server - run: curl http://localhost:8050/docs + env: + SUPERADMIN_GH_PAT: ${{ secrets.SUPERADMIN_GH_PAT }} + SUPERADMIN_LOGIN: dummy_login + SUPERADMIN_PWD: dummy_pwd + GH_OAUTH_ID: ${{ secrets.GH_OAUTH_ID }} + GH_OAUTH_SECRET: ${{ secrets.GH_OAUTH_SECRET }} + POSTGRES_DB: postgres + POSTGRES_USER: postgres + POSTGRES_PASSWORD: pg_pwd + OLLAMA_MODEL: tinydolphin:1.1b-v2.8-q4_0 + run: | + sleep 20 && docker compose logs backend + nc -vz localhost 8050 + docker compose logs + curl http://localhost:8050/docs diff --git a/.github/workflows/scripts.yml b/.github/workflows/scripts.yml index 6465013..150b1a6 100644 --- a/.github/workflows/scripts.yml +++ b/.github/workflows/scripts.yml @@ -32,8 +32,8 @@ jobs: run: sleep 20 && nc -vz localhost 8050 - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install "requests>=2.31.0,<3.0.0" python-dotenv + python -m pip install --upgrade uv + uv pip install --system "requests>=2.31.0,<3.0.0" python-dotenv - name: Run integration test env: SUPERUSER_LOGIN: ${{ secrets.SUPERUSER_LOGIN }} diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index c68cca1..93b89cf 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -15,8 +15,7 @@ jobs: python: [3.9] steps: - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: x64 @@ -25,15 +24,10 @@ jobs: poetry-version: "1.7.1" - name: Resolve dependencies run: poetry export -f requirements.txt --without-hashes --only quality --output requirements.txt - - name: Cache python modules - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -r requirements.txt + python -m pip install --upgrade uv + uv pip install --system -r requirements.txt - name: Run ruff run: | ruff --version @@ -56,15 +50,10 @@ jobs: poetry-version: "1.7.1" - name: Resolve dependencies run: poetry export -f requirements.txt --without-hashes --with quality --output requirements.txt - - name: Cache python modules - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -r requirements.txt + python -m pip install --upgrade uv + uv pip install --system -r requirements.txt - name: Run mypy run: | mypy --version @@ -78,8 +67,7 @@ jobs: python: [3.9] steps: - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: x64 @@ -88,15 +76,10 @@ jobs: poetry-version: "1.7.1" - name: Resolve dependencies run: poetry export -f requirements.txt --without-hashes --only quality --output requirements.txt - - name: Cache python modules - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -r requirements.txt + python -m pip install --upgrade uv + uv pip install --system -r requirements.txt - name: Run ruff run: | ruff --version @@ -121,8 +104,8 @@ jobs: run: poetry export -f requirements.txt --without-hashes --only quality --output requirements.txt - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -r requirements.txt + python -m pip install --upgrade uv + uv pip install --system -r requirements.txt - name: Run pre-commit hooks run: | git checkout -b temp From 740c5a1f94cc37225c8906c644bcad3c8d0cce9d Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:03:56 +0100 Subject: [PATCH 2/4] chore(docker): add uv to dockerfile --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 564f33b..7694812 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,8 @@ COPY requirements.txt /app/requirements.txt # install dependencies RUN set -eux \ - && pip install -r /app/requirements.txt \ + && pip install --no-cache-dir uv \ + && uv pip install --no-cache --system -r /app/requirements.txt \ && rm -rf /root/.cache/pip # copy project From c8bda5202864ae025bef4b07ee0e8da921aafd08 Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:05:56 +0100 Subject: [PATCH 3/4] chore(docker): clean cache in docker --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7694812..9b8ff4a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ COPY requirements.txt /app/requirements.txt RUN set -eux \ && pip install --no-cache-dir uv \ && uv pip install --no-cache --system -r /app/requirements.txt \ - && rm -rf /root/.cache/pip + && rm -rf /root/.cache # copy project COPY src/app /app/app From 2a502ee45f5d867edd6e6e961c62821990b648b2 Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:24:47 +0100 Subject: [PATCH 4/4] chore(docker): optimize layers --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9b8ff4a..0cd516d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,6 @@ RUN set -eux \ && rm -rf /root/.cache # copy project -COPY src/app /app/app -COPY src/alembic /app/alembic COPY src/alembic.ini /app/alembic.ini +COPY src/alembic /app/alembic +COPY src/app /app/app