name: CI on: workflow_dispatch: push: branches: [main, master] pull_request: branches: [main, master] jobs: lint: name: Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Lua uses: leafo/gh-actions-lua@v12 - name: Setup LuaRocks uses: leafo/gh-actions-luarocks@v6 - name: Install luacheck run: luarocks install luacheck - name: Luacheck devices-api run: luacheck devices-api --codes continue-on-error: true - name: Luacheck devices-worker run: luacheck devices-worker --codes continue-on-error: true - name: Setup Deno uses: denoland/setup-deno@v2 with: deno-version: v2 - name: Deno lint frontend run: cd frontend/alpinejs && deno lint main.ts continue-on-error: true build: name: Build runs-on: ubuntu-latest needs: lint steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build API image uses: docker/build-push-action@v6 with: context: ./devices-api push: false load: true tags: handheld-devices-api:${{ github.sha }} - name: Build worker image uses: docker/build-push-action@v6 with: context: ./devices-worker push: false load: true tags: handheld-devices-worker:${{ github.sha }} - name: Build frontend image uses: docker/build-push-action@v6 with: context: ./frontend push: false load: true tags: handheld-devices-frontend:${{ github.sha }} test: name: Test runs-on: ubuntu-latest needs: build services: postgres: image: postgres:15-alpine env: POSTGRES_DB: handheld_devices POSTGRES_USER: devices_user POSTGRES_PASSWORD: devices_password ports: - 5432:5432 options: >- --health-cmd "pg_isready -U devices_user -d handheld_devices" --health-interval 5s --health-timeout 5s --health-retries 5 redis: image: redis:7-alpine ports: - 6379:6379 options: >- --health-cmd "redis-cli ping" --health-interval 5s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v4 - name: Set up Lua uses: leafo/gh-actions-luarocks@v6 with: lua-version: "5.4" - name: Install dependencies run: | luarocks install lua-cjson luarocks install luasocket luarocks install pgmoon luarocks install redis-lua luarocks install luaossl - name: Run API run: | cd devices-api export DB_HOST=localhost DB_PORT=5432 DB_NAME=handheld_devices DB_USER=devices_user DB_PASSWORD=devices_password export REDIS_HOST=localhost REDIS_PORT=6379 lua app-standalone.lua & API_PID=$! sleep 15 curl -f http://localhost:8080/health/ready || (kill $API_PID 2>/dev/null; exit 1) curl -f http://localhost:8080/health/live || (kill $API_PID 2>/dev/null; exit 1) kill $API_PID 2>/dev/null || true helm-lint: name: Helm Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Helm uses: azure/setup-helm@v4 with: version: "v3.14.0" - name: Helm lint run: helm lint k8s/handheld-devices