diff --git a/.github/workflows/podman.yml b/.github/workflows/podman.yml new file mode 100644 index 00000000..5a5b6714 --- /dev/null +++ b/.github/workflows/podman.yml @@ -0,0 +1,61 @@ +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: | + cp misc/asu.env .env + podman-compose up -d + + - name: Let the containers start + run: sleep 10 + + - 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 30 + + 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 diff --git a/misc/asu.env b/misc/asu.env index 00299577..485e178a 100644 --- a/misc/asu.env +++ b/misc/asu.env @@ -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/ +PUBLIC_PATH=/tmp/public/ REDIS_URL=redis://redis/ -SERVER_STATS=stats -SQUID_CACHE=1 +# SERVER_STATS=stats +# SQUID_CACHE=1 +# ALLOW_DEFAULTS=1 diff --git a/podman-compose.yml b/podman-compose.yml index fcfafd9d..cf171e1d 100644 --- a/podman-compose.yml +++ b/podman-compose.yml @@ -2,14 +2,17 @@ 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 ports: @@ -19,25 +22,28 @@ services: 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" @@ -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 diff --git a/tests/ci/openwrt-one-24.10.0.json b/tests/ci/openwrt-one-24.10.0.json new file mode 100644 index 00000000..5893c85d --- /dev/null +++ b/tests/ci/openwrt-one-24.10.0.json @@ -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" +}