Skip to content

Commit

Permalink
Merge pull request #39 from alberto-abarzua/fix/ci_naming
Browse files Browse the repository at this point in the history
Fix/ci naming
  • Loading branch information
alberto-abarzua authored Nov 15, 2023
2 parents 4c0555a + a008988 commit 3fbeb4e
Show file tree
Hide file tree
Showing 26 changed files with 388 additions and 113 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/backend-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
workflow_dispatch:

jobs:
build-test:
build-lint:
runs-on: ubuntu-latest
environment: general
env:
Expand All @@ -30,9 +30,19 @@ jobs:

- name: Lint Backend
run: ./manage.py lint --container backend


- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Push Backend Container
if: github.ref == 'refs/heads/main'
run: ./manage.py docker-compose --container backend --op push

- name: Stop and remove containers
if: always()
run: ./manage.py down
run: ./manage.py down --container backend


21 changes: 20 additions & 1 deletion .github/workflows/controller-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
CONTROLLER_WEBSOCKET_PORT: ${{ vars.CONTROLLER_WEBSOCKET_PORT }}
CONTROLLER_SERVER_PORT: ${{ vars.CONTROLLER_SERVER_PORT }}
BACKEND_HTTP_PORT: ${{ vars.BACKEND_HTTP_PORT }}
CONTROLLER_PDM_PUBLISH_PASSWORD: ${{ secrets.CONTROLLER_PDM_PUBLISH_PASSWORD }}
CONTROLLER_PDM_PUBLISH_USERNAME: ${{ secrets.CONTROLLER_PDM_PUBLISH_USERNAME }}
CONTROLLER_PDM_OVERRIDE_VERSION: 'none'
steps:
- name: Check out repository
uses: actions/checkout@v3
Expand All @@ -37,10 +40,26 @@ jobs:

- name: Run Firmware and Controller Tests
run: ./manage.py test

- name: Publish Controller Package
if: github.ref == 'refs/heads/main'
run: ./manage.py publish-controller

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Push Controller Container
if: github.ref == 'refs/heads/main'
run: ./manage.py docker-compose --container controller --op push

- name: Stop and remove containers
if: always()
run: ./manage.py down
run: |
./manage.py down --container controller
./manage.py down --container firmware


Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/firmware-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,19 @@ jobs:
- name: Build Firmware for Linux
run: ./manage.py buildf

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Push Firmware-linux Container
if: github.ref == 'refs/heads/main'
run: ./manage.py docker-compose --container firmware --op push

- name: Stop and remove containers
if: always()
run: ./manage.py down
run: ./manage.py down --container firmware

esp-idf-build:
runs-on: ubuntu-latest
Expand All @@ -50,11 +60,24 @@ jobs:
run: printenv | grep -v "^\(PWD\|SHLVL\|HOME\)" > .env

- name: Build ESP-IDF Container
run: ./manage.py build --container esp-idf
run: ./manage.py build --container esp_idf

- name: Build firmware for ESP32 using ESP-IDF
run: ./manage.py build-esp

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Push esp-idf Container
if: github.ref == 'refs/heads/main'
run: ./manage.py docker-compose --container esp_idf --op push
- name: Stop and remove containers
if: always()
run: ./manage.py down --container esp_idf




42 changes: 20 additions & 22 deletions .github/workflows/frontend-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ on:
push:
paths:
- 'frontend/**'
- 'unity_arm_simulation/**'
workflow_dispatch:

jobs:
build-test:
build-lint:
runs-on: ubuntu-latest
environment: general
env:
Expand All @@ -28,30 +29,27 @@ jobs:
- name: Build frontend container
run: ./manage.py build --container frontend

- name: Build Unity Webgl
run: ./manage.py build --container unity_webgl_server

- name: Lint Frontend
run: ./manage.py lint --container frontend

- name: Stop and remove containers
if: always()
run: ./manage.py down

