Skip to content
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

Update boilerplate, dependencies, coding-style … #18

Merged
merged 4 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ indent_size = 4
# isort config
atomic = true
multi_line_output = 5
line_length = 80
line_length = 100
combine_as_imports = true
skip = wsgi.py,docs,bower_components,node_modules
known_third_party =
Expand Down
54 changes: 29 additions & 25 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
name: Python package
name: Run tests

on: [push]
on:
push:
branches:
- "main"
pull_request:
branches:
- "main"

jobs:
build:

test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.7]
# Run in all these versions of Python
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
# Checkout the latest code from the repo
- name: Checkout repo
uses: actions/checkout@v3
# Setup which version of Python to use
- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: |
make development
- name: Test with pytest
run: |
.venv/bin/pytest --cov-report xml --cov=drupy tests/
- uses: codecov/codecov-action@v1
cache: pip
# Display the Python version being used
- name: Display Python version
run: python -c "import sys; print(sys.version)"
# Install the package.
- name: Install package
run: pip install -r requirements-dev.txt; pip install -e .
- name: Run tests
run: pytest
#- name: Run linters
# uses: pre-commit/action@v3.0.0
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ __pycache__
.eggs
coverage.xml
.pytest_cache/
pytest-junit.xml
11 changes: 0 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ repos:
- id: check-added-large-files
- repo: local
hooks:
- id: safety
name: safety
entry: safety check -r
language: system
files: requirements.txt
- id: isort
name: isort
entry: isort
Expand All @@ -30,12 +25,6 @@ repos:
language: system
types:
- python
- id: pycodestyle
name: pycodestyle
entry: pycodestyle
language: system
types:
- python
- id: pydocstyle
name: pydocstyle
entry: pydocstyle
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

36 changes: 17 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,53 +1,51 @@
.PHONY: help bootstrap test safety requirements venv
.PHONY: help bootstrap lint test requirements

VENV?=.venv
PYTHON?=python3
PYTHONNOUSERSITE?=1

help:
@echo
@echo "make install -- setup production environment"
@echo
@echo "make development -- setup development environment"
@echo "make test -- run full test suite"
@echo "make safety -- run safety check on packages"
@echo "make lint -- run all linters on the code base"
@echo
@echo "make requirements -- only compile the requirements*.txt files"
@echo "make .venv -- bootstrap the virtualenv."
@echo

PIP_SYNC=$(VENV)/bin/pip-sync

install: $(VENV)/.pip-installed-production

development: $(VENV)/.pip-installed-development .git/hooks/pre-commit

test:
$(VENV)/bin/pytest --cov tests

safety: requirements.txt
$(VENV)/bin/safety check -r $<
lint: development
$(VENV)/bin/pre-commit run -a

requirements: requirements.txt requirements-dev.txt
test: development
$(VENV)/bin/pytest

%.txt: %.in
$(VENV)/bin/pip-compile -v --output-file $@ $<
requirements: requirements-dev.txt

requirements-dev.txt: requirements-dev.in requirements.in
requirements-dev.txt: pyproject.toml $(PIP_SYNC)
$(VENV)/bin/pip-compile -v --output-file=$@ --extra=dev --extra=yaml $<

# Actual files/directories
################################################################################

venv: $(VENV)

# Create this directory as a symbolic link to an existing virtualenv, if you want to use that.
$(VENV):
$(PYTHON) -m venv $(VENV)
$(VENV)/bin/pip install pip-tools wheel
$(PYTHON) -m venv --system-site-packages $(VENV)
touch $(VENV)

$(VENV)/.pip-installed-production: $(VENV) requirements.txt
$(VENV)/bin/pip-sync requirements.txt && touch $@
$(PIP_SYNC): $(VENV)
PYTHONNOUSERSITE=$(PYTHONNOUSERSITE) $(VENV)/bin/pip install --upgrade pip pip-tools wheel && touch $@

$(VENV)/.pip-installed-development: $(VENV) requirements-dev.txt
$(VENV)/bin/pip-sync requirements-dev.txt && touch $@
$(VENV)/.pip-installed-development: requirements-dev.txt $(PIP_SYNC)
PYTHONNOUSERSITE=$(PYTHONNOUSERSITE) $(PIP_SYNC) $< && touch $@

.git/hooks/pre-commit: $(VENV)
$(VENV)/bin/pre-commit install
Expand Down
3 changes: 1 addition & 2 deletions README.md → README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ FAQ
modules/
contrib/ # allow different versions of a module per site
module1 -> ../../../../../projects/module1-7.x-2.0

Directory layouts like this seems rather cumbersome with drush make which seems to be a bit biased towards a one-drupal-tree-per-site approach of hosting.

* **Why not use sites/all/ for code-sharing?**
sites/all/ doesn't allow us to update modules site by site. If an module has an update-hook (ie. brings down your site until drush updb is run) you have to update the module-code. Then you need to run drush updb in all sites to bring them online again. So the mean down-time for a site is: n/2. With lots of sites this can take quite some time.
* **Why care for code sharing at all?**
Sharing the code for modules means that our opcode cache needs to hold only one copy of a file instead of one per site.

Loading