92 lines
2.6 KiB
YAML
92 lines
2.6 KiB
YAML
name: CI
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
rust:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgres:15
|
|
env:
|
|
POSTGRES_PASSWORD: postgres
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt, clippy
|
|
|
|
- name: Cache cargo registry and build
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Check formatting
|
|
run: cargo fmt --all --check
|
|
|
|
- name: Run clippy
|
|
run: cargo clippy --workspace -- -D warnings
|
|
|
|
- name: Build workspace
|
|
run: cargo build --workspace
|
|
|
|
- name: Run tests
|
|
run: cargo test --workspace
|
|
env:
|
|
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
|
|
JWT_SECRET: test-secret-for-ci-only-not-production
|
|
DEFAULT_TENANT_DB_URL: postgres://postgres:postgres@localhost:5432/postgres
|
|
|
|
- name: Verify sqlx offline data
|
|
run: cargo sqlx prepare --check --workspace
|
|
env:
|
|
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
|
|
|
|
podman-build:
|
|
runs-on: ubuntu-latest
|
|
needs: rust
|
|
container:
|
|
image: docker.io/podman/stable:latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build gateway-runtime
|
|
run: podman build --target gateway -t git.madapes.com/madbase/gateway:ci .
|
|
|
|
- name: Build worker-runtime
|
|
run: podman build --target worker-runtime -t git.madapes.com/madbase/worker:ci .
|
|
|
|
- name: Build control-runtime
|
|
run: podman build --target control-runtime -t git.madapes.com/madbase/control:ci .
|
|
|
|
- name: Build proxy-runtime
|
|
run: podman build --target proxy-runtime -t git.madapes.com/madbase/proxy:ci .
|
|
|
|
- name: Login to registry
|
|
if: github.ref == 'refs/heads/main'
|
|
run: podman login git.madapes.com -u ${{ secrets.REGISTRY_USER }} -p ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Push images
|
|
if: github.ref == 'refs/heads/main'
|
|
run: |
|
|
podman push git.madapes.com/madbase/gateway:ci
|
|
podman push git.madapes.com/madbase/worker:ci
|
|
podman push git.madapes.com/madbase/control:ci
|
|
podman push git.madapes.com/madbase/proxy:ci
|