Skip to content

Commit

Permalink
Merge pull request #595 from BrewBlox/develop
Browse files Browse the repository at this point in the history
Edge release
  • Loading branch information
steersbob authored Jan 17, 2024
2 parents 8d75530 + 744ae05 commit 99eef3f
Show file tree
Hide file tree
Showing 149 changed files with 7,798 additions and 8,422 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: docker/setup-buildx-action@v2
- uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: "3.11"

- name: (Service) Image metadata
id: service_meta
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@ eeprom.bin

# Build files
firmware/

.appenv
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "python",
"request": "attach",
"port": 5678,
"host": "localhost",
"host": "buildbot32.local",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
Expand All @@ -16,4 +16,4 @@
}
],
"compounds": []
}
}
5 changes: 1 addition & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"python.defaultInterpreterPath": ".venv/bin/python",
"python.terminal.activateEnvInCurrentTerminal": true,
"python.terminal.activateEnvironment": true,
"python.linting.flake8Enabled": true,
"python.linting.pylintEnabled": false,
"python.testing.pytestArgs": [
"--no-cov",
"."
Expand All @@ -17,6 +15,5 @@
],
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
},
"python.formatting.provider": "none"
}
}
76 changes: 48 additions & 28 deletions Dockerfile.service
Original file line number Diff line number Diff line change
@@ -1,43 +1,63 @@
FROM python:3.9-bullseye as base
FROM python:3.11-bookworm as base

ENV PIP_EXTRA_INDEX_URL=https://www.piwheels.org/simple
ENV PIP_FIND_LINKS=/wheeley
ENV VENV=/app/.venv
ENV PATH="$VENV/bin:$PATH"

COPY ./dist /app/dist
COPY ./firmware /app/firmware

RUN set -ex \
&& mkdir /wheeley \
&& pip3 install --upgrade pip wheel setuptools \
&& pip3 wheel --wheel-dir=/wheeley -r /app/dist/requirements.txt \
&& pip3 wheel --wheel-dir=/wheeley /app/dist/*.tar.gz \
&& ARCH="$(dpkg --print-architecture)" \
&& if [ "${ARCH}" = "amd64" ]; then OTHER_SIM='brewblox-{arm32,arm64}.sim'; fi \
&& if [ "${ARCH}" = "armhf" ]; then OTHER_SIM='brewblox-{amd64,arm64}.sim'; fi \
&& if [ "${ARCH}" = "arm64" ]; then OTHER_SIM='brewblox-{amd64,arm32}.sim'; fi \
&& bash -c "rm /app/firmware/${OTHER_SIM}" \
&& rm /app/firmware/*.elf

FROM python:3.9-slim-bullseye
RUN <<EOF
set -ex

mkdir /wheeley
python3 -m venv $VENV
pip3 install --upgrade pip wheel setuptools
pip3 wheel --wheel-dir=/wheeley -r /app/dist/requirements.txt
pip3 wheel --wheel-dir=/wheeley /app/dist/*.tar.gz
EOF

RUN <<EOF bash
set -ex

cd /app/firmware
ARCH="$(dpkg --print-architecture)"
if [ "\${ARCH}" = "amd64" ]; then
rm ./*.elf ./brewblox-{arm32,arm64}.sim
elif [ "\${ARCH}" = "armhf" ]; then
rm ./*.elf ./brewblox-{amd64,arm64}.sim
elif [ "\${ARCH}" = "arm64" ]; then
rm ./*.elf ./brewblox-{amd64,arm32}.sim
fi
EOF

FROM python:3.11-slim-bookworm
EXPOSE 5000
WORKDIR /app

ARG service_info=UNKNOWN
ENV SERVICE_INFO=${service_info}

RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
socat \
usbutils \
&& rm -rf /var/lib/apt/lists/*
ENV PIP_FIND_LINKS=/wheeley
ENV VENV=/app/.venv
ENV PATH="$VENV/bin:$PATH"

COPY --from=base /wheeley /wheeley
COPY --from=base /app/firmware /app/firmware
COPY ./parse_appenv.py ./parse_appenv.py
COPY ./entrypoint.sh ./entrypoint.sh

RUN <<EOF
set -ex

apt-get update
apt-get install -y --no-install-recommends \
socat \
usbutils
rm -rf /var/cache/apt/archives /var/lib/apt/lists

RUN set -ex \
&& pip3 install --no-index --find-links=/wheeley brewblox-devcon-spark \
&& pip3 freeze \
&& rm -rf /wheeley
python3 -m venv $VENV
pip3 install --no-index brewblox_devcon_spark
pip3 freeze
rm -rf /wheeley
EOF

ENTRYPOINT ["python3", "-m", "brewblox_devcon_spark"]
ENTRYPOINT ["bash", "./entrypoint.sh"]
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ This includes USB/TCP communication with the controller, but also encoding, deco

## Installation

To set up the development environment, follow the instructions at <https://github.com/BrewBlox/brewblox-boilerplate#readme>.
To set up the development environment, follow the instructions at <https://brewblox.com/dev/service/python_env.html>.

Integration tests run against the firmware simulator.
## Tests

**If you run Ubuntu 22.04, and your tests fail, you may need to manually install libssl 1.1**.
Integration tests run against the firmware simulator. This firmware is downloaded, but not committed.
To ensure you have the latest firmware, run `invoke download-firmware`.
This also happens during `invoke update-firmware`.

```sh
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
```
During tests, you may need to kill the pytest process.
This will cause it to skip test teardown, and leave leftover containers and processes. \
To remove these leftovers, run `invoke testclean`.

## Firmware

Expand All @@ -33,7 +34,8 @@ The brewblox-proto repository only contains .proto files. The associated pb2.py

Firmware dependency management is handled by [invoke](https://docs.pyinvoke.org/en/stable/index.html) commands, defined in `tasks.py`:

`invoke update-firmware` fetches the latest firmware.ini file for a given firmware build (*develop* by default), checks out the associated brewblox-proto commit for the submodule, and calls both `compile-proto.sh` and `download-firmware.sh`.
`invoke update-firmware` fetches the latest firmware.ini file for a given firmware build (*develop* by default),
checks out the associated brewblox-proto commit for the submodule, and then calls `compile-proto` and `download-firmware`.

`invoke compile-proto` compiles .proto files found in the proto submodule into _pb2.py python files.
The_pb2.py files are committed into version control.
Expand Down
2 changes: 1 addition & 1 deletion brewblox-proto
172 changes: 0 additions & 172 deletions brewblox_devcon_spark/__main__.py

This file was deleted.

3 changes: 0 additions & 3 deletions brewblox_devcon_spark/api/__init__.py

This file was deleted.

Loading

0 comments on commit 99eef3f

Please sign in to comment.