feat(ci): Add Forgejo CI/CD pipeline for linting and building
Some checks are pending
Lint and Build / Lint (push) Waiting to run
Lint and Build / Build (push) Blocked by required conditions
Lint and Build / Docker Build (push) Blocked by required conditions

- Automated linting with rustfmt and clippy
- Automated building and testing
- Automated Docker image builds
- Clippy and rustfmt configuration files
This commit is contained in:
goose 2026-02-15 19:57:03 -03:00
parent c69d3be302
commit 775f05d696
4 changed files with 238 additions and 0 deletions

View file

@ -0,0 +1,123 @@
name: Lint and Build
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
override: true
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v3
with:
path: backend/target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Run rustfmt
working-directory: ./backend
run: |
cargo fmt --all -- --check
- name: Run clippy
working-directory: ./backend
run: |
cargo clippy --all-targets --all-features -- -D warnings
build:
name: Build
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v3
with:
path: backend/target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Build project
working-directory: ./backend
run: |
cargo build --verbose
- name: Run tests
working-directory: ./backend
run: |
cargo test --verbose
docker-build:
name: Docker Build
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
working-directory: ./backend
run: |
docker build -f docker/Dockerfile -t normogen-backend:test .
- name: Build Docker image (dev)
working-directory: ./backend
run: |
docker build -f docker/Dockerfile.dev -t normogen-backend:dev-test .

73
FORGEJO-CI-CD-PIPELINE.md Normal file
View file

@ -0,0 +1,73 @@
# Forgejo CI/CD Pipeline
## Status: ✅ Implemented
**Date**: 2026-02-15 19:55:00 UTC
---
## Pipeline Stages
### 1. Lint Job
- Check code formatting with rustfmt
- Run clippy linter with strict rules
### 2. Build Job
- Build all targets with cargo
- Run all tests
### 3. Docker Build Job
- Build production Docker image
- Build development Docker image
---
## Trigger Events
- Push to main branch
- Push to develop branch
- Pull requests to main/develop
---
## Configuration Files
- .forgejo/workflows/lint-and-build.yml
- backend/clippy.toml
- backend/rustfmt.toml
---
## Running Locally
### Check formatting
```bash
cd backend
cargo fmt --all -- --check
cargo fmt --all # to fix
```
### Run clippy
```bash
cd backend
cargo clippy --all-targets --all-features -- -D warnings
```
### Build
```bash
cd backend
cargo build --verbose
```
### Run tests
```bash
cd backend
cargo test --verbose
```
---
## Viewing Results
After pushing, go to:
http://gitea.soliverez.com.ar/alvaro/normogen/actions

27
backend/clippy.toml Normal file
View file

@ -0,0 +1,27 @@
# Clippy configuration
# Allow certain warnings for development
ambiguous-glob-reexports = "allow"
cast-lossless = "allow"
doc-markdown = "warn"
empty-structs-with-brackets = "warn"
explicit-auto-deref = "warn"
if-then-some-else-none = "warn"
match-wildcard-for-single-variants = "warn"
missing-errors-doc = "warn"
missing-panics-doc = "warn"
missing-safety-doc = "warn"
semicolon-if-nothing-returned = "warn"
unreadable-literal = "warn"
unused-self = "warn"
used-underscore-binding = "warn"
# Deny certain lints
missing-docs-in-private-items = "warn"
unwrap-used = "warn"
expect-used = "warn"
indexing-slicing = "warn"
panic = "deny"
unimplemented = "warn"
todo = "warn"
unreachable = "warn"

15
backend/rustfmt.toml Normal file
View file

@ -0,0 +1,15 @@
# Rustfmt configuration
max_width = 100
hard_tabs = false
tab_spaces = 4
newline_style = "Unix"
use_small_heuristics = "Default"
reorder_imports = true
reorder_modules = true
remove_nested_parens = true
edition = "2021"
merge_derives = true
use_try_shorthand = true
use_field_init_shorthand = true
force_explicit_abi = true