aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2021-05-11 20:58:45 +0300
committerGravatar Hassan Abouelela <[email protected]>2021-05-11 21:30:44 +0300
commit1db39d0c3cd1c3f4731f4c494a892d15a07f00fe (patch)
tree30b5e8d445a25ee6d52cf5387a9adae1ad9ffbb9
parentAdds Python-Dotenv (diff)
Updates Usages Of Pipenv To Poetry
Updates the Dockerfile, pre-commit, CI, and documentation to reflect the new dependency manager. Dockerfile is also updated to 3.9. Signed-off-by: Hassan Abouelela <[email protected]>
-rw-r--r--.github/workflows/lint-test.yml19
-rw-r--r--.pre-commit-config.yaml4
-rw-r--r--Dockerfile20
-rw-r--r--tests/README.md10
4 files changed, 22 insertions, 31 deletions
diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml
index 95bed2e14..d96f324ec 100644
--- a/.github/workflows/lint-test.yml
+++ b/.github/workflows/lint-test.yml
@@ -23,15 +23,12 @@ jobs:
PIP_NO_CACHE_DIR: false
PIP_USER: 1
- # Hide the graphical elements from pipenv's output
- PIPENV_HIDE_EMOJIS: 1
- PIPENV_NOSPIN: 1
-
- # Make sure pipenv does not try reuse an environment it's running in
- PIPENV_IGNORE_VIRTUALENVS: 1
+ # Make sure package manager does not use virtualenv
+ POETRY_VIRTUALENVS_CREATE: false
# Specify explicit paths for python dependencies and the pre-commit
# environment so we know which directories to cache
+ POETRY_CACHE_DIR: ${{ github.workspace }}/.cache/py-user-base
PYTHONUSERBASE: ${{ github.workspace }}/.cache/py-user-base
PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit-cache
@@ -46,7 +43,7 @@ jobs:
id: python
uses: actions/setup-python@v2
with:
- python-version: '3.8'
+ python-version: '3.9'
# This step caches our Python dependencies. To make sure we
# only restore a cache when the dependencies, the python version,
@@ -61,14 +58,14 @@ jobs:
path: ${{ env.PYTHONUSERBASE }}
key: "python-0-${{ runner.os }}-${{ env.PYTHONUSERBASE }}-\
${{ steps.python.outputs.python-version }}-\
- ${{ hashFiles('./Pipfile', './Pipfile.lock') }}"
+ ${{ hashFiles('./pyproject.toml', './poetry.lock') }}"
# Install our dependencies if we did not restore a dependency cache
- - name: Install dependencies using pipenv
+ - name: Install dependencies using poetry
if: steps.python_cache.outputs.cache-hit != 'true'
run: |
- pip install pipenv
- pipenv install --dev --deploy --system
+ pip install poetry
+ poetry install
# This step caches our pre-commit environment. To make sure we
# do create a new environment when our pre-commit setup changes,
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 52500a282..131ba9453 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -17,8 +17,8 @@ repos:
hooks:
- id: flake8
name: Flake8
- description: This hook runs flake8 within our project's pipenv environment.
- entry: pipenv run flake8
+ description: This hook runs flake8 within our project's environment.
+ entry: poetry run task flake8
language: system
types: [python]
require_serial: true
diff --git a/Dockerfile b/Dockerfile
index 1a75e5669..91e9ce18e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,25 +1,19 @@
-FROM python:3.8-slim
+FROM python:3.9.5-slim
-# Set pip to have cleaner logs and no saved cache
+# Set pip to have no saved cache
ENV PIP_NO_CACHE_DIR=false \
- PIPENV_HIDE_EMOJIS=1 \
- PIPENV_IGNORE_VIRTUALENVS=1 \
- PIPENV_NOSPIN=1
+ POETRY_VIRTUALENVS_CREATE=false
-RUN apt-get -y update \
- && apt-get install -y \
- git \
- && rm -rf /var/lib/apt/lists/*
-# Install pipenv
-RUN pip install -U pipenv
+# Install poetry
+RUN pip install -U poetry
# Create the working directory
WORKDIR /bot
# Install project dependencies
-COPY Pipfile* ./
-RUN pipenv install --system --deploy
+COPY pyproject.toml poetry.lock ./
+RUN poetry install --prod
# Define Git SHA build argument
ARG git_sha="development"
diff --git a/tests/README.md b/tests/README.md
index 092324123..1a17c09bd 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -12,13 +12,13 @@ We are using the following modules and packages for our unit tests:
- [unittest.mock](https://docs.python.org/3/library/unittest.mock.html) (standard library)
- [coverage.py](https://coverage.readthedocs.io/en/stable/)
-To ensure the results you obtain on your personal machine are comparable to those generated in the Azure pipeline, please make sure to run your tests with the virtual environment defined by our [Pipfile](/Pipfile). To run your tests with `pipenv`, we've provided two "scripts" shortcuts:
+To ensure the results you obtain on your personal machine are comparable to those generated in the CI, please make sure to run your tests with the virtual environment defined by our [Poetry Project](/pyproject.toml). To run your tests with `poetry`, we've provided two "scripts" shortcuts:
-- `pipenv run test` will run `unittest` with `coverage.py`
-- `pipenv run test path/to/test.py` will run a specific test.
-- `pipenv run report` will generate a coverage report of the tests you've run with `pipenv run test`. If you append the `-m` flag to this command, the report will include the lines and branches not covered by tests in addition to the test coverage report.
+- `poetry run task test` will run `unittest` with `coverage.py`
+- `poetry run task test path/to/test.py` will run a specific test.
+- `poetry run task report` will generate a coverage report of the tests you've run with `poetry run task test`. If you append the `-m` flag to this command, the report will include the lines and branches not covered by tests in addition to the test coverage report.
-If you want a coverage report, make sure to run the tests with `pipenv run test` *first*.
+If you want a coverage report, make sure to run the tests with `poetry run task test` *first*.
## Writing tests