diff --git a/.cookietemple.yml b/.cookietemple.yml index 5667562..541fc75 100644 --- a/.cookietemple.yml +++ b/.cookietemple.yml @@ -1,9 +1,9 @@ -cookietemple_version: '0.1.0 # <>' +cookietemple_version: '1.2.4 # <>' domain: web language: python project_slug: mlf_core_website project_slug_no_hyphen: mlf_core_website -template_version: '1.0.0 # <>' +template_version: '1.1.0 # <>' template_handle: web-website-python github_username: mlf-core creator_github_username: zethson diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index dde4226..213545d 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -11,7 +11,7 @@ assignees: '' -**Describe the solution you'd like** +**Describe the solution you would like** diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml index 0b5bd69..c2ae369 100644 --- a/.github/workflows/build_package.yml +++ b/.github/workflows/build_package.yml @@ -1,6 +1,6 @@ name: Build mlf_core_website Package -on: [push] +on: [push, pull_request] jobs: build: diff --git a/.github/workflows/check_no_SNAPSHOT_master.yml b/.github/workflows/check_no_SNAPSHOT_master.yml index 7589403..8d40841 100644 --- a/.github/workflows/check_no_SNAPSHOT_master.yml +++ b/.github/workflows/check_no_SNAPSHOT_master.yml @@ -9,6 +9,10 @@ jobs: test: runs-on: ubuntu-latest steps: + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' # PRs to the repository master branch are only ok if coming from any patch or release branch - name: Install cookietemple run: pip install cookietemple @@ -23,7 +27,6 @@ jobs: exit 0 fi - # If the above check failed, post a comment on the PR explaining the failure # NOTE - this may not work if the PR is coming from a fork, due to limitations in GitHub actions secrets - name: Post PR comment @@ -38,4 +41,3 @@ jobs: The `master` branch should never have any SNAPSHOT versions, since only fully stable code should be on the `master` branch. repo-token: ${{ secrets.GITHUB_TOKEN }} allow-repeats: false - diff --git a/.github/workflows/build_docs.yml b/.github/workflows/publish_docs.yml similarity index 71% rename from .github/workflows/build_docs.yml rename to .github/workflows/publish_docs.yml index 521cc7b..a1541fe 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/publish_docs.yml @@ -29,3 +29,10 @@ jobs: cd docs make html + - name: Deploy + if: ${{ github.ref == 'refs/heads/master' }} + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/_build/html + diff --git a/.github/workflows/run_bandit.yml b/.github/workflows/run_bandit.yml index ecfc4fd..634e273 100644 --- a/.github/workflows/run_bandit.yml +++ b/.github/workflows/run_bandit.yml @@ -1,9 +1,12 @@ name: Run bandit -on: +on: push: paths: - "**/*.py" + pull_request: + paths: + - "**/*.py" jobs: build: diff --git a/.github/workflows/run_codecov.yml b/.github/workflows/run_codecov.yml index ed59147..ebca35e 100644 --- a/.github/workflows/run_codecov.yml +++ b/.github/workflows/run_codecov.yml @@ -1,5 +1,5 @@ name: Run Codecov -on: [push] +on: [push, pull_request] jobs: run: diff --git a/.github/workflows/run_cookietemple_lint.yml b/.github/workflows/run_cookietemple_lint.yml index 1297032..03b5fac 100644 --- a/.github/workflows/run_cookietemple_lint.yml +++ b/.github/workflows/run_cookietemple_lint.yml @@ -14,7 +14,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: 3.9 - name: Install cookietemple run: | @@ -22,4 +22,4 @@ jobs: - name: Run cookietemple lint run: | - cookietemple lint . + cookietemple lint . --skip-external diff --git a/.github/workflows/run_css_lint.yml b/.github/workflows/run_css_lint.yml index 9034d60..ff15dcb 100644 --- a/.github/workflows/run_css_lint.yml +++ b/.github/workflows/run_css_lint.yml @@ -1,9 +1,12 @@ name: CSS linter -on: +on: push: paths: - "**/*.css" + pull_request: + paths: + - "**/*.css" jobs: build: diff --git a/.github/workflows/run_flake8_linting.yml b/.github/workflows/run_flake8_linting.yml index 34df5f8..fdfe190 100644 --- a/.github/workflows/run_flake8_linting.yml +++ b/.github/workflows/run_flake8_linting.yml @@ -1,9 +1,12 @@ name: Run flake8 linting -on: +on: push: paths: - "**/*.py" + pull_request: + paths: + - "**/*.py" jobs: build: diff --git a/.github/workflows/run_tox_testsuite.yml b/.github/workflows/run_tox_testsuite.yml index af71366..5f1db67 100644 --- a/.github/workflows/run_tox_testsuite.yml +++ b/.github/workflows/run_tox_testsuite.yml @@ -1,6 +1,6 @@ name: Run mlf_core_website Tox Test Suite -on: [push] +on: [push, pull_request] jobs: build: diff --git a/.github/workflows/sync_project.yml b/.github/workflows/sync_project.yml new file mode 100644 index 0000000..d290c9c --- /dev/null +++ b/.github/workflows/sync_project.yml @@ -0,0 +1,34 @@ +name: cookietemple sync + +on: + schedule: + - cron: '0 1 * * *' # 1 am UTC + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + + - name: Install cookietemple + run: pip install cookietemple + + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + token: '${{ secrets.CT_SYNC_TOKEN }}' + name: Check out source-code repository + + - uses: oleksiyrudenko/gha-git-credentials@v2 + with: + name: 'zethson' + email: 'lukas.heumos@posteo.net' + actor: 'zethson' + token: '${{ secrets.CT_SYNC_TOKEN}}' + + - name: Sync project + run: cookietemple sync . ${{ secrets.CT_SYNC_TOKEN }} zethson diff --git a/LICENSE b/LICENSE index a440f0f..acdb276 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020, Lukas Heumos +Copyright (c) 2021, Lukas Heumos Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index 1881b6a..08a9f01 100644 --- a/Makefile +++ b/Makefile @@ -1,85 +1,5 @@ -.PHONY: clean clean-test clean-pyc clean-build docs help -.DEFAULT_GOAL := help - -define BROWSER_PYSCRIPT -import os, webbrowser, sys - -from urllib.request import pathname2url - -webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) -endef -export BROWSER_PYSCRIPT - -define PRINT_HELP_PYSCRIPT -import re, sys - -for line in sys.stdin: - match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) - if match: - target, help = match.groups() - print("%-20s %s" % (target, help)) -endef -export PRINT_HELP_PYSCRIPT - -BROWSER := python -c "$$BROWSER_PYSCRIPT" - -help: - @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) - -clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts - -clean-build: ## remove build artifacts - rm -fr build/ - rm -fr dist/ - rm -fr .eggs/ - find . -name '*.egg-info' -exec rm -fr {} + - find . -name '*.egg' -exec rm -f {} + - -clean-pyc: ## remove Python file artifacts - find . -name '*.pyc' -exec rm -f {} + - find . -name '*.pyo' -exec rm -f {} + - find . -name '*~' -exec rm -f {} + - find . -name '__pycache__' -exec rm -fr {} + - -clean-test: ## remove test and coverage artifacts - rm -fr .tox/ - rm -f .coverage - rm -fr htmlcov/ - rm -fr .pytest_cache - -lint: ## check style with flake8 - flake8 mlf_core_website tests - -test: ## run tests quickly with the default Python - pytest - -test-all: ## run tests on every Python version with tox - tox - -coverage: ## check code coverage quickly with the default Python - coverage run --source mlf_core_website -m pytest - coverage report -m - coverage html - $(BROWSER) htmlcov/index.html - -docs: ## generate Sphinx HTML documentation, including API docs - rm -f docs/mlf_core_website.rst - rm -f docs/modules.rst - sphinx-apidoc -o docs/ mlf_core_website - $(MAKE) -C docs clean - $(MAKE) -C docs html - $(BROWSER) docs/_build/html/index.html - -servedocs: docs ## compile the docs watching for changes - watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . - -release: dist ## package and upload a release - twine upload dist/* - -dist: clean ## builds source and wheel package - python setup.py sdist - python setup.py bdist_wheel - ls -l dist - -install: clean ## install the package to the active Python's site-packages - pip install . +ifeq ($(OS),Windows_NT) +include makefiles/Windows.mk +else +include makefiles/Linux.mk +endif diff --git a/cookietemple.cfg b/cookietemple.cfg index d08859f..ed0d172 100644 --- a/cookietemple.cfg +++ b/cookietemple.cfg @@ -3,6 +3,7 @@ current_version = 0.1.0 [bumpversion_files_whitelisted] setup_file = setup.py +dot_cookietemple = .cookietemple.yml [bumpversion_files_blacklisted] @@ -10,4 +11,7 @@ setup_file = setup.py ct_sync_level = minor [sync_files_blacklisted] +changelog = CHANGELOG.rst +requirements = requirements.txt +requirements_dev = requirements_dev.txt diff --git a/deployment_scripts/setup.sh b/deployment_scripts/setup.sh index 281d134..592bed6 100644 --- a/deployment_scripts/setup.sh +++ b/deployment_scripts/setup.sh @@ -1,35 +1,42 @@ #!/bin/bash # Reference: # https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04 +sudo apt-get install software-properties-common +sudo apt-add-repository universe +sudo apt-get update +sudo apt-get install python3-pip +sudo apt-get install python3-dev nginx -y +sudo pip3 install virtualenv -apt-get update +virtualenv dpenv +source dpenv/bin/activate +sudo apt-get update pip3 install gunicorn - -python3 setup.py clean --all install +make install cp /home/cookietempleuser/mlf_core_website/deployment_scripts/mlf_core_website.service \ /etc/systemd/system/mlf_core_website.service -systemctl start mlf_core_website +sudo systemctl start mlf_core_website -systemctl enable mlf_core_website +sudo systemctl enable mlf_core_website cp /home/cookietempleuser/mlf_core_website/deployment_scripts/mlf_core_website \ /etc/nginx/sites-available/mlf_core_website ln -s /etc/nginx/sites-available/mlf_core_website /etc/nginx/sites-enabled -nginx -t +sudo nginx -t -systemctl restart nginx +sudo systemctl restart nginx -ufw delete allow 5000 +sudo ufw delete allow 5000 -ufw allow 'Nginx Full' +sudo ufw allow 'Nginx Full' -add-apt-repository ppa:certbot/certbot -y +sudo add-apt-repository ppa:certbot/certbot -y -apt install python3-certbot-nginx -y +sudo apt install python3-certbot-nginx -y -certbot --nginx -d mlf-core.com -d www.mlf-core.com --non-interactive --agree-tos -m lukas.heumos@posteo.net +sudo certbot --nginx -d mlf-core.com -d www.mlf-core.com --non-interactive --agree-tos -m lukas.heumos@posteo.net diff --git a/docs/_static/custom_cookietemple.css b/docs/_static/custom_cookietemple.css index ff1006b..116126b 100644 --- a/docs/_static/custom_cookietemple.css +++ b/docs/_static/custom_cookietemple.css @@ -13,6 +13,24 @@ div, span, code { background-color: #005fff !important; } +.wy-side-nav-search form { + background-color: #005fff !important; +} + +.wy-side-nav-search .wy-form input { + background-color: #2D2E2F !important; +} + +.wy-side-nav-search .wy-form input:focus { + background-color: #FFFFFF !important; + color: #000000 !important; +} + +::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */ + color: white; + opacity: 1; /* Firefox */ +} + /*Font color is mainly white*/ .rst-content p, li, h1, h2, h3, h4, h5, h6, .highlight-console, .n, .section { color: #FFFFFF; @@ -63,6 +81,17 @@ div, span, code { background: #005fff !important; } +.wy-menu-vertical li.toctree-l3.current li.toctree-l4 > a { + color: #FFFFFF !important; + background: #2D2E2F !important; +} + +.wy-menu-vertical li.toctree-l3.current li.toctree-l4 > a:hover { + color: #FFFFFF !important; + background: #005fff !important; +} + + .wy-menu-vertical li.toctree-l2.current > a:hover { color: #FFFFFF !important; background: #005fff !important; @@ -108,6 +137,21 @@ div, span, code { background-color: #2D2E2F !important; } +.wy-menu-vertical li.toctree-l2.current a .toctree-expand { + background-color: #2D2E2F !important; + color: #FFFFFF !important; +} + +.wy-menu-vertical li.toctree-l2.current a:hover .toctree-expand { + background-color: #005fff !important; + color: #FFFFFF !important; +} + +.wy-menu-vertical li.toctree-l3.current a .toctree-expand { + background-color: #2D2E2F !important; + color: #FFFFFF !important; +} + .wy-menu-vertical li.toctree-l3 a:hover span.toctree-expand { background-color: #005fff !important; } diff --git a/docs/conf.py b/docs/conf.py index f4c0524..7b09375 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -45,7 +45,7 @@ # General information about the project. project = 'mlf_core_website' -copyright = "2020, Lukas Heumos" +copyright = "2021, Lukas Heumos" author = "Lukas Heumos" # The version info for the project you're documenting, acts as replacement diff --git a/makefiles/Linux.mk b/makefiles/Linux.mk new file mode 100644 index 0000000..c73076b --- /dev/null +++ b/makefiles/Linux.mk @@ -0,0 +1,84 @@ +.PHONY: clean clean-test clean-pyc clean-build docs help +.DEFAULT_GOAL := help + +define BROWSER_PYSCRIPT +import os, webbrowser, sys + +from urllib.request import pathname2url + +webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) +endef +export BROWSER_PYSCRIPT + +define PRINT_HELP_PYSCRIPT +import re, sys + +for line in sys.stdin: + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) + if match: + target, help = match.groups() + print("%-20s %s" % (target, help)) +endef +export PRINT_HELP_PYSCRIPT + +BROWSER := python -c "$$BROWSER_PYSCRIPT" + +help: + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) + +clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts + +clean-build: ## remove build artifacts + rm -fr build/ + rm -fr dist/ + rm -fr .eggs/ + find . -name '*.egg-info' -exec rm -fr {} + + find . -name '*.egg' -exec rm -f {} + + +clean-pyc: ## remove Python file artifacts + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + find . -name '__pycache__' -exec rm -fr {} + + +clean-test: ## remove test and coverage artifacts + rm -fr .tox/ + rm -f .coverage + rm -fr htmlcov/ + rm -fr .pytest_cache + +lint: ## check style with flake8 + flake8 mlf_core_website tests + +test: ## run tests quickly with the default Python + pytest + +test-all: ## run tests on every Python version with tox + tox + +coverage: ## check code coverage quickly with the default Python + coverage run --source mlf_core_website -m pytest + coverage report -m + coverage html + $(BROWSER) htmlcov/index.html + +docs: ## generate Sphinx HTML documentation, including API docs + rm -f docs/mlf_core_website.rst + rm -f docs/modules.rst + sphinx-apidoc -o docs/ mlf_core_website + $(MAKE) -C docs clean + $(MAKE) -C docs html + $(BROWSER) docs/_build/html/index.html + +servedocs: docs ## compile the docs watching for changes + watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . + +release: dist ## package and upload a release + twine upload dist/* + +dist: clean ## builds source and wheel package + python setup.py sdist + python setup.py bdist_wheel + +install: clean ## install the package to the active Python's site-packages + pip install . diff --git a/makefiles/Windows.mk b/makefiles/Windows.mk new file mode 100644 index 0000000..02694b0 --- /dev/null +++ b/makefiles/Windows.mk @@ -0,0 +1,84 @@ +.PHONY: clean clean-test clean-pyc clean-build docs help +.DEFAULT_GOAL := help + +define BROWSER_PYSCRIPT +import os, webbrowser, sys + +from urllib.request import pathname2url + +webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) +endef +export BROWSER_PYSCRIPT + +define PRINT_HELP_PYSCRIPT +import re, sys + +for line in sys.stdin: + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) + if match: + target, help = match.groups() + print("%-20s %s" % (target, help)) +endef +export PRINT_HELP_PYSCRIPT + +BROWSER := python -c "$$BROWSER_PYSCRIPT" + +help: + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) + +clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts + +clean-build: ## remove build artifacts + if exist build rd /s /q build + if exist dist rd /s /q dist + if exist .eggs rd /s /q .eggs + for /d /r . %%d in (*egg-info) do @if exist "%%d" echo "%%d" && rd /s/q "%%d" + del /q /s /f .\*.egg + +clean-pyc: ## remove Python file artifacts + del /s /f /q .\*.pyc + del /s /f /q .\*.pyo + del /s /f /q .\*~ + for /d /r . %%d in (*__pycache__) do @if exist "%%d" echo "%%d" && rd /s/q "%%d" + +clean-test: ## remove test and coverage artifacts + if exist .tox rd /s /q .tox + if exist .coverage rd /s /q .coverage + if exist htmlcov rd /s /q htmlcov + if exist .pytest_cache rd /s /q .pytest_cache + +lint: ## check style with flake8 + flake8 mlf_core_website tests + +test: ## run tests quickly with the default Python + pytest + +test-all: ## run tests on every Python version with tox + tox + +coverage: ## check code coverage quickly with the default Python + coverage run --source mlf_core_website -m pytest + coverage report -m + coverage html + $(BROWSER) htmlcov\index.html + +docs: ## generate Sphinx HTML documentation, including API docs + del /f /q docs\mlf_core_website.rst + del /f /q docs\modules.rst + sphinx-apidoc -o docs\ mlf_core_website + $(MAKE) -C docs clean + $(MAKE) -C docs html + $(BROWSER) docs\_build\html\index.html + +servedocs: docs ## compile the docs watching for changes + watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . + +release: dist ## package and upload a release + twine upload dist\* + +dist: clean ## builds source and wheel package + python setup.py sdist + python setup.py bdist_wheel + +install: clean ## install the package to the active Python's site-packages + pip install . diff --git a/setup.py b/setup.py index 3e49d46..e3246af 100644 --- a/setup.py +++ b/setup.py @@ -40,22 +40,20 @@ def walker(base, *paths): setup( author="Lukas Heumos", author_email='lukas.heumos@posteo.net', - python_requires='>=3.5', + python_requires='>=3.7', classifiers=[ 'Development Status :: 2 - Pre-Alpha', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Natural Language :: English', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', ], description="The mlf-core website.", entry_points={ 'console_scripts': [ - 'mlf_core_website={}.server:main'.format(module.__name__), + f'mlf_core_website={module.__name__}.server:main', ], }, install_requires=requirements,