Skip to content

Commit

Permalink
Implement review suggestions, thx @Mogost
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Mar 14, 2021
1 parent e3c15af commit cca3183
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 178 deletions.
26 changes: 10 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
- run: python -m pip install -r requirements.txt
- run: make msgcheck
- run: msgcheck -n hijack/locale/*/LC_MESSAGES/*.po

lint:
strategy:
Expand All @@ -46,27 +46,21 @@ jobs:
- run: python -m pip install -r requirements.txt
- run: ${{ matrix.lint-command }}

dist:
readme:
runs-on: ubuntu-latest
steps:
- run: sudo apt install -y gettext
- uses: actions/setup-python@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v2
- run: make dist
- name: Install Python dependencies
run: python -m pip install --upgrade pip setuptools wheel twine readme-renderer
- run: python setup.py sdist bdist_wheel
- run: python -m twine check dist/*
- uses: actions/upload-artifact@v2
with:
path: dist/*

readme:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v2
- run: python -m pip install --upgrade pip setuptools wheel twine readme-renderer
- uses: actions/checkout@v2
- run: python setup.py sdist bdist_wheel
- run: python -m twine check dist/*

stylelint:
runs-on: ubuntu-latest
steps:
Expand All @@ -78,7 +72,6 @@ jobs:
pytest:
runs-on: ubuntu-latest
needs:
- dist
- readme
- lint
- stylelint
Expand All @@ -95,17 +88,18 @@ jobs:
- "3.0"
- "3.1"
steps:
- uses: actions/checkout@v2
- run: sudo apt install -y gettext
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/setup-node@v2
- uses: actions/checkout@v2
- name: Upgrade Python setuptools
run: python -m pip install --upgrade pip setuptools wheel codecov
- name: Install Django ${{ matrix.django-version }}
run: python -m pip install django~=${{ matrix.django-version }}
- uses: actions/setup-node@v2
- run: make static
- run: python setup.py develop
- name: Run tests
run: python setup.py test
- run: codecov
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ jobs:
- uses: actions/setup-python@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v2
- run: make dist
- name: Install Python dependencies
run: python -m pip install --upgrade pip setuptools wheel twine
- name: Build dist packages
run: python setup.py sdist bdist_wheel
- name: Upload packages
run: python -m twine upload dist/*
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ node_modules/

# minified static files
*.min.*
*.css
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/*
159 changes: 30 additions & 129 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,142 +1,43 @@
# Contributing to this project
# Contributing Guide

Please take a moment to review this document in order to make the contribution
process easy and effective for everyone involved.
## Setup Development Environment

Following these guidelines helps to communicate that you respect the time of
the developers managing and developing this open source project. In return,
they should reciprocate that respect in addressing your issue or assessing
patches and features.
### Non-Python dependencies

You will need both a supported version of Node.js and gettext.
Gettext is best installed using a package manager like apt or brew.

## Using the issue tracker
```shell
# Debian/Ubuntu
sudo apt install gettext
# macOS
brew install gettext
```

The issue tracker is the preferred channel for [bug reports](#bugs),
[features requests](#features) and [submitting pull
requests](#pull-requests), but please respect the following restrictions:
You may use NVM to install the correct Node.js version:

* Please **do not** use the issue tracker for personal support requests (use
[Stack Overflow](http://stackoverflow.com) or IRC).
```shell
nvm install
nvm use
```

* Please **do not** derail or troll issues. Keep the discussion on topic and
respect the opinions of others.
Last but not least, install the required Node.js dependencies.
```shell
npm ci
```

### Development setup

<a name="bugs"></a>
## Bug reports
After installing the non-Python dependencies, its as easy as calling:

A bug is a _demonstrable problem_ that is caused by the code in the repository.
Good bug reports are extremely helpful - thank you!
```shell
python setyp.py develop
```

Guidelines for bug reports:
## Tests

1. **Use the GitHub issue search** &mdash; check if the issue has already been
reported.
Simply run:

2. **Check if the issue has been fixed** &mdash; try to reproduce it using the
latest `master` or development branch in the repository.

3. **Isolate the problem** &mdash; create a [reduced test
case](http://css-tricks.com/reduced-test-cases/) and a live example.

A good bug report shouldn't leave others needing to chase you up for more
information. Please try to be as detailed as possible in your report. What is
your environment? What steps will reproduce the issue? What browser(s) and OS
experience the problem? What would you expect to be the outcome? All these
details will help people to fix any potential bugs.

Example:

> Short and descriptive example bug report title
>
> A summary of the issue and the browser/OS environment in which it occurs. If
> suitable, include the steps required to reproduce the bug.
>
> 1. This is the first step
> 2. This is the second step
> 3. Further steps, etc.
>
> `<url>` - a link to the reduced test case
>
> Any other information you want to share that is relevant to the issue being
> reported. This might include the lines of code that you have identified as
> causing the bug, and potential solutions (and your opinions on their
> merits).

<a name="features"></a>
## Feature requests

Feature requests are welcome. But take a moment to find out whether your idea
fits with the scope and aims of the project. It's up to *you* to make a strong
case to convince the project's developers of the merits of this feature. Please
provide as much detail and context as possible.


<a name="pull-requests"></a>
## Pull requests

Good pull requests - patches, improvements, new features - are a fantastic
help. They should remain focused in scope and avoid containing unrelated
commits.

**Please ask first** before embarking on any significant pull request (e.g.
implementing features, refactoring code, porting to a different language),
otherwise you risk spending a lot of time working on something that the
project's developers might not want to merge into the project.

Please adhere to the coding conventions used throughout a project (indentation,
accurate comments, etc.) and any other requirements (such as test coverage).

Follow this process if you'd like your work considered for inclusion in the
project:

1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork,
and configure the remotes:

```bash
# Clone your fork of the repo into the current directory
git clone https://github.com/<your-username>/<repo-name>
# Navigate to the newly cloned directory
cd <repo-name>
# Assign the original repo to a remote called "upstream"
git remote add upstream https://github.com/<upstream-owner>/<repo-name>
```

2. If you cloned a while ago, get the latest changes from upstream:

```bash
git checkout <dev-branch>
git pull upstream <dev-branch>
```

3. Create a new topic branch (off the main project development branch) to
contain your feature, change, or fix:

```bash
git checkout -b <topic-branch-name>
```

4. Commit your changes in logical chunks. Please adhere to these [git commit
message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
or your code is unlikely be merged into the main project. Use Git's
[interactive rebase](https://help.github.com/articles/interactive-rebase)
feature to tidy up your commits before making them public.

5. Locally merge (or rebase) the upstream development branch into your topic branch:

```bash
git pull [--rebase] upstream <dev-branch>
```

6. Push your topic branch up to your fork:

```bash
git push origin <topic-branch-name>
```

7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
with a clear title and description.

**IMPORTANT**: By submitting a patch, you agree to allow the project owner to
license your work under the same license as that used by the project.
```shell
python setup.py test
```
29 changes: 0 additions & 29 deletions Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "django-hijack",
"version": "1.0.0",
"scripts": {
"build": "postcss hijack/static/hijack/hijack-styles.scss -o hijack/static/hijack/hijack-styles.scss",
"build:watch": "postcss hijack/static/hijack/hijack-styles.scss -o hijack/static/hijack/hijack-styles.scss -w",
"build": "postcss hijack/static/hijack/hijack-styles.scss -o hijack/static/hijack/hijack-styles.css",
"build:watch": "postcss hijack/static/hijack/hijack-styles.scss -o hijack/static/hijack/hijack-styles.css -w",
"lint:scss": "stylelint \"**/*.scss\""
},
"repository": {
Expand Down
90 changes: 89 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,92 @@
#!/usr/bin/env python
import distutils
import glob
import os
import subprocess # nosec
from distutils.cmd import Command
from distutils.command.build import build as _build

from setuptools import setup
from setuptools.command.develop import develop as _develop
from setuptools.command.install_lib import install_lib as _install_lib

BASE_DIR = os.path.dirname((os.path.abspath(__file__)))


class compile_translations(Command):
description = "Compile i18n translations using gettext."
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
pattern = "hijack/locale/*/LC_MESSAGES/django.po"
for file in glob.glob(pattern):
name, ext = os.path.splitext(file)
cmd = ["msgfmt", "-c", "-o", f"{name}.mo", file]
self.announce(
"running command: %s" % " ".join(cmd), level=distutils.log.INFO
)
subprocess.check_call(cmd, cwd=BASE_DIR) # nosec


class compile_scss(Command):
description = "Compile SCSS files using postcss."
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
cmd = ["npm", "ci"]
self.announce(
"running command: %s" % " ".join(cmd), level=distutils.log.INFO
)
subprocess.check_call(cmd, cwd=BASE_DIR) # nosec

cmd = ["npm", "run", "build"]
self.announce(
"running command: %s" % " ".join(cmd), level=distutils.log.INFO
)
subprocess.check_call(cmd, cwd=BASE_DIR) # nosec


class build(_build):
sub_commands = [
("compile_translations", None),
("compile_scss", None),
] + _build.sub_commands


class install_lib(_install_lib):
def run(self):
self.run_command("compile_translations")
self.run_command("compile_scss")
_install_lib.run(self)


class develop(_develop):
def run(self):
self.run_command("compile_translations")
self.run_command("compile_scss")
_develop.run(self)


setup(name="django-hijack", use_scm_version=True)
setup(
name="django-hijack",
use_scm_version=True,
cmdclass={
"build": build,
"develop": develop,
"install_lib": install_lib,
"compile_translations": compile_translations,
"compile_scss": compile_scss,
},
)

0 comments on commit cca3183

Please sign in to comment.