loco-rs 0.6.1

The one-person framework for Rust
Documentation
name: examples/demo

on:
  push:
    branches:
      - master
  pull_request:

env:
  RUST_TOOLCHAIN: stable
  TOOLCHAIN_PROFILE: minimal

jobs:
  rustfmt:
    name: Check Style
    runs-on: ubuntu-latest

    permissions:
      contents: read

    steps:
      - name: Checkout the code
        uses: actions/checkout@v4
      - uses: actions-rs/toolchain@v1
        with:
          profile: ${{ env.TOOLCHAIN_PROFILE }}
          toolchain: ${{ env.RUST_TOOLCHAIN }}
          override: true
          components: rustfmt
      - run: cargo fmt --all -- --check
        working-directory: ./examples/demo

  clippy:
    name: Run Clippy
    needs: [rustfmt]
    runs-on: ubuntu-latest

    permissions:
      contents: read

    steps:
      - name: Checkout the code
        uses: actions/checkout@v4
      - uses: actions-rs/toolchain@v1
        with:
          profile: ${{ env.TOOLCHAIN_PROFILE }}
          toolchain: ${{ env.RUST_TOOLCHAIN }}
          override: true
      - name: Setup Rust cache
        uses: Swatinem/rust-cache@v2
      - name: Run cargo clippy
        run: cargo clippy -- -W clippy::nursery -W clippy::pedantic -W rust-2018-idioms -W rust-2021-compatibility
        working-directory: ./examples/demo

  test:
    name: Run Tests
    needs: [rustfmt, clippy]
    runs-on: ubuntu-latest

    permissions:
      contents: read

    services:
      redis:
        image: redis
        options: >-
          --health-cmd "redis-cli ping"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - "6379:6379"
      postgres:
        image: postgres
        env:
          POSTGRES_DB: postgres_test
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
        ports:
          - "5432:5432"
        # Set health checks to wait until postgres has started
        options: --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    steps:
      - name: Checkout the code
        uses: actions/checkout@v4
      - uses: actions-rs/toolchain@v1
        with:
          profile: ${{ env.TOOLCHAIN_PROFILE }}
          toolchain: ${{ env.RUST_TOOLCHAIN }}
          override: true
      - name: Setup Rust cache
        uses: Swatinem/rust-cache@v2
      - name: Install seaorm cli
        run: cargo install sea-orm-cli
      - name: Run cargo test
        run: cargo test --all-features --all
        working-directory: ./examples/demo
        env:
          LOCO_CI_MODE: 1
          REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}}
          DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test