diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 7a95be79..398daa45 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -14,8 +14,70 @@ concurrency: cancel-in-progress: true jobs: + test: + runs-on: ubuntu-latest + services: + postgres: + image: timescale/timescaledb:latest-pg17 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: towerops_test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + otp-version: '27.1' + elixir-version: '1.17.3' + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y libsnmp-dev snmp-mibs-downloader + + - name: Restore dependencies cache + uses: actions/cache@v4 + with: + path: | + deps + _build + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: ${{ runner.os }}-mix- + + - name: Install dependencies + run: mix deps.get + + - name: Check code formatting + run: mix format --check-formatted + + - name: Compile with warnings as errors + run: mix compile --warnings-as-errors + env: + MIX_ENV: test + + - name: Run Credo + run: mix credo --strict + + - name: Run tests + run: mix test --warnings-as-errors + env: + MIX_ENV: test + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/towerops_test + build: runs-on: ubuntu-latest + needs: test steps: - name: Checkout code uses: actions/checkout@v4