-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add makefile with common commands #23
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,8 +95,10 @@ lint: | |
image: $PRECOMMIT_IMAGE:latest | ||
stage: lint | ||
interruptible: true | ||
before_script: | ||
- make | ||
Comment on lines
+98
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as we use $PRECOMMIT_IMAGE, it is not necessary to setup venv before |
||
script: | ||
- pre-commit run --all-files | ||
- make lint | ||
rules: | ||
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' | ||
changes: | ||
|
@@ -112,8 +114,10 @@ lint-precommit-changed: | |
image: $PRECOMMIT_IMAGE:dev-$CI_COMMIT_SHA | ||
stage: lint | ||
interruptible: true | ||
before_script: | ||
- make | ||
script: | ||
- pre-commit run --all-files | ||
- make lint | ||
rules: | ||
- if: $CI_PIPELINE_SOURCE == "merge_request_event" | ||
changes: | ||
|
@@ -145,21 +149,19 @@ tests: | |
stage: tests | ||
interruptible: true | ||
before_script: | ||
- . setup_dev_env.sh | ||
- pip install build twine bump2version | ||
- make | ||
- pip install build twine bump2version #??? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it may be removed indeed |
||
script: | ||
# fused check license here as it would take more time to do it in different place. | ||
- ./check_licenses.sh | ||
- make lic-check | ||
# test package building | ||
- echo ${CI_PIPELINE_IID} >> src/{{ cookiecutter.__package_name }}/VERSION | ||
- python -m build | ||
# generate pip freeze | ||
- pip freeze > requirements-freeze.txt | ||
- make freeze | ||
- cat requirements-freeze.txt | ||
# run with coverage to not execute tests twice | ||
- coverage run -m pytest -v -p no:warnings --junitxml=report.xml tests/ | ||
- coverage report | ||
- coverage xml | ||
- make coverage | ||
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/' | ||
artifacts: | ||
when: always | ||
|
@@ -244,9 +246,9 @@ pages: | |
stage: pages | ||
interruptible: true | ||
before_script: | ||
- . setup_dev_env.sh | ||
- make | ||
script: | ||
- ./build_docs.sh | ||
- make docs | ||
artifacts: | ||
paths: | ||
- public | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
{{ cookiecutter.__package_name }} | ||
pkg_resources |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
PYTHON_VERSION := 3.11 | ||
WHEEL_VERSION := 0.43.0 | ||
|
||
.DEFAULT_GOAL := venv/bin/activate | ||
|
||
venv/bin/activate: requirements-dev.txt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not how makefile works, "functions" below check for existance of venv/bin/activate file if it doesn't exist then makefile will run this "function" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makefile will check if requirments file changed, if yes then venv will be rebuild :) |
||
python$(PYTHON_VERSION) -m venv venv | ||
. venv/bin/activate | ||
pip install --upgrade pip | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am getting following output:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the error still occur if you run make after generating the test project? Can you check if pip is configured correctly on your machine? |
||
pip install wheel==$(WHEEL_VERSION) | ||
pip install -r requirements-dev.txt | ||
pre-commit install | ||
|
||
lint: venv/bin/activate | ||
. venv/bin/activate | ||
pre-commit run --all-files | ||
|
||
clean: | ||
find . -type f -name "*.pyc" -delete | ||
find . -type d -name "__pycache__" -delete | ||
rm -rf venv | ||
rm -rf .pytest_cache | ||
rm -rf .coverage | ||
rm -rf build/ | ||
rm -rf dist/ | ||
rm -rf *.egg-info/ | ||
|
||
build: venv/bin/activate | ||
. venv/bin/activate | ||
python -m pip install -U build | ||
python -m build | ||
|
||
lic-check: venv/bin/activate | ||
. venv/bin/activate | ||
pip-licenses --from=mixed --ignore-packages `cat .libraries-whitelist.txt`> licenses.txt --allow-only="$(paste -sd ";" .license-whitelist.txt)" | ||
|
||
docs: venv/bin/activate | ||
. venv/bin/activate | ||
pip-licenses --from=mixed --format rst --with-urls --with-description --output-file=docs/licenses_table.rst | ||
sphinx-build -d docs/_build/doctrees docs/ public/ | ||
|
||
bump-version: venv/bin/activate | ||
. venv/bin/activate | ||
bump2version --verbose --commit $(args) | ||
|
||
freeze: venv/bin/activate | ||
. venv/bin/activate | ||
pip freeze > requirements-freeze.txt | ||
|
||
coverage: venv/bin/activate | ||
. venv/bin/activate | ||
coverage run -m pytest -v -p no:warnings --junitxml=report.xml tests/ | ||
coverage report | ||
coverage xml | ||
|
||
.PHONY: lint, clean, build, lic-check, docs, bump-version, freeze, coverage |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess we shouldn't be so brutal :D we want to use cached version to make this step much quicker and avoid setting up venv from scratch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that we can't run make functions without creating a virtual environment and sourcing it first. Because of this, I'm not sure if it's worth continuing to work on the Makefile. Since we can't use it everywhere, it would require maintaining code in two places—both the Makefile and the ci.yml.