From 76d374ea182b2c030b97680487c01a7257390100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20P=C3=A9rex?= Date: Mon, 7 Jul 2025 23:09:32 +0100 Subject: [PATCH] chore: add hidden files --- .dockerignore | 111 ++++++++++++++++ .githooks/pre-commit | 16 +++ .githooks/pre-push | 16 +++ .github/dependabot.yml | 81 ++++++++++++ .github/workflows/ci-cd.yml | 247 ++++++++++++++++++++++++++++++++++++ .gitignore | 98 ++++++++++++++ 6 files changed, 569 insertions(+) create mode 100644 .dockerignore create mode 100755 .githooks/pre-commit create mode 100755 .githooks/pre-push create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci-cd.yml create mode 100644 .gitignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..77de6cf --- /dev/null +++ b/.dockerignore @@ -0,0 +1,111 @@ +# Rust build artifacts +target/ +**/*.rs.bk +*.pdb + +# Node.js +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Development files +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +# IDE and editor files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Git +.git/ +.gitignore +.gitattributes + +# Documentation +*.md +docs/ +README* + +# Test files +tests/ +test/ +**/*test* +**/*spec* + +# Temporary files +tmp/ +temp/ +*.tmp +*.temp + +# Logs +logs/ +*.log + +# Runtime directories +uploads/ +cache/ +data/ +backups/ + +# Development scripts +scripts/dev* +scripts/test* + +# Docker files +Dockerfile* +docker-compose* +.dockerignore + +# CI/CD +.github/ +.gitlab-ci.yml +.travis.yml +.circleci/ + +# Package manager files (keep package.json but ignore lock files for multi-stage) +package-lock.json +yarn.lock +pnpm-lock.yaml + +# Build tools config +.cargo/ +rust-toolchain +rust-toolchain.toml + +# Examples and demos +examples/ +end2end/ + +# Certificates (should be mounted or provided separately) +certs/ +*.pem +*.crt +*.key + +# Database files +*.db +*.sqlite +*.sqlite3 + +# Binaries +*.exe +*.so +*.dylib +*.dll diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..27df652 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,16 @@ +#!/bin/bash +# Pre-commit hook to run cargo +nightly fmt + +echo "Running cargo +nightly fmt..." + +# Run cargo +nightly fmt +cargo +nightly fmt + +# Check if there are any changes after formatting +if ! git diff --quiet; then + echo "Code has been formatted. Please add the changes and commit again." + echo "Run: git add . && git commit" + exit 1 +fi + +echo "Code formatting check passed!" diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100755 index 0000000..d90dde0 --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,16 @@ +#!/bin/bash +# Pre-push hook to run cargo +nightly fmt + +echo "Running cargo +nightly fmt before push..." + +# Run cargo +nightly fmt +cargo +nightly fmt + +# Check if there are any changes after formatting +if ! git diff --quiet; then + echo "Code has been formatted. Please commit the changes and push again." + echo "Run: git add . && git commit -m \"cargo fmt\" && git push" + exit 1 +fi + +echo "Code formatting check passed!" diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5979065 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,81 @@ +version: 2 +updates: + # Rust dependencies + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + time: "06:00" + open-pull-requests-limit: 10 + reviewers: + - "rustelo-maintainers" + commit-message: + prefix: "cargo" + include: "scope" + labels: + - "dependencies" + - "rust" + allow: + - dependency-type: "all" + ignore: + - dependency-name: "leptos*" + update-types: ["version-update:semver-major"] + - dependency-name: "axum" + update-types: ["version-update:semver-major"] + + # Node.js dependencies + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + time: "06:00" + open-pull-requests-limit: 10 + reviewers: + - "rustelo-maintainers" + commit-message: + prefix: "npm" + include: "scope" + labels: + - "dependencies" + - "javascript" + allow: + - dependency-type: "all" + ignore: + - dependency-name: "tailwindcss" + update-types: ["version-update:semver-major"] + + # Docker dependencies + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + time: "06:00" + open-pull-requests-limit: 5 + reviewers: + - "rustelo-maintainers" + commit-message: + prefix: "docker" + include: "scope" + labels: + - "dependencies" + - "docker" + + # GitHub Actions dependencies + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + time: "06:00" + open-pull-requests-limit: 5 + reviewers: + - "rustelo-maintainers" + commit-message: + prefix: "github-actions" + include: "scope" + labels: + - "dependencies" + - "github-actions" diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 0000000..1417493 --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -0,0 +1,247 @@ +name: CI/CD Pipeline + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main ] + release: + types: [ published ] + +env: + CARGO_TERM_COLOR: always + RUST_VERSION: 1.75.0 + +jobs: + test: + name: Test Suite + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:15 + env: + POSTGRES_PASSWORD: postgres + POSTGRES_DB: rustelo_test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + redis: + image: redis:7 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 6379:6379 + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_VERSION }} + components: rustfmt, clippy + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install Node dependencies + run: npm ci + + - name: Cache Cargo dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Install cargo-leptos + run: cargo install cargo-leptos --version 0.2.20 + + - name: Check formatting + run: cargo fmt --all -- --check + + - name: Run Clippy + run: cargo clippy --all-targets --features "auth,content-db,crypto,email,metrics,examples" -- -D warnings + + - name: Run tests + run: cargo test --features "auth,content-db,crypto,email,metrics,examples" + env: + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/rustelo_test + REDIS_URL: redis://localhost:6379 + + - name: Build frontend + run: npm run build + + - name: Build application + run: cargo leptos build --release --features production --no-default-features + + security: + name: Security Audit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_VERSION }} + + - name: Install cargo-audit + run: cargo install cargo-audit + + - name: Run security audit + run: cargo audit + + - name: Run cargo-deny + uses: EmbarkStudios/cargo-deny-action@v1 + + build: + name: Build Docker Image + runs-on: ubuntu-latest + needs: [test, security] + if: github.event_name == 'push' || github.event_name == 'release' + + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + if: github.event_name == 'release' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ secrets.DOCKER_USERNAME }}/rustelo + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha,prefix={{branch}}- + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name == 'release' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + deploy-staging: + name: Deploy to Staging + runs-on: ubuntu-latest + needs: build + if: github.ref == 'refs/heads/develop' + environment: staging + + steps: + - uses: actions/checkout@v4 + + - name: Deploy to staging + run: | + echo "Deploying to staging environment..." + # Add your staging deployment commands here + # Example: kubectl apply -f k8s/staging/ + # Example: docker-compose -f docker-compose.staging.yml up -d + + - name: Run health check + run: | + echo "Running health check..." + # Add health check commands here + # Example: curl -f https://staging.yourapp.com/health + + deploy-production: + name: Deploy to Production + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'release' + environment: production + + steps: + - uses: actions/checkout@v4 + + - name: Deploy to production + run: | + echo "Deploying to production environment..." + # Add your production deployment commands here + # Example: kubectl apply -f k8s/production/ + # Example: docker-compose -f docker-compose.prod.yml up -d + + - name: Run health check + run: | + echo "Running health check..." + # Add health check commands here + # Example: curl -f https://yourapp.com/health + + - name: Notify deployment + if: always() + run: | + echo "Notifying deployment status..." + # Add notification commands here + # Example: Send Slack notification, email, etc. + + benchmark: + name: Performance Benchmarks + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_VERSION }} + + - name: Run benchmarks + run: cargo bench --features production --no-default-features + + - name: Store benchmark results + uses: benchmark-action/github-action-benchmark@v1 + with: + tool: 'cargo' + output-file-path: target/criterion/report/index.html + github-token: ${{ secrets.GITHUB_TOKEN }} + auto-push: true + comment-on-alert: true + alert-threshold: '200%' + fail-on-alert: true + + cleanup: + name: Cleanup + runs-on: ubuntu-latest + if: always() + needs: [test, security, build, deploy-staging, deploy-production] + + steps: + - name: Cleanup artifacts + run: | + echo "Cleaning up temporary artifacts..." + # Add cleanup commands here if needed diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c950441 --- /dev/null +++ b/.gitignore @@ -0,0 +1,98 @@ +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ +# Encryption keys and related files (CRITICAL - NEVER COMMIT) +.k +.k.backup +*.k +*.key.backup + +config.*.toml +config.*back + +# where book is written +_book + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +node_modules/ + +**/output.css +**/input.css + +# Environment files +.env +.env.local +.env.production +.env.development +.env.staging + +# Keep example files +!.env.example + +# Configuration files (may contain sensitive data) +config.prod.toml +config.production.toml +config.local.toml +config.*.local.toml + +# Keep example configuration files +!config.toml +!config.dev.toml +!config.example.toml + +# Log files +logs/ +*.log + +# TLS certificates and keys +certs/ +*.pem +*.crt +*.key +*.p12 +*.pfx + +# Database files +*.db +*.sqlite +*.sqlite3 + +# Backup files +*.bak +*.backup +*.tmp +*~ + +# Encryption and security related files +*.encrypted +*.enc +secrets/ +private/ +security/ + +# Configuration backups that may contain secrets +config.*.backup +config.backup.* + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db +# Documentation build output +book-output/ +# Generated setup report +SETUP_COMPLETE.md