Files
Ikraam GhoorandClaude Opus 4.5 bcb82a2b95 Updated image processing to use ImageMagick
Necessary because GraphicsMagick cannot output true 2-bit grayscale PNG
files. TRMNL firmware only supports 1-2 bit PNG depth, and GraphicsMagick
always outputs 8-bit regardless of settings.

ImageMagick properly supports the -depth flag for low bit depth output.
The gm package supports both backends via subClass({ imageMagick: true }).

Changes:
- Switched Dockerfile dependency from graphicsmagick to imagemagick
- Updated dithering strategies to use raw .out() commands for IM7 compat
- Added proper bit depth handling for PNG (1-bit, 2-bit, 4-bit)
- Fixed BMP 1-bit output using -monochrome flag
- Updated AppArmor profile with ImageMagick binary paths
- Replaced all GraphicsMagick references in documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 16:49:26 +00:00

140 lines
4.0 KiB
YAML

name: CI
on:
push:
branches: [main, develop, feature/*]
pull_request:
branches: [main, develop]
env:
REGISTRY: ghcr.io
CACHE_REPO: ${{ github.repository_owner }}/trmnl-ha-cache
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Cache Bun dependencies
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: bun-${{ runner.os }}-${{ hashFiles('trmnl-ha/ha-trmnl/bun.lock') }}
restore-keys: bun-${{ runner.os }}-
- name: Install dependencies
working-directory: trmnl-ha/ha-trmnl
run: bun install
- name: Run ESLint
working-directory: trmnl-ha/ha-trmnl
run: bun run lint
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Cache Bun dependencies
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: bun-${{ runner.os }}-${{ hashFiles('trmnl-ha/ha-trmnl/bun.lock') }}
restore-keys: bun-${{ runner.os }}-
- name: Install ImageMagick
run: sudo apt-get update && sudo apt-get install -y imagemagick
- name: Install dependencies
working-directory: trmnl-ha/ha-trmnl
run: bun install
- name: Create test options file
working-directory: trmnl-ha/ha-trmnl
run: cp options-dev.json.example options-dev.json
- name: Run unit tests
working-directory: trmnl-ha/ha-trmnl
run: bun test tests/unit
- name: Run integration tests
working-directory: trmnl-ha/ha-trmnl
run: MOCK_HA=true bun test tests/integration
- name: Check coverage
working-directory: trmnl-ha/ha-trmnl
run: bun test --coverage
build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [lint, test]
# NOTE: Write to packages needed for registry cache on push to main
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- platform: linux/amd64
tag: amd64
- platform: linux/arm64
tag: arm64
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Login to GHCR for registry cache (read for PRs, write for push)
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# NOTE: Registry cache is branch-agnostic - PR builds reuse main's cache!
# On push to main: update the shared registry cache
# On PR: read from registry cache, write to GHA cache (branch-scoped fallback)
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: trmnl-ha
platforms: ${{ matrix.platform }}
push: false
load: true
tags: trmnl-ha:test-${{ matrix.tag }}
cache-from: |
type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_REPO }}:${{ matrix.tag }}
type=gha,scope=build-${{ matrix.tag }}
cache-to: ${{ github.event_name == 'push' && format('type=registry,ref={0}/{1}:{2},mode=max', env.REGISTRY, env.CACHE_REPO, matrix.tag) || format('type=gha,mode=max,scope=build-{0}', matrix.tag) }}
provenance: false
- name: Verify Bun installation in image
run: docker run --rm trmnl-ha:test-${{ matrix.tag }} bun --version
- name: Test image can start
run: |
docker run -d --name test-container trmnl-ha:test-${{ matrix.tag }}
sleep 5
docker logs test-container
docker stop test-container
docker rm test-container