From e079e305ddaf508d3105394df3fab1be92d6e38c Mon Sep 17 00:00:00 2001
From: Emmanuel Courreges <emmanuel.courreges@orange.com>
Date: Fri, 3 Sep 2021 10:12:29 +0000
Subject: [PATCH] feat: add Poetry extras support (PYTHON_POETRY_EXTRAS
 variable)

---
 README.md                      | 6 ++++++
 kicker.json                    | 7 ++++++-
 templates/gitlab-ci-python.yml | 6 +++---
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 9134cb3..709e4ad 100644
--- a/README.md
+++ b/README.md
@@ -40,6 +40,12 @@ Poetry support is disabled  if `PYTHON_POETRY_DISABLED` has a value.
 
 :warning: as stated in [Poetry documentation](https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control), _You should commit the `poetry.lock` file to your project repo so that all people working on the project are locked to the same versions of dependencies_.
 
+It uses the following variables:
+
+| Name                     | description                                                | default value     |
+| ------------------------ | ---------------------------------------------------------- | ----------------- |
+| `PYTHON_POETRY_EXTRAS`   | Poetry [extra sets of dependencies](https://python-poetry.org/docs/pyproject/#extras) to include, space separated     |  _none_           |
+
 ## Jobs
 
 ### Lint jobs
diff --git a/kicker.json b/kicker.json
index 8d23974..efffb3e 100644
--- a/kicker.json
+++ b/kicker.json
@@ -36,6 +36,11 @@
       "description": "Disable poetry support",
       "type": "boolean",
       "advanced": true
+    },
+    {
+      "name": "PYTHON_POETRY_EXTRAS",
+      "description": "Poetry [extra sets of dependencies](https://python-poetry.org/docs/pyproject/#extras) to include, space separated",
+      "advanced": true
     }
   ],
   "features": [
@@ -232,4 +237,4 @@
       ]
     }
   ]
-}
\ No newline at end of file
+}
diff --git a/templates/gitlab-ci-python.yml b/templates/gitlab-ci-python.yml
index 977317f..0555e8b 100644
--- a/templates/gitlab-ci-python.yml
+++ b/templates/gitlab-ci-python.yml
@@ -77,7 +77,7 @@ variables:
       fi
       log_info "--- Poetry detected: generating \\e[33;1m${TEST_REQUIREMENTS_FILE}\\e[0m from poetry.lock"      
       pip install poetry
-      poetry export --without-hashes --dev -f requirements.txt --output "${TEST_REQUIREMENTS_FILE}"
+      poetry export --without-hashes ${PYTHON_POETRY_EXTRAS:+--extras "$PYTHON_POETRY_EXTRAS"} --dev -f requirements.txt --output "${TEST_REQUIREMENTS_FILE}"
     fi
 
     if [[ -f "${TEST_REQUIREMENTS_FILE}" ]]; then
@@ -97,7 +97,7 @@ variables:
       fi
       log_info "--- Poetry detected: generating \\e[33;1m${REQUIREMENTS_FILE}\\e[0m from poetry.lock"      
       pip install poetry
-      poetry export --without-hashes -f requirements.txt --output "${REQUIREMENTS_FILE}"
+      poetry export --without-hashes ${PYTHON_POETRY_EXTRAS:+--extras "$PYTHON_POETRY_EXTRAS"} -f requirements.txt --output "${REQUIREMENTS_FILE}"
     fi
 
     if [[ -f "${REQUIREMENTS_FILE}" ]]; then
@@ -120,7 +120,7 @@ variables:
       fi
       log_info "--- Poetry detected: generating \\e[33;1m${TEST_REQUIREMENTS_FILE}\\e[0m from poetry.lock"     
       pip install poetry
-      poetry export --without-hashes -f requirements.txt --output "${DOCS_REQUIREMENTS_FILE}"
+      poetry export --without-hashes ${PYTHON_POETRY_EXTRAS:+--extras "$PYTHON_POETRY_EXTRAS"} -f requirements.txt --output "${DOCS_REQUIREMENTS_FILE}"
     fi
 
     if [[ -f "${DOCS_REQUIREMENTS_FILE}" ]]; then
-- 
GitLab