aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-09-18 02:01:15 +0400
committerGravatar GitHub <[email protected]>2022-09-17 22:01:15 +0000
commit8f2159f375ca024ae21c0a510009278adc980c5e (patch)
tree1c2347aebae89b5cce385428083efbfa4af34159
parentMerge pull request #1094 from python-discord/message-content-intent (diff)
Fix Poetry 1.2 Support (#1099)
-rw-r--r--.github/workflows/lint.yaml63
-rw-r--r--Dockerfile20
2 files changed, 11 insertions, 72 deletions
diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml
index 2cbfc2f5..8bfe25fa 100644
--- a/.github/workflows/lint.yaml
+++ b/.github/workflows/lint.yaml
@@ -26,56 +26,16 @@ jobs:
Mozilla Public License 2.0 (MPL 2.0);
Public Domain;
Python Software Foundation License
- # See https://github.com/pre-commit/pre-commit/issues/2178#issuecomment-1002163763
- # for why we set this.
- SETUPTOOLS_USE_DISTUTILS: stdlib
-
-# Configure pip to cache dependencies and do a user install
- PIP_NO_CACHE_DIR: false
- PIP_USER: 1
-
- # Disable Poetry virtualenv creation
- POETRY_VIRTUALENVS_CREATE: false
-
- # Specify explicit paths for python dependencies and the pre-commit
- # environment so we know which directories to cache
- PYTHONUSERBASE: ${{ github.workspace }}/.cache/py-user-base
- PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit-cache
steps:
- - name: Add custom PYTHONUSERBASE to PATH
- run: echo '${{ env.PYTHONUSERBASE }}/bin/' >> $GITHUB_PATH
-
- name: Checkout repository
uses: actions/checkout@v2
- - name: Setup python
- id: python
- uses: actions/setup-python@v2
- with:
- python-version: '3.9'
-
- # This step caches our Python dependencies. To make sure we
- # only restore a cache when the dependencies, the python version,
- # the runner operating system, and the dependency location haven't
- # changed, we create a cache key that is a composite of those states.
- #
- # Only when the context is exactly the same, we will restore the cache.
- - name: Python Dependency Caching
- uses: actions/cache@v2
- id: python_cache
+ - name: Install Python Dependencies
+ uses: HassanAbouelela/actions/setup-python@setup-python_v1.3.1
with:
- path: ${{ env.PYTHONUSERBASE }}
- key: "python-0-${{ runner.os }}-${{ env.PYTHONUSERBASE }}-\
- ${{ steps.python.outputs.python-version }}-\
- ${{ hashFiles('./pyproject.toml', './poetry.lock') }}"
-
- # Install our dependencies if we did not restore a dependency cache
- - name: Install dependencies using poetry
- if: steps.python_cache.outputs.cache-hit != 'true'
- run: |
- pip install poetry
- poetry install --no-interaction --no-ansi
+ dev: true
+ python_version: "3.9"
# Check all of our dev dependencies are compatible with the MIT license.
# If you added a new dependencies that is being rejected,
@@ -94,22 +54,11 @@ jobs:
USE_FAKEREDIS: true
IN_CI: true
- # This step caches our pre-commit environment. To make sure we
- # do create a new environment when our pre-commit setup changes,
- # we create a cache key based on relevant factors.
- - name: Pre-commit Environment Caching
- uses: actions/cache@v2
- with:
- path: ${{ env.PRE_COMMIT_HOME }}
- key: "precommit-0-${{ runner.os }}-${{ env.PRE_COMMIT_HOME }}-\
- ${{ steps.python.outputs.python-version }}-\
- ${{ hashFiles('./.pre-commit-config.yaml') }}"
# We will not run `flake8` here, as we will use a separate flake8
- # action. As pre-commit does not support user installs, we set
- # PIP_USER=0 to not do a user install.
+ # action.
- name: Run pre-commit hooks
- run: export PIP_USER=0; SKIP=flake8 pre-commit run --all-files
+ run: SKIP=flake8 pre-commit run --all-files
# Run flake8 and have it format the linting errors in the format of
# the GitHub Workflow command to register error annotations. This
diff --git a/Dockerfile b/Dockerfile
index 44ef0574..10e8bbd4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,20 +1,9 @@
-FROM --platform=linux/amd64 python:3.9-slim
-
-# Set pip to have cleaner logs and no saved cache
-ENV PIP_NO_CACHE_DIR=false \
- POETRY_VIRTUALENVS_CREATE=false
-
-# Install Poetry
-RUN pip install --upgrade poetry
+FROM --platform=linux/amd64 ghcr.io/chrislovering/python-poetry-base:3.9-slim
+# Install dependencies
WORKDIR /bot
-
-# Copy dependencies and lockfile
-COPY pyproject.toml poetry.lock /bot/
-
-# Install dependencies and lockfile, excluding development
-# dependencies,
-RUN poetry install --no-dev --no-interaction --no-ansi
+COPY pyproject.toml poetry.lock ./
+RUN poetry install --without dev
# Set SHA build argument
ARG git_sha="development"
@@ -24,4 +13,5 @@ ENV GIT_SHA=$git_sha
COPY . .
# Start the bot
+ENTRYPOINT ["poetry", "run"]
CMD ["python", "-m", "bot"]