normogen/.forgejo/workflows/lint-and-build.yml
goose 6935992457
Some checks failed
Lint, Build, and Docker / format (push) Successful in 47s
Lint, Build, and Docker / clippy (push) Successful in 1m31s
Lint, Build, and Docker / build (push) Successful in 3m36s
Lint, Build, and Docker / docker-build (push) Failing after 4s
fix(ci): use rust:latest for edition2024 support
- Change from rust:1.84-slim to rust:latest
- Latest Rust version includes edition2024 support
- Fixes time-core dependency issue
- Ensures CI uses most recent stable Rust
2026-03-17 23:09:50 -03:00

155 lines
4.6 KiB
YAML

name: Lint, Build, and Docker
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
rustup component add clippy
- name: Build release binary
working-directory: ./backend
run: cargo build --release --verbose
# ==============================================================================
# Job 4: Docker Build - Uses DinD with Buildx
# ==============================================================================
docker-build:
runs-on: docker
container:
image: docker:cli
volumes:
- /var/run/docker.sock:/var/run/docker.sock
needs: [build]
services:
docker:
image: docker:dind
command: ["dockerd", "--host=tcp://0.0.0.0:2375", "--tls=false"]
options: >-
--privileged
-e DOCKER_TLS_CERTDIR=
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Verify Docker is available
run: |
docker version
docker info
- name: Set up Docker Buildx
run: |
docker buildx version
docker buildx create --use --name builder --driver docker --driver-opt network=host
docker buildx inspect --bootstrap
- name: Build Docker image with Buildx
working-directory: ./backend
run: |
docker buildx build \
--file docker/Dockerfile \
--tag normogen-backend:${{ github.sha }} \
--tag normogen-backend:latest \
--cache-from type=local,src=/tmp/.buildx-cache \
--cache-to type=local,dest=/tmp/.buildx-cache-new,mode=max \
--load \
.
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache || true
- name: Test Docker image
run: |
docker run --rm normogen-backend:${{ github.sha }} \
ls -la /app/normogen-backend || echo "Binary check"
- name: Show image info
run: |
docker images normogen-backend
docker inspect normogen-backend:${{ github.sha }} || echo "Image inspect"