123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- Contributing
- ============
- Developing CodeRed CMS
- To create a test project locally:
- The -e flag makes the install editable, which is relevant when running
- ``makemigrations`` in test project to actually generate the migration files
- in the coderedcms pip package. The ``[dev]`` installs extras such as sphinx
- for generating docs.
- your project name to ensure it is ignored by git.
- ``makemigrations coderedcms`` in the test project to generate the relevant
- migration files for the pip package. ALWAYS follow steps 4 and 5 in
- :doc:`/getting_started/install` with a fresh database before making migrations.
- app), run ``makemigrations website`` in the test project to generate the
- relevant migration files locally. Apply and test the migrations. When
- satisfied, re-generate the ``0001_initial.py`` migration in
- ``project_template/website/migrations/`` as so:
-
-
- ``testproject/website/migrations/``.
-
- an ``0001_initial.py`` migration.
-
- your newly generated migration.
- When making changes that are potentially destructive or backwards incompatible,
- increment the minor version number until coderedcms reaches a stable 1.0 release.
- Each production project that uses coderedcms should specify the appropriate
- version in its requirements.txt to prevent breakage.
- .. note::
- When testing existing projects with coderedcms installed from the master or
- development branches, be sure to use a disposable database, as it is likely
- that the migrations in master will not be the same migrations that get
- released.
- A Note on Cross-Platform Support
- CodeRed CMS works equally well on Windows, macOS, and Linux. When adding new features
- or new dependencies, ensure that these utilize proper cross-platform utilities in Python.
- To ease local development of CodeRed CMS, we have many automation scripts using
- `PowerShell Core <https://github.com/powershell/powershell>`_ because it provides high quality
- commercial support for Windows, macOS, and Linux. Throughout this contributing guide,
- you will encounter various PowerShell scripts which always provide the easiest and most
- definitive way of working on CodeRed CMS.
- Our goal is that users of any platform can develop or host a CodeRed CMS website easily.
- CSS Development
- When CSS changes are needed for front-end code (not the wagtail admin), Sass should be used.
- Each block, page, snippet, or other component that requires styling should have a dedicated ``.scss``
- file created beginning with an underscore in ``coderedcms/static/scss/``. Then import the file
- in our main ``codered-front.scss`` file. Then build a human readable and minified version of CSS
- from the command prompt as so:
- .. code-block:: console
- $ cd coderedcms/static/coderedcms/
- // Build human readable CSS, and source map for nicer debugging.
- $ pysassc -g -t expanded scss/codered-front.scss css/codered-front.css
- // Build minified CSS.
- $ pysassc -t compressed scss/codered-front.scss css/codered-front.min.css
- Finally, copy the license header comment into codered-front.min.css (since ``pysassc`` does
- not have an argument to preserve comments while also using compressed output).
- The generated CSS files must also be committed to version control whenever a sass file is
- changed, as they are distributed as part of our package.
- JavaScript Development
- All JavaScript should use ``codered-front.js`` as an entry point, meaning feature
- detection should happen in ``codered-front.js`` and then only load secondary scripts and CSS
- as needed. This ensures only one single small JavaScript file is required on page load, which
- reduces render-blocking resources and page load time.
- All JavaScript files produced by CodeRed should contain a license header comment. This standard
- license header comment states copyright, ownership, license, and also provides compatibility for
- `LibreJS <https://www.gnu.org/software/librejs/free-your-javascript.html>`_.
- .. code-block:: text
-
- ... script code here ...
-
- Testing CodeRed CMS
- To run the unit tests, run the following command. This will output a unit test
- report and code coverage report:
- .. code-block:: console
- $ pytest coderedcms/
- Or more conveniently, run the PowerShell script, which will also print out the
- code coverage percentage in the console:
- .. code-block:: console
- $ ./ci/run-tests.ps1
- Detailed test coverage reports are now available by opening ``htmlcov/index.html``
- in your browser (which is ignored by version control)
- Adding New Tests
- Test coverage at the moment is fairly minimal and it is highly recommended that
- new features and models include proper unit tests. Any testing infrastructure
- (i.e. implementations of abstract models and migrations) needed should be added
- to the ``tests`` app in your local copy of CodeRed CMS. The tests themselves
- should be in their relevant section in CodeRed CMS (i.e. tests for models in
- ``coderedcms.models.page_models`` should be located in
- ``coderedcms.models.tests.test_page_models``).
- For example, here is how you would add tests for a new abstract page type,
- ``CoderedCustomPage`` that would live in ``coderedcms/models/page_models.py``:
- .. code-block:: python
- class CoderedCustomPageTestCase(AbstractPageTestCase, WagtailPageTests):
- model = CoderedCustomPage
- .. code-block:: python
- class CustomPageTestCase(ConcreteBasicPageTestCase, WagtailPageTests):
- model = CustomPage
- may require.
- Static Analysis
- Flake8 is used to check for syntax and style errors. To analyze the entire
- codebase, run:
- .. code-block:: console
- $ flake8 .
- Alternatively, our continuous integration only analyzes the diff between your
- changes and master. To analyze just the diff of your current changes, run the
- `PowerShell Core <https://github.com/powershell/powershell>`_ script:
- .. code-block:: console
- $ ./ci/run-flake8.ps1
- Contributor Guidelines
- We are happy to accept pull requests from the community if it aligns with our
- vision for coderedcms. When creating a pull request, please make sure you
- include the following:
- * A description in the pull request of what this change does and how it works.
- * Reference to an issue if the change is related to one of the issues on our
- GitHub page.
- * Documentation updates in the ``docs/`` directory describing your change.
- Following submission of your pull request, a CodeRed member will review and test
- your change. **All changes, even by CodeRed members, must go through a pull
- request process to ensure quality.**
- Building Python Packages
- To build a publicly consumable pip package, run:
- .. code-block:: console
- $ python setup.py sdist bdist_wheel
- Building Documentation
- For every code or feature change, be sure to update the docs in the repository.
- To build the documentation run the PowerShell script, which will also check for
- errors in the documentation:
- .. code-block:: console
- $ ./ci/make-docs.ps1
- Or manually using sphinx:
- .. code-block:: console
- $ sphinx-build -M html docs/ docs/_build/ -W
- Output will be in ``docs/_build/html/`` directory.
- Publishing a New Release
- First checkout the code/branch for release.
- Next build a pip package:
- .. code-block:: console
- $ python setup.py sdist bdist_wheel
- Then upload the pip package to the Python Package Index:
- .. code-block:: console
- $ twine upload dist
|