Skip to content

Commit

Permalink
feat(ci): automatically test podman-compose.yml
Browse files Browse the repository at this point in the history
Make sure it's easy for other people to run their own server.

Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
aparcar committed Feb 9, 2025
1 parent 7e0e177 commit 0c204b4
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 44 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/podman.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Test podman-compose.yml

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
TERM: xterm-color
PY_COLORS: 1
LOG_LEVEL: DEBUG

jobs:
build:
runs-on: ubuntu-latest

name: podman-compose integration test

steps:
- uses: actions/checkout@v4

- name: Install ImageBuilder prereqs
run: sudo apt-get install -y podman-compose jq

- name: Build the containers
run: |
podman-compose build
- name: Start the containers
run: |
podman system service --time=0 unix:///tmp/podman.sock &
cp misc/asu.env .env
podman-compose up -d
- name: Let the containers start
run: sleep 30

- name: Test startup
run: |
queue_length="$(curl -s http://localhost:8000/api/v1/stats | jq .queue_length)"
[ "$queue_length" -eq 0 ] || exit 1
- name: Test build
run: |
curl 'http://localhost:8000/api/v1/build' \
--request 'POST' \
--header 'Content-Type: application/json' \
--data @ tests/ci/openwrt-one-24.10.0.json > build_response.json
status_code=$(jq -r '.status' build_response.json)
[ "$status_code" -eq 202 ] || exit 1
sleep 60
curl 'http://localhost:8000/api/v1/build' \
--request 'POST' \
--header 'Content-Type: application/json' \
--data @ tests/ci/openwrt-one-24.10.0.json > build_response.json
status_code=$(jq -r '.status' build_response.json)
[ "$status_code" -eq 200 ] || exit 1
2 changes: 0 additions & 2 deletions asu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
app = FastAPI()
app.include_router(api.router, prefix="/api/v1")

(settings.public_path / "store").mkdir(parents=True, exist_ok=True)

app.mount("/store", StaticFiles(directory=settings.public_path / "store"), name="store")
app.mount("/static", StaticFiles(directory=base_path / "static"), name="static")

Expand Down
12 changes: 6 additions & 6 deletions misc/asu.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ALLOW_DEFAULTS=1
CONTAINER_HOST=unix:///run/user/1000/podman/podman.sock
CONTAINER_SOCK=/run/user/1000/podman/podman.sock
PUBLIC_PATH=/home/openwrt/public/
CONTAINER_HOST=unix:///tmp/podman.sock
CONTAINER_SOCK=/tmp/podman.sock
PUBLIC_PATH=/tmp/public/
REDIS_URL=redis://redis/
SERVER_STATS=stats
SQUID_CACHE=1
# SERVER_STATS=stats
# SQUID_CACHE=1
# ALLOW_DEFAULTS=1
78 changes: 42 additions & 36 deletions podman-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,48 @@ version: "2"

volumes:
redis:
grafana-storage:
# grafana-storage:

services:
server:
image: "docker.io/openwrt/asu:latest"
build:
context: .
dockerfile: Containerfile
restart: unless-stopped
command: uvicorn --host 0.0.0.0 asu.main:app
env_file: asu.env
env_file: .env
volumes:
- $PUBLIC_PATH:$PUBLIC_PATH:ro
- $PUBLIC_PATH/store:$PUBLIC_PATH/store:ro
ports:
- "127.0.0.1:8000:8000"
depends_on:
- redis

worker:
image: "docker.io/openwrt/asu:latest"
build:
context: .
dockerfile: Containerfile
restart: unless-stopped
command: rqworker --logging_level INFO
env_file: asu.env
env_file: .env
volumes:
- $PUBLIC_PATH:$PUBLIC_PATH:rw
- $CONTAINER_SOCK:$CONTAINER_SOCK:rw
depends_on:
- redis

worker2:
image: "docker.io/openwrt/asu:latest"
restart: unless-stopped
command: rqworker --logging_level INFO
env_file: asu.env
volumes:
- $PUBLIC_PATH:$PUBLIC_PATH:rw
- $CONTAINER_SOCK:$CONTAINER_SOCK:rw
depends_on:
- redis
# worker2:
# image: "docker.io/openwrt/asu:latest"
# restart: unless-stopped
# command: rqworker --logging_level INFO
# env_file: .env
# volumes:
# - $PUBLIC_PATH:$PUBLIC_PATH:rw
# - $CONTAINER_SOCK:$CONTAINER_SOCK:rw
# depends_on:
# - redis

redis:
image: "docker.io/redis/redis-stack-server"
Expand All @@ -47,26 +53,26 @@ services:
ports:
- "127.0.0.1:6379:6379"

squid:
image: "docker.io/ubuntu/squid:latest"
restart: unless-stopped
ports:
- "127.0.0.1:3128:3128"
volumes:
- ".squid.conf:/etc/squid/conf.d/snippet.conf:ro"
- "./squid/:/var/spool/squid/:rw"
# squid:
# image: "docker.io/ubuntu/squid:latest"
# restart: unless-stopped
# ports:
# - "127.0.0.1:3128:3128"
# volumes:
# - ".squid.conf:/etc/squid/conf.d/snippet.conf:ro"
# - "./squid/:/var/spool/squid/:rw"

grafana:
image: docker.io/grafana/grafana-oss
container_name: grafana
restart: unless-stopped
ports:
- "127.0.0.1:3000:3000"
depends_on:
- redis
environment:
GF_SERVER_DOMAIN: sysupgrade.openwrt.org
GF_SERVER_ROOT_URL: https://sysupgrade.openwrt.org/stats/
GF_SERVER_SERVE_FROM_SUB_PATH: "true"
volumes:
- grafana-storage:/var/lib/grafana
# grafana:
# image: docker.io/grafana/grafana-oss
# container_name: grafana
# restart: unless-stopped
# ports:
# - "127.0.0.1:3000:3000"
# depends_on:
# - redis
# environment:
# GF_SERVER_DOMAIN: sysupgrade.openwrt.org
# GF_SERVER_ROOT_URL: https://sysupgrade.openwrt.org/stats/
# GF_SERVER_SERVE_FROM_SUB_PATH: "true"
# volumes:
# - grafana-storage:/var/lib/grafana
50 changes: 50 additions & 0 deletions tests/ci/openwrt-one-24.10.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"profile": "openwrt_one",
"target": "mediatek/filogic",
"packages": [
"base-files",
"ca-bundle",
"dnsmasq",
"dropbear",
"firewall4",
"fitblk",
"fstools",
"kmod-crypto-hw-safexcel",
"kmod-gpio-button-hotplug",
"kmod-leds-gpio",
"kmod-nft-offload",
"kmod-phy-aquantia",
"libc",
"libgcc",
"libustream-mbedtls",
"logd",
"mtd",
"netifd",
"nftables",
"odhcp6c",
"odhcpd-ipv6only",
"opkg",
"ppp",
"ppp-mod-pppoe",
"procd-ujail",
"uboot-envtools",
"uci",
"uclient-fetch",
"urandom-seed",
"urngd",
"wpad-basic-mbedtls",
"kmod-mt7915e",
"kmod-mt7981-firmware",
"mt7981-wo-firmware",
"kmod-rtc-pcf8563",
"kmod-usb3",
"kmod-nvme",
"kmod-phy-airoha-en8811h",
"luci"
],
"defaults": "",
"version_code": "r28427-6df0e3d02a",
"version": "24.10.0",
"diff_packages": true,
"client": "ci"
}

0 comments on commit 0c204b4

Please sign in to comment.