Skip to content

Commit

Permalink
Update contributing guide from saleor repo
Browse files Browse the repository at this point in the history
  • Loading branch information
witoszekdev committed Feb 12, 2025
1 parent 1babfd6 commit e951536
Showing 1 changed file with 108 additions and 0 deletions.
108 changes: 108 additions & 0 deletions docs/developer/community/contributing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,111 @@ IDE instructions:

- [Codespaces](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers)

### Running Saleor locally with database and additional services in docker

Install & setup prerequisites via homebrew:

```shell
brew install libmagic
brew install pyenv

pyenv install 3.12

# optionally set python globally
pyenv global 3.12

brew install pipx
pipx install poetry
```

Clone this [repository](https://github.com/saleor/saleor) and setup database and additional services in docker:

```shell
cd .devcontainer
docker compose up db dashboard redis mailpit
```

If you didn’t set python version globally set [pyenv](https://github.com/pyenv/pyenv) local version:

```shell
pyenv local 3.12
```

To create virtualenv and install dependencies run in root of the repository:

Check warning on line 65 in docs/developer/community/contributing.mdx

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (virtualenv)

```shell
poetry sync
```

After installation activate virtualenv:

Check warning on line 71 in docs/developer/community/contributing.mdx

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (virtualenv)

```shell
eval $(poetry env activate)
```

See [poetry docs](https://python-poetry.org/docs/managing-environments/#bash-csh-zsh) for all supported shells.

> [!TIP]
> Your shell prompt should have virtualenv information available and should look similar to this:

Check warning on line 80 in docs/developer/community/contributing.mdx

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (virtualenv)
> `(saleor-py3.12) ~/D/saleor %`
Install pre commit hooks:

```shell
pre-commit install
```

Set environment variables for your setup. You can use [direnv](https://direnv.net/) to do this automatically.
Create `.envrc` file:

```shell
export CELERY_BROKER_URL=redis://localhost:6379/1
export DATABASE_URL=postgres://saleor:saleor@localhost/saleor
export DEFAULT_FROM_EMAIL=noreply@example.com
export EMAIL_URL=smtp://localhost:1025
export SECRET_KEY=changeme
export DEFAULT_CHANNEL_SLUG=default-channel
export HTTP_IP_FILTER_ALLOW_LOOPBACK_IPS=True
export DASHBOARD_URL=http://localhost:9000/
```

Run command to set variables from this file:

```shell
direnv allow
```

You are ready to go 🎉.

### Common commands

To start server:

```shell
uvicorn saleor.asgi:application --reload
```

To start Celery worker:

```shell
celery --app=saleor.celeryconf:app worker --beat
```

To run database migrations:

```shell
python manage.py migrate
```

To populate database with example data and create the admin user:

```shell
python manage.py populatedb --createsuperuser
```

*Note that `--createsuperuser` argument creates an admin account for `admin@example.com` with the password set to `admin`.*


## Managing dependencies

### Poetry
Expand Down Expand Up @@ -226,6 +331,9 @@ pre-commit install

For more information on how it works, see the `.pre-commit-config.yaml` configuration file.

> [!NOTE]
> Running `git commit` for the first time might take a while, since all dependencnies will be setting up.

Check warning on line 335 in docs/developer/community/contributing.mdx

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (dependencnies)
Saleor has a strict formatting policy enforced by the [black formatting tool](https://github.com/python/black).

Module names should make their purpose obvious. Avoid generic file names such as `utils.py`.
Expand Down

0 comments on commit e951536

Please # to comment.