Skip to content

Commit 2da193e

Browse files
committed
Add make test & development documentation
1 parent f203814 commit 2da193e

12 files changed

+9907
-7
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747

4848
- run:
4949
name: JS deps
50-
command: cd tests && yarn
50+
command: cd tests && npm ci
5151
- save_cache:
5252
paths:
5353
- ./npm

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ requirements = -r requirements-dev.txt
1111

1212
all: install build
1313

14+
@activate_venv = . $(ENV)/bin/activate
15+
@check_if_venv_active = $(shell python -c 'import sys; print ("1" if sys.prefix != sys.base_prefix else "0")')
16+
@activate_venv_if_not_active = $(if $(filter 1,$(check_if_venv_active)),$(activate_venv),)
17+
1418
clean:
1519
@echo "Cleaning..."
1620
@find webpack_loader/ -name '*.pyc' -delete
1721
@rm -rf ./build ./*egg* ./.coverage ./dist
1822

1923
build: clean
24+
@$(activate_venv_if_not_active)
2025
@echo "Building..."
2126
@pip install -U setuptools
2227
@python setup.py sdist bdist_wheel --universal
@@ -25,6 +30,12 @@ install:
2530
@echo "Installing build dependencies"
2631
@[ ! -d $(ENV)/ ] && python3 -m venv $(ENV)/ || :
2732
@$(ENV)/bin/pip install $(requirements)
33+
@cd tests; npm i
34+
35+
test:
36+
@$(activate_venv_if_not_active)
37+
@echo "Running tests..."
38+
@cd tests; coverage run manage.py test
2839

2940
publish: build
3041
@echo "Publishing to $(REPOSITORY)..."

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ The `STATS_FILE` parameter represents the output file produced by `webpack-bundl
111111

112112
- `LOADER_CLASS` is the fully qualified name of a python class as a string that holds the custom webpack loader. This is where behavior can be customized as to how the stats file is loaded. Examples include loading the stats file from a database, cache, external url, etc. For convenience, `webpack_loader.loaders.WebpackLoader` can be extended. The `load_assets` method is likely where custom behavior will be added. This should return the stats file as an object.
113113

114+
- `WEBPACK_CHUNK_URL_USE_PUBLIC_PATH` (Default: `True`) is a flag that enables using the webpack's [publicPath](https://webpack.js.org/guides/public-path/) config as the chunk URL. Setting this to false may be useful if you are using both publicPath and a S3Storage with a custom ___domain.
115+
114116
- `SKIP_COMMON_CHUNKS` is a flag which prevents already generated chunks from being included again in the same page. This should only happen if you use more than one entrypoint per Django template (multiple `render_bundle` calls). By enabling this, you can get the same default behavior of the [HtmlWebpackPlugin](https://webpack.js.org/plugins/html-webpack-plugin/). The same caveats apply as when using `skip_common_chunks` on `render_bundle`, see that section below for more details.
115117

116118
Here's a simple example of loading from an external url:
@@ -436,6 +438,26 @@ In order to use `django-webpack-loader>=1.0.0`, you must ensure that `webpack-bu
436438

437439
This is necessary because the formatting of `webpack-stats.json` that `webpack-bundle-tracker` outputs has changed starting at version `1.0.0-alpha.1`. Starting at `django-webpack-loader==1.0.0`, this is the only formatting accepted here, meaning that other versions of that package don't output compatible files anymore, thereby breaking compatibility with older `webpack-bundle-tracker` releases.
438440

441+
## Development
442+
443+
This project includes a Makefile that provides several useful commands for building, installing, and publishing the project.
444+
445+
### Available Commands
446+
447+
- `clean`: Removes generated files and directories.
448+
- `build`: Cleans the project and builds the distribution packages.
449+
- `test`: Run the tests.
450+
- `install`: Installs the project's build dependencies. Will initialize a virtual environment if one does not exist.
451+
- `publish`: Builds the distribution packages and publishes them to the specified repository.
452+
- `register`: Registers the package on the specified repository.
453+
454+
To execute a command, run `make <command>` in the project's root directory.
455+
456+
### Virtual Environment Settings
457+
458+
- `ENV`: The name of the virtual environment. (Default: `venv`)
459+
- `REPOSITORY`: The repository to publish the distribution packages to. (Default: `pypi`)
460+
439461
## Commercial Support
440462

441463
[![alt text](https://avatars2.githubusercontent.com/u/5529080?s=80&v=4 "Vinta Logo")](https://www.vinta.com.br/)

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
coverage==5.5
12
twine==3.4.1
23
Django==3.2.23
34
django-jinja==2.10.2

0 commit comments

Comments
 (0)