Skip to content
Merged
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
33 changes: 0 additions & 33 deletions .ansible-lint

This file was deleted.

15 changes: 0 additions & 15 deletions .ansibleignore

This file was deleted.

32 changes: 0 additions & 32 deletions .github/workflows/ansible-role-ci.yml

This file was deleted.

24 changes: 16 additions & 8 deletions .github/workflows/application-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,36 @@ name: Application CI

on:
push:
branches:
- main
- develop
branches: [ main ]
pull_request:

jobs:
test:
ci:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install ruff mypy pytest

- name: Run tests
run: pytest
- name: Lint (ruff)
run: ruff check .

- name: Typecheck (mypy)
run: mypy app

- name: Test (pytest)
run: pytest -q

- name: Build container
run: docker build -t pi-log:ci .
11 changes: 0 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,3 @@ __pycache__/
# Pi-specific temp files
*.swp
*.swo

# ================================
# Ansible
# ================================
# Local facts, cache, and retry files
*.retry
.cache/
.fact_cache/
.ansible/
ansible/.ansible/
ansible/collections/
26 changes: 0 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,6 @@ repos:
- id: yamllint
args: ["-c", "yamllint.yml"]

# -----------------------------
# Ansible linting (pi-log)
# -----------------------------
- repo: https://github.com/ansible/ansible-lint
rev: v24.2.0
hooks:
- id: ansible-lint
name: ansible-lint (pi-log)
files: ^ansible/
stages: [commit]
additional_dependencies:
- ansible-core
- ansible
- ansible-lint
- ansible-compat
- ansible-pygments

- repo: local
hooks:
- id: install-ansible-collections
name: Install Ansible Galaxy collections for linting
entry: bash -c "ansible-galaxy collection install ansible.posix community.general"
language: system
pass_filenames: false
stages: [commit]

# -----------------------------
# Optional Python formatting
# -----------------------------
Expand Down
74 changes: 22 additions & 52 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
# filename: Makefile
# ========================================================================
# Beamwarden pi-log — Unified Makefile
# Python Dev • Local Ingestion • Docker • Ansible • Pi Ops
# ========================================================================
# This Makefile provides a single, consistent interface for:
# - Local development (venv, lint, typecheck, tests)
# - Running the ingestion agent locally (via run.py)
# - Building + pushing the container image
# - Deploying to the Raspberry Pi via Ansible
# - Managing the pi-log systemd service on the Pi
# - Health checks, logs, and maintenance
# Beamwarden pi-log — Unified Makefile (Application Only)
# Python Dev • Local Ingestion • Docker Build/Push • Pi Ops via Quasar
# ========================================================================

# ------------------------------------------------------------------------
Expand All @@ -20,10 +12,6 @@ PI_HOST := beamrider-0001.local
PI_USER := jeb
SERVICE := pi-log

ANSIBLE_DIR := ansible
INVENTORY := $(ANSIBLE_DIR)/inventory
PLAYBOOK := $(ANSIBLE_DIR)/deploy.yml

IMAGE := ghcr.io/beamwarden/pi-log
TAG := latest

Expand Down Expand Up @@ -81,12 +69,15 @@ clean: ## Remove venv + Python cache files
find . -type d -name "__pycache__" -exec rm -rf {} +
find . -type f -name "*.pyc" -delete

clean-pytest:
rm -rf .pytest_cache

# ------------------------------------------------------------------------
# Local Ingestion Agent (run.py + config.toml)
# ------------------------------------------------------------------------

run: check-venv ## Run ingestion agent locally (via scripts/run_local.sh)
./scripts/run_local.sh
run: check-venv ## Run ingestion agent locally
$(VENV)/bin/python run.py

dev-run: run ## Alias for local ingestion run

Expand Down Expand Up @@ -115,7 +106,7 @@ ci: clean-pyc check-venv ## Full local CI (lint + typecheck + tests)
@echo "✔ Local CI passed"

# ------------------------------------------------------------------------
# Docker Build + Push
# Docker Build + Push + Release
# ------------------------------------------------------------------------

build: ## Build the pi-log container image
Expand All @@ -124,6 +115,13 @@ build: ## Build the pi-log container image
push: ## Push the container image to GHCR
docker push $(IMAGE):$(TAG)

