name: Lint and Build on: push: branches: [main, develop] pull_request: branches: [main, develop] jobs: # ============================================================================== # Job 1: Format Check # ============================================================================== format: runs-on: docker container: image: rust:latest steps: - name: Install Node.js for checkout run: | apt-get update apt-get install -y curl gnupg curl -fsSL https://deb.nodesource.com/setup_20.x | bash - apt-get install -y nodejs - name: Checkout code uses: actions/checkout@v4 - name: Install dependencies run: | apt-get update apt-get install -y pkg-config libssl-dev rustup component add rustfmt - name: Check formatting working-directory: ./backend run: cargo fmt --all -- --check # ============================================================================== # Job 2: Lint # ============================================================================== clippy: runs-on: docker container: image: rust:latest steps: - name: Install Node.js for checkout run: | apt-get update apt-get install -y curl gnupg curl -fsSL https://deb.nodesource.com/setup_20.x | bash - apt-get install -y nodejs - name: Checkout code uses: actions/checkout@v4 - name: Install dependencies run: | apt-get update apt-get install -y pkg-config libssl-dev rustup component add clippy - name: Run Clippy working-directory: ./backend run: cargo clippy --all-targets --all-features # ============================================================================== # Job 3: Build - Depends on format and clippy # ============================================================================== build: runs-on: docker container: image: rust:latest needs: [format, clippy] steps: - name: Install Node.js for checkout run: | apt-get update apt-get install -y curl gnupg curl -fsSL https://deb.nodesource.com/setup_20.x | bash - apt-get install -y nodejs - name: Checkout code uses: actions/checkout@v4 - name: Install dependencies run: | apt-get update apt-get install -y pkg-config libssl-dev - name: Build release binary working-directory: ./backend run: cargo build --release --verbose # ============================================================================== # Job 4: Tests (unit + integration) — depends on format and clippy # ============================================================================== # Integration tests need a live MongoDB. The `services.mongo` block provides # one; it's reachable at `mongo:27017` from the job container. The tests skip # gracefully if Mongo is unreachable, so this job stays green even on runners # that can't provide service containers. test: runs-on: docker container: image: rust:latest needs: [format, clippy] services: mongo: image: mongo:7 env: MONGO_INITDB_DATABASE: normogen_test # No `ports:` mapping: the job container reaches Mongo over the job's # internal network via the service hostname (MONGODB_URI uses `mongo`, # not localhost). Publishing to a host port is unnecessary and collides # with any mongod already bound to :27017 on the runner host — which # made the service container fail to schedule ("port is already # allocated") and aborted the whole test job before any test ran. env: MONGODB_URI: mongodb://mongo:27017 APP_ENVIRONMENT: development steps: - name: Install Node.js for checkout run: | apt-get update apt-get install -y curl gnupg curl -fsSL https://deb.nodesource.com/setup_20.x | bash - apt-get install -y nodejs - name: Checkout code uses: actions/checkout@v4 - name: Install dependencies run: | apt-get update apt-get install -y pkg-config libssl-dev - name: Run unit + integration tests working-directory: ./backend run: cargo test --all-targets # ============================================================================== # NOTE: Docker builds are handled separately due to Forgejo runner limitations # # The Forgejo act runner creates isolated networks for each job, making it # impossible to access Docker from within CI jobs. All attempts to work around # this have failed: # - Socket mount: Socket not accessible in container # - DinD service: DNS resolution fails across networks # - Buildx: Same network isolation issues # - Direct host access: Network isolation prevents this # # Docker builds are done separately: # - Locally: docker build -f backend/docker/Dockerfile # - On Solaria: docs/deployment/deploy-to-solaria.sh # # This is a pragmatic solution that works within Forgejo's infrastructure. # ==============================================================================