- Install Node.js in docker:cli container for checkout action - Remove Buildx and DinD service complexity - Use straightforward docker build with socket mount - Keep it simple: docker build -f docker/Dockerfile - This should resolve the checkout failures in docker-build job
132 lines
3.8 KiB
YAML
132 lines
3.8 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
|
|
|
|
- name: Build release binary
|
|
working-directory: ./backend
|
|
run: cargo build --release --verbose
|
|
|
|
# ==============================================================================
|
|
# Job 4: Docker Build - Simple docker build
|
|
# ==============================================================================
|
|
docker-build:
|
|
runs-on: docker
|
|
container:
|
|
image: docker:cli
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
needs: [build]
|
|
|
|
steps:
|
|
- name: Install Node.js for checkout
|
|
run: apk add --no-cache nodejs npm
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Verify Docker is available
|
|
run: |
|
|
docker version
|
|
docker info
|
|
|
|
- name: Build Docker image
|
|
working-directory: ./backend
|
|
run: |
|
|
docker build -f docker/Dockerfile -t normogen-backend:${{ github.sha }} -t normogen-backend:latest .
|
|
|
|
- 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"
|