Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 29 additions & 15 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,39 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3.3.0

- uses: actions/setup-python@v4
- uses: actions/setup-python@v4.5.0
with:
python-version: '3.10'

- name: Install and configure Poetry
uses: snok/install-poetry@v1.3.3
with:
version: 1.3.2
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install Python dependencies
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3.2.6
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction

- name: Set env variables
run: |
pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt

- name: Lint python code
run: flake8 --ignore=E501,F401,E402,F811,E731,F403 .

- name: Run django checks
run: ./manage.py check

- name: Check migrations
run: ./manage.py makemigrations --dry-run --check
echo 'FAKE_REDIS=1' >> $GITHUB_ENV
echo 'DEBUG=1' >> $GITHUB_ENV
shell: bash

- name: Run tests
run: FAKE_REDIS=1 DEBUG=1 py.test
run: |
poetry run flake8
poetry run python manage.py check
poetry run python manage.py makemigrations --dry-run --check
DJANGO_SETTINGS_MODULE=incubator.settings FAKE_REDIS=1 DEBUG=1 poetry run py.test
30 changes: 18 additions & 12 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,34 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3.3.0

- uses: actions/setup-python@v4
- uses: actions/setup-python@v4.5.0
with:
python-version: '3.10'

- name: Install and configure Poetry
uses: snok/install-poetry@v1.3.3
with:
version: 1.3.2
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt
poetry install --with prod

- name: Lint python code
run: flake8 --ignore=E501,F401,E402,F811,E731,F403 .
run: poetry run flake8 --ignore=E501,F401,E402,F811,E731,F403 .

- name: Run django checks
run: ./manage.py check
run: poetry run python manage.py check

- name: Check migrations
run: ./manage.py makemigrations --dry-run --check
run: poetry run python manage.py makemigrations --dry-run --check

- name: Run tests
run: FAKE_REDIS=1 DEBUG=1 py.test
run: FAKE_REDIS=1 DEBUG=1 poetry run py.test

docker:
runs-on: ubuntu-20.04
Expand All @@ -45,22 +51,22 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v3.3.0

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
uses: docker/metadata-action@v4.3.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- uses: docker/build-push-action@v2
- uses: docker/build-push-action@v4.0.0
name: Build and push
with:
push: true
Expand Down
50 changes: 21 additions & 29 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,24 @@ The setup you need wildly depends on the OS you are running.
Here are instructions for some common OSes.

<details>
<summary>Ubuntu (or Mint)</summary>

```shell
sudo apt-get install python3-dev python3-setuptools python3-pip
sudo pip3 install virtualenv
```

<summary>Ubuntu (or Mint)</summary>
```shell
sudo apt-get install python3-dev python3-setuptools python3-pip
```
</details>

<details>
<summary>Fedora</summary>

```shell
sudo dnf install python3-devel python3-setuptools python3-virtualenv
```

<summary>Fedora</summary>
```shell
sudo dnf install python3-devel python3-setuptools
```
</details>

<details>
<summary>MacOS</summary>

```shell
brew install python3
pip3 install virtualenv
```

<summary>MacOS</summary>
```shell
brew install python3
```
</details>

## Get the code
Expand All @@ -46,9 +38,8 @@ Now that you have the code we have to install the required Python dependencies.
We will use a virtualenv for this purpose. This allows us to install specific versions of the package for the incubator and avoid messing up with your system packages. If you don't know what is a virtualenv, it might be good to google it a bit or ask about it to members of the hackerspace, they will be happy to help.

```shell
python3 -m venv ve
source ve/bin/activate
pip install -r requirements.txt -r requirements-dev.txt
poetry install
poetry shell
```

The last step is to create an empty database with the correct structure.
Expand All @@ -69,7 +60,7 @@ Now that you are set up, you can fire up the Django web server:
The next time you want to work on this code, you don't have to repeat the whole list of commands we just typed. You only have to activate the virtualenv (you have to activate it once for every new shell you open)

```shell
source ve/bin/activate
poetry shell
```

And then start the server
Expand Down Expand Up @@ -116,15 +107,16 @@ export SQL_PORT=<PORT>

## MQTT backend
```shell
pip install paho-mqtt
poetry add paho-mqtt
```


## Adding new requirements

To add a requirement, add it with no version constraint (or as little as needed)
to `requirements.in` (or `requirements-dev.in` or `requirements-prod.in` if it is needed only in prod or dev). Then run `pip-compile` (or `pip-compile requirements-dev.in` or `pip-compile requirements-prod.in`).

Never edit a `requirements-*.txt` file by hand !
To install a new requirements, simply run `poetry add <requirement name>`. This will automatically install the requirement, and save it in the `pyproject.toml` file. In order to add a development only requirement, type `poetry add --dev <requirement name>`.

In addition, we use [Dependabot](https://dependabot.com/) who will automatically submit Pull Requests to upgrade the python packages when a new version is available. This will only change the `requirement-*.txt`.

## Installing the project without the development requirements

In order to install the project without the development requirements (e.g. while deploying the website), replace the `poetry install` command with `poetry install --no-dev`.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ But if you want to have try, please do !

# Development guide

This is a typical Django project, the usual `virtualenv`, `requirements.txt`, ... apply.
This project uses poetry as package manager. To install the requirements for development, you first need to install poetry :
```
pip install -U poetry
```
Then you will be able to create a virtual environment for the project by typing `poetry install`, and then `poetry shell` in order to spawn a shell within the new environment.

**:warning: You will need to type `exit` in order to leave the poetry virtual environment instead of the classic `deactivate` :warning:**

Please have a look at [`DEVELOPMENT.md`](DEVELOPMENT.md) for an in-depth installation guide as well as help for common tasks.

Expand Down
15 changes: 0 additions & 15 deletions fabfile.py

This file was deleted.

Loading