publish: build push ## Build and push the container image
@echo "✔ Image built and pushed to GHCR"

# Release is now build+push only; deployment is Quasar's job
release: publish ## Full release (container only)
@echo "✔ Container release completed"

run-container: ## Run the container locally (binds config.toml + serial)
docker run --rm -it \
--device /dev/ttyUSB0 \
Expand All @@ -134,33 +132,17 @@ logs-container: ## Tail logs from a locally running container
docker logs -f pi-log

# ------------------------------------------------------------------------
# Ansible Deployment
# ------------------------------------------------------------------------

check-ansible: ## Validate Ansible syntax, inventory, lint, and dry-run
ansible-playbook $(PLAYBOOK) --syntax-check
ansible-inventory --list >/dev/null
ansible-lint $(ANSIBLE_DIR)
ansible-playbook $(PLAYBOOK) --check

deploy: ## Deploy to Raspberry Pi via Ansible
ansible-playbook $(PLAYBOOK)

ansible-deploy: ## Run ansible/Makefile deploy
cd ansible && make deploy

# ------------------------------------------------------------------------
# Pi Service Management
# Pi Service Management (via SSH)
# ------------------------------------------------------------------------

restart: ## Restart pi-log service on the Pi
ansible beamrider-0001 -m systemd -a "name=$(SERVICE) state=restarted"
ssh $(PI_USER)@$(PI_HOST) "sudo systemctl restart $(SERVICE)"

start: ## Start pi-log service
ansible beamrider-0001 -m systemd -a "name=$(SERVICE) state=started"
ssh $(PI_USER)@$(PI_HOST) "sudo systemctl start $(SERVICE)"

stop: ## Stop pi-log service
ansible beamrider-0001 -m systemd -a "name=$(SERVICE) state=stopped"
ssh $(PI_USER)@$(PI_HOST) "sudo systemctl stop $(SERVICE)"

status: ## Show pi-log systemd status
ssh $(PI_USER)@$(PI_HOST) "systemctl status $(SERVICE)"
Expand All @@ -172,17 +154,14 @@ tail: ## Follow live logs from the Pi
ssh $(PI_USER)@$(PI_HOST) "sudo journalctl -u $(SERVICE) -f"

db-shell: ## Open SQLite shell on the Pi
ssh $(PI_USER)@$(PI_HOST) "sudo sqlite3 /opt/pi-log/readings.db"
ssh $(PI_USER)@$(PI_HOST) "sudo sqlite3 /var/lib/pi-log/readings.db"

# ------------------------------------------------------------------------
# Pi Health + Maintenance
# ------------------------------------------------------------------------

ping: ## Ping the Raspberry Pi via Ansible
ansible beamrider-0001 -m ping

hosts: ## Show parsed Ansible inventory
ansible-inventory --list
ping: ## Ping the Raspberry Pi
ssh $(PI_USER)@$(PI_HOST) "echo ping"

ssh: ## SSH into the Raspberry Pi
ssh $(PI_USER)@$(PI_HOST)
Expand All @@ -191,16 +170,7 @@ doctor: ## Full environment + Pi health checks
@echo "Checking Python..."; python3 --version; echo ""
@echo "Checking virtual environment..."; \
[ -d ".venv" ] && echo "venv OK" || echo "venv missing"; echo ""
@echo "Checking Python dependencies..."; $(VENV)/bin/pip --version; echo ""
@echo "Checking Ansible..."; ansible --version; \
ansible-inventory --list >/dev/null && echo "Inventory OK"; echo ""
@echo "Checking SSH connectivity..."; \
ssh -o BatchMode=yes -o ConnectTimeout=5 $(PI_USER)@$(PI_HOST) "echo SSH OK" || echo "SSH FAILED"; echo ""
@echo "Checking systemd service..."; \
ssh $(PI_USER)@$(PI_HOST) "systemctl is-active $(SERVICE)" || true

reset-pi: ## Wipe /opt/pi-log on the Pi and redeploy
ssh $(PI_USER)@$(PI_HOST) "sudo systemctl stop $(SERVICE) || true"
ssh $(PI_USER)@$(PI_HOST) "sudo rm -rf /opt/pi-log/*"
ansible-playbook $(PLAYBOOK)
ssh $(PI_USER)@$(PI_HOST) "sudo systemctl restart $(SERVICE)"
Loading