esp-idf-build:
runs-on: ubuntu-latest
environment: general
env:
ESP_CONTROLLER_SERVER_HOST: ${{ vars.ESP_CONTROLLER_SERVER_HOST }}
ESP_CONTROLLER_SERVER_PORT: ${{ vars.ESP_CONTROLLER_SERVER_PORT }}
ESP_WIFI_SSID: ${{ vars.ESP_WIFI_SSID }}
ESP_WIFI_PASSWORD: ${{ vars.ESP_WIFI_PASSWORD }}
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set Env File
run: printenv | grep -v "^\(PWD\|SHLVL\|HOME\)" > .env
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Esp-idf Build
run: ./manage.py build-esp
- name: Push Frontend Container
if: github.ref == 'refs/heads/main'
run: ./manage.py docker-compose --container frontend --op push


- name: Push Unity Webgl Container
if: github.ref == 'refs/heads/main'
run: ./manage.py docker-compose --container unity_webgl_server --op push


- name: Stop and remove containers
if: always()
run: ./manage.py down --container frontend

3 changes: 3 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ COPY ./pdm.lock ./pdm.lock

COPY . .

RUN pdm install

RUN chmod +x ./entrypoint.sh

EXPOSE 8000

ENTRYPOINT ["/app/entrypoint.sh"]

CMD ["pdm","run","start"]
1 change: 0 additions & 1 deletion backend/controller

This file was deleted.

9 changes: 7 additions & 2 deletions backend/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/bin/sh


echo "Installing dependecies (required for editable mode)"
pdm install --dev
# check if BACKEND_UPDATE_RIBOT_CONTROLLER is set to 'true'
if [ "$BACKEND_UPDATE_RIBOT_CONTROLLER" = "true" ]; then

echo "Updating ribot-controller to latest"
echo "Updating ribot-controller to latest"
pdm update ribot-controller
fi


exec "$@"
14 changes: 8 additions & 6 deletions backend/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
[project]
name = ""
version = ""
description = ""
authors = [
{name = "", email = ""},
]
dependencies = [
"fastapi>=0.101.1",
"uvicorn>=0.23.2",
"numpy>=1.20",
"ribot-controller>=0.3.4",
]
requires-python = ">=3.11"
readme = "README.md"
license = {text = "MIT"}

[tool.pdm.dev-dependencies]
dev = [
"-e file:///${PROJECT_ROOT}/controller#egg=ribot",
"black>=23.11.0",
"isort>=5.12.0",
"flake8>=6.0.0",
Expand All @@ -34,3 +26,8 @@ type_check = "mypy src"
format = {composite = ["isort", "black"]}
lint = {composite = ["pure_lint", "type_check"]}


[mypy]
ignore_missing_imports = "True"
disallow_untyped_defs = "True"
mypy_path = "src"
9 changes: 0 additions & 9 deletions backend/src/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import logging
from contextlib import asynccontextmanager

from fastapi import FastAPI
Expand All @@ -8,14 +7,6 @@
from routers.settings import router as settings_router
from utils.general import start_controller, stop_controller

# class IgnoreEndpointFilter(logging.Filter):
# def filter(self, record: logging.LogRecord) -> bool:
# return "/settings/status/" not in record.getMessage()
#
#
# logging.basicConfig(level=logging.INFO)
# logging.getLogger("uvicorn.access").addFilter(IgnoreEndpointFilter())


@asynccontextmanager
async def controller_lifespan(_: FastAPI): # type: ignore # noqa: ANN201
Expand Down
6 changes: 4 additions & 2 deletions controller/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN pip install --no-cache-dir pdm==2.10
RUN pip install --no-cache-dir pdm==2.10.1

ENV PYTHONPATH "${PYTHONPATH}:/app/src"

COPY pyproject.toml .
COPY pdm.lock .

COPY . .

RUN pdm install


COPY . .

Loading

0 comments on commit 3fbeb4e

Please sign in to comment.