-
Notifications
You must be signed in to change notification settings - Fork 13
chore: migrate to pyproject.toml #251
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
Open
JaeAeich
wants to merge
5
commits into
dev
Choose a base branch
from
poetry
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [flake8] | ||
| exclude = .git,.eggs,build,.venv,venv,env | ||
| max-line-length = 79 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,21 +36,21 @@ jobs: | |
| python-version: ${{ matrix.py-version-img[0] }} | ||
| - name: Install requirements | ||
| run: | | ||
| pip install -e .[dev] | ||
| pip install setuptools | ||
| pip install poetry | ||
| poetry install --with=code_quality,docs,test,types | ||
| - name: Lint with flake8 | ||
| run: flake8 | ||
| run: poetry run flake8 | ||
| - name: Run mypy | ||
| run: mypy foca | ||
| run: poetry run mypy foca | ||
| - name: Start MongoDB | ||
| uses: supercharge/[email protected] | ||
| with: | ||
| mongodb-version: ${{ matrix.mongodb-version }} | ||
| mongodb-port: ${{ matrix.mongodb-port }} | ||
| - name: Calculate unit test coverage | ||
| run: | | ||
| coverage run --source foca -m pytest -W ignore::DeprecationWarning | ||
| coverage xml | ||
| poetry run coverage run --source foca -m pytest -W ignore::DeprecationWarning | ||
| poetry run coverage xml | ||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
|
|
@@ -75,7 +75,7 @@ jobs: | |
| docker-compose up --build -d | ||
| cd ../.. | ||
| sleep 10 | ||
| pytest ./tests/integration_tests.py | ||
| poetry run pytest ./tests/integration_tests.py | ||
|
|
||
| Docker: | ||
| runs-on: ubuntu-latest | ||
|
|
||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # NOTE: This Makefile assumes that dependencies are installed and, if a virtual | ||
| # environment is used, it is activated. | ||
|
|
||
| ## Variables ################################################################## | ||
| # NOTE: Define any variables here if needed in the future | ||
|
|
||
| ## Documentation ############################################################## | ||
| # NOTE: Keep all the targets in alphabetical order for better readability. | ||
|
|
||
| default: help | ||
|
|
||
| .PHONY: help | ||
| help: | ||
| @echo "\nUsage: make [target] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" | ||
| @echo "Available targets:\n" | ||
|
|
||
| @echo "Code Quality ------------------------------------------------------------------" | ||
| @echo " \033[1m\033[35mformat-lint\033[0m \033[37m(fl)\033[0m: \033[36mRun linter, formatter, spellcheck.\033[0m" | ||
| @echo " \033[1m\033[35mtype-check\033[0m \033[37m(tc)\033[0m: \033[36mPerform type checking.\033[0m\n" | ||
|
|
||
| @echo "Environment Management --------------------------------------------------------" | ||
| @echo " \033[1m\033[35mclean-venv\033[0m \033[37m(cv)\033[0m: \033[36mRemove virtual environment.\033[0m" | ||
| @echo " \033[1m\033[35minstall\033[0m \033[37m(i)\033[0m: \033[36mInstall app and dependencies.\033[0m" | ||
| @echo " \033[1m\033[35mvenv\033[0m \033[37m(v)\033[0m: \033[36mCreate virtual environment.\033[0m\n" | ||
|
|
||
| @echo "Testing -----------------------------------------------------------------------" | ||
| @echo " \033[1m\033[35mtest\033[0m \033[37m(t)\033[0m: \033[36mRun all tests.\033[0m\n" | ||
|
|
||
| .PHONY: clean-venv cv | ||
| clean-venv: | ||
| @echo "\nRemoving the virtual environment ++++++++++++++++++++++++++++++++++++++++++++++\n" | ||
| @rm -rf .venv | ||
|
|
||
| cv: clean-venv | ||
|
|
||
| .PHONY: format-lint fl | ||
| format-lint: | ||
| @echo "\nRunning linter and formatter using ruff and typos +++++++++++++++++++++++++++++\n" | ||
| @poetry run flake8 && poetry run ruff check --fix | ||
| @typos . | ||
|
|
||
| fl: format-lint | ||
|
|
||
| .PHONY: install i | ||
| install: | ||
| @echo "\nInstalling this package its dependencies +++++++++++++++++++++++++++++++++\n" | ||
| @poetry install --with=code_quality,doc`s,test,types | ||
|
|
||
| i: install | ||
|
|
||
| .PHONY: test t | ||
| test: | ||
| @echo "\nRunning tests using pytest ++++++++++++++++++++++++++++++++++++++++++++++++++++\n" | ||
| @poetry run pytest tests/ | ||
|
|
||
| t: test | ||
|
|
||
| .PHONY: type-check tc | ||
| type-check: | ||
| @echo "\nPerforming type checking with mypy ++++++++++++++++++++++++++++++++++++++++++++\n" | ||
| @poetry run mypy foca | ||
|
|
||
| tc: type-check | ||
|
|
||
| .PHONY: venv v | ||
| venv: | ||
| @echo "\nCreating a virtual environment ++++++++++++++++++++++++++++++++++++++++++++++++\n" | ||
| @python -m venv .venv | ||
| @echo "\nSummary +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" | ||
| @echo "Virtual environment created successfully." | ||
| @echo "To activate the environment for this shell session, run:" | ||
| @echo "source .venv/bin/activate" | ||
|
|
||
| v: venv | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,50 @@ | ||
| ################################################### | ||
| # Stage 1: Get poetry # | ||
| ################################################### | ||
| ARG PY_IMAGE=3.12-slim-bookworm | ||
| FROM python:$PY_IMAGE as base | ||
|
|
||
| # Metadata | ||
| LABEL software="FOCA" | ||
| LABEL software.description="Kickstart OpenAPI-based microservice development with Flask & Connexion" | ||
| LABEL software.website="https://github.com/elixir-cloud-aai/foca" | ||
| LABEL software.license="https://spdx.org/licenses/Apache-2.0" | ||
| LABEL maintainer="[email protected]" | ||
| LABEL maintainer.organisation="ELIXIR Cloud & AAI" | ||
|
|
||
| # Build image | ||
| FROM base as builder | ||
|
|
||
| # Install general dependencies | ||
| ENV PACKAGES openssl git build-essential python3-dev curl jq | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends ${PACKAGES} && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
| FROM python:$PY_IMAGE AS poetry | ||
|
|
||
| ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
| PYTHONUNBUFFERED=1 | ||
|
|
||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| curl \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN curl -sSL https://install.python-poetry.org | python3 - && \ | ||
| ln -s /root/.local/bin/poetry /usr/local/bin/poetry | ||
|
|
||
| ################################################### | ||
| # Stage 2: Get deps # | ||
| ################################################### | ||
| FROM poetry AS builder | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Install Python dependencies | ||
| COPY requirements.txt ./ | ||
| RUN pip install \ | ||
| --no-warn-script-location \ | ||
| --prefix="/install" \ | ||
| -r requirements.txt | ||
| COPY . /app/ | ||
|
|
||
| # Install FOCA | ||
| COPY setup.py README.md ./ | ||
| COPY foca/ ./foca/ | ||
| RUN pip install --upgrade pkginfo && \ | ||
| pip install . \ | ||
| --no-warn-script-location \ | ||
| --prefix="/install" | ||
| RUN poetry config virtualenvs.create false \ | ||
| && poetry build | ||
|
|
||
| # Final image | ||
| FROM base | ||
| # ################################################### | ||
| # # Stage 3: Add Metadata and install wheel # | ||
| # ################################################### | ||
| FROM python:$PY_IMAGE | ||
|
|
||
| COPY --from=builder /app/dist /app/dist | ||
|
|
||
| RUN pip install /app/dist/*.whl | ||
|
|
||
| LABEL org.opencontainers.image.title="FOCA" | ||
| LABEL org.opencontainers.image.description="Kickstart OpenAPI-based microservice development with Flask & Connexion" | ||
| LABEL org.opencontainers.image.source="https://github.com/elixir-cloud-aai/foca" | ||
| LABEL org.opencontainers.image.licenses="Apache-2.0" | ||
| LABEL org.opencontainers.image.authors="[email protected]" | ||
| LABEL org.opencontainers.image.vendor="ELIXIR Cloud & AAI" | ||
|
|
||
| # Python UserID workaround for OpenShift/K8S | ||
| ENV LOGNAME=ipython | ||
| ENV USER=ipython | ||
| ENV HOME=/tmp/user | ||
|
|
||
| # Install general dependencies | ||
| ENV PACKAGES openssl git build-essential python3-dev curl jq | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends ${PACKAGES} && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Copy Python packages | ||
| COPY --from=builder /install /usr/local | ||
| WORKDIR /app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.