Skip to content

Commit

Permalink
use hatch like in asyncz (#308)
Browse files Browse the repository at this point in the history
* switch to hatch
* remove makefile and a2wsgi from dev extra
  • Loading branch information
devkral authored May 2, 2024
1 parent 1d675d2 commit 238d501
Show file tree
Hide file tree
Showing 20 changed files with 98 additions and 421 deletions.
11 changes: 0 additions & 11 deletions .flake8

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
- uses: "actions/setup-python@v5"
with:
python-version: 3.8
- name: "Install dependencies"
run: "scripts/install"
- name: Install build dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install build twine
run: pip install hatch
- name: "Build package"
run: "scripts/build"
run: "hatch build"
- name: "Build docs"
run: "hatch run docs:build"
- name: "Publish to PyPI"
run: "scripts/release"
env:
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ jobs:
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test-v02
- name: "Install dependencies"
if: steps.cache.outputs.cache-hit != 'true'
run: "scripts/install"
- name: "Run linting"
run: "scripts/lint"
run: "pip install hatch"
- name: "Run linting checks"
run: "hatch run lint"
# - name: "Run typing checks"
# run: "hatch run test:check_types"
- name: "Run tests"
env:
DATABASE_URI: "mongodb://root:mongoadmin@localhost:27017"
run: "scripts/test"
run: "hatch run test:test"
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# See https://pre-commit.com for more information.
# See https://pre-commit.com/hooks.html for more hooks.
default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand All @@ -26,11 +24,6 @@ repos:
hooks:
- id: ruff
args: ["--fix", "--line-length=99"]
- repo: https://github.com/psf/black
rev: 24.4.0
hooks:
- id: black
args: ["--line-length=99"]
ci:
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate
53 changes: 0 additions & 53 deletions Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ services:
POSTGRES_DB: "esmerald"
expose:
- "5432"
volumes:
- "esmerald:/var/lib/postgresql/data"
command: >-
--jit=false
ports:
Expand All @@ -33,8 +31,6 @@ services:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: mongoadmin
MONGO_INITDB_DATABASE: mongodb
volumes:
- "mongo_esmerald_db_data:/data/db"
expose:
- 27017
ports:
Expand All @@ -52,9 +48,3 @@ services:
ME_CONFIG_MONGODB_ADMINPASSWORD: mongoadmin
ME_CONFIG_BASICAUTH_USERNAME: admin
ME_CONFIG_BASICAUTH_PASSWORD: password

volumes:
esmerald:
external: true
mongo_esmerald_db_data:
external: true
93 changes: 30 additions & 63 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,109 +47,76 @@ $ git clone https://github.com/YOUR-USERNAME/esmerald

### Install the project dependencies

=== "Linux, macOS"
```shell
$ cd esmerald
$ scripts/install
```

=== "Windows"
```powershell
$ cd esmerald
$ scripts\install.ps1
```
Not necessary because the dependencies are automatically installed by hatch.
But if environments should be pre-initialized it can be done with `hatch env`

```shell
$ cd esmerald
$ hatch env create
$ hatch env create test
$ hatch env create docs
```

### Enable pre-commit

The project comes with a pre-commit hook configuration. To enable it, just run inside the clone:

```shell
$ pre-commit
$ pre-commit install
```

### Run the tests

To run the tests, use:

=== "Linux, macOS"

```shell
$ scripts/test
```

=== "Windows"

```powershell
$ scripts\test.ps1
```
```shell
$ hatch run test:test
```

Because Esmerald uses pytest, any additional arguments will be passed. More info within the
[pytest documentation](https://docs.pytest.org/en/latest/how-to/usage.html)

For example, to run a single test_script:

=== "Linux, macOS"
```shell
$ scripts/test tests/test_apiviews.py
```

=== "Windows"
```powershell
$ scripts\test tests\test_apiviews.py
```
```shell
$ hatch run test:test tests/test_apiviews.py
```

To run the linting, use:

=== "Linux, macOS"
```shell
$ scripts/lint
```

=== "Windows"
```powershell
$ scripts\lint.ps1
```
```shell
$ hatch run lint
```

### Documentation

Improving the documentation is quite easy and it is placed inside the `esmerald/docs` folder.

To start the docs, run:

=== "Linux, macOS"
```shell
$ scripts/docs
```

=== "Windows"
```powershell
$ scripts\docs.ps1
```
```shell
$ hatch run docs:serve
```

## Building Esmerald

To build a package locally, run:

=== "Linux, macOS"
```shell
$ scripts/build
```

=== "Windows"
```shell
$ scripts\build
```
```shell
$ hatch build
```


Alternatively running:

=== "Linux, macOS"
```
$ scripts/install
```
=== "Windows"
```
$ scripts\install.ps1
```

```shell
$ hatch shell
```

It will install the requirements and create a local build in your virtual environment.

Expand Down
Loading

0 comments on commit 238d501

Please sign in to comment.