|
| 1 | +# CI/CD Infrastructure |
| 2 | + |
| 3 | +This document provides an overview of the CI/CD infrastructure for apalis-board. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The apalis-board repository uses GitHub Actions for continuous integration, deployment, and automated maintenance. The infrastructure is designed to ensure code quality, security, and reliability. |
| 8 | + |
| 9 | +## Workflows |
| 10 | + |
| 11 | +### Core CI Workflows |
| 12 | + |
| 13 | +#### 1. All Checks (`ci.yml`) |
| 14 | +**Trigger**: Push to master/main, Pull Requests |
| 15 | +**Purpose**: Combined workflow that serves as the main status check |
| 16 | + |
| 17 | +This workflow runs: |
| 18 | +- Rust compilation checks |
| 19 | +- Test suite |
| 20 | +- Code formatting validation |
| 21 | +- Clippy linting |
| 22 | +- Frontend build |
| 23 | +- Security audit |
| 24 | + |
| 25 | +**Status**: This is the primary status check for PRs |
| 26 | + |
| 27 | +#### 2. Rust CI (`rust-ci.yml`) |
| 28 | +**Trigger**: Push to master/main, Pull Requests |
| 29 | +**Purpose**: Comprehensive Rust quality checks |
| 30 | + |
| 31 | +Jobs: |
| 32 | +- **check**: Verifies all crates compile |
| 33 | +- **test**: Runs test suites for types and api crates |
| 34 | +- **fmt**: Validates code formatting with rustfmt |
| 35 | +- **clippy**: Lints code with clippy |
| 36 | +- **features**: Tests feature combinations (actix, axum) |
| 37 | + |
| 38 | +#### 3. Frontend Build (`frontend-build.yml`) |
| 39 | +**Trigger**: Push to master/main, Pull Requests |
| 40 | +**Purpose**: Builds the Leptos WASM frontend |
| 41 | + |
| 42 | +Steps: |
| 43 | +1. Install Rust with wasm32-unknown-unknown target |
| 44 | +2. Install Trunk (WASM bundler) |
| 45 | +3. Install npm dependencies (Tailwind CSS) |
| 46 | +4. Build frontend with Trunk |
| 47 | +5. Upload build artifacts |
| 48 | + |
| 49 | +### Release Workflow |
| 50 | + |
| 51 | +#### 4. Release (`release.yml`) |
| 52 | +**Trigger**: Version tags (v*.*.*) |
| 53 | +**Purpose**: Automated release creation and artifact publishing |
| 54 | + |
| 55 | +The workflow: |
| 56 | +1. Creates a GitHub release |
| 57 | +2. Builds frontend and packages as tar.gz |
| 58 | +3. Builds and packages Rust crates |
| 59 | +4. Uploads all artifacts to the release |
| 60 | + |
| 61 | +**Usage**: Push a version tag to trigger |
| 62 | +```bash |
| 63 | +git tag -a v1.0.0 -m "Release v1.0.0" |
| 64 | +git push origin v1.0.0 |
| 65 | +``` |
| 66 | + |
| 67 | +### Security and Quality |
| 68 | + |
| 69 | +#### 5. Security Audit (`security.yml`) |
| 70 | +**Trigger**: |
| 71 | +- Push/PR on Cargo.toml or Cargo.lock changes |
| 72 | +- Weekly schedule (Mondays at 9 AM UTC) |
| 73 | + |
| 74 | +Jobs: |
| 75 | +- **audit**: Scans for security vulnerabilities with cargo-audit |
| 76 | +- **deny**: Checks dependencies with cargo-deny for: |
| 77 | + - Known security advisories |
| 78 | + - License compliance |
| 79 | + - Banned/yanked crates |
| 80 | + - Multiple versions of same crate |
| 81 | + |
| 82 | +#### 6. Code Coverage (`coverage.yml`) |
| 83 | +**Trigger**: Push to master/main, Pull Requests |
| 84 | +**Purpose**: Generates and reports code coverage |
| 85 | + |
| 86 | +Uses: |
| 87 | +- cargo-tarpaulin for coverage generation |
| 88 | +- Codecov for coverage reporting and tracking |
| 89 | + |
| 90 | +#### 7. Documentation Check (`docs.yml`) |
| 91 | +**Trigger**: |
| 92 | +- Push/PR to master/main |
| 93 | +- Weekly schedule (Sundays at midnight UTC) |
| 94 | + |
| 95 | +Jobs: |
| 96 | +- **link-check**: Validates markdown links |
| 97 | +- **rustdoc**: Builds Rust documentation with warnings as errors |
| 98 | + |
| 99 | +### Maintenance |
| 100 | + |
| 101 | +#### 8. Tailwind CSS Check (`nodejs.yml`) |
| 102 | +**Trigger**: Push to master/main, Pull Requests |
| 103 | +**Purpose**: Validates npm dependencies |
| 104 | + |
| 105 | +Checks: |
| 106 | +- Installs npm dependencies |
| 107 | +- Checks for outdated packages |
| 108 | +- Runs security audit |
| 109 | + |
| 110 | +#### 9. Cache Warmup (`cache-warmup.yml`) |
| 111 | +**Trigger**: |
| 112 | +- Weekly schedule (Sundays at midnight UTC) |
| 113 | +- Manual workflow dispatch |
| 114 | + |
| 115 | +**Purpose**: Pre-warms caches to improve CI performance |
| 116 | + |
| 117 | +Jobs: |
| 118 | +- Builds all Rust crates to populate cargo cache |
| 119 | +- Installs npm dependencies to populate npm cache |
| 120 | + |
| 121 | +#### 10. Dependabot Configuration (`dependabot.yml`) |
| 122 | +**Schedule**: Weekly (Mondays) |
| 123 | +**Purpose**: Automated dependency updates |
| 124 | + |
| 125 | +Monitors: |
| 126 | +- Cargo dependencies (Rust) |
| 127 | +- npm dependencies (Tailwind CSS) |
| 128 | +- GitHub Actions versions |
| 129 | + |
| 130 | +Creates PRs for updates grouped by ecosystem. |
| 131 | + |
| 132 | +## Caching Strategy |
| 133 | + |
| 134 | +The CI uses multiple caching strategies: |
| 135 | + |
| 136 | +1. **Rust Cache** (Swatinem/rust-cache@v2) |
| 137 | + - Caches compiled dependencies |
| 138 | + - Shared across workflows with `shared-key` |
| 139 | + - Significantly reduces build times |
| 140 | + |
| 141 | +2. **npm Cache** |
| 142 | + - Built into setup-node action |
| 143 | + - Caches node_modules dependencies |
| 144 | + |
| 145 | +3. **Weekly Warmup** |
| 146 | + - Refreshes caches weekly |
| 147 | + - Ensures CI has latest pre-compiled dependencies |
| 148 | + |
| 149 | +## Security Features |
| 150 | + |
| 151 | +1. **cargo-audit**: Checks for known security vulnerabilities |
| 152 | +2. **cargo-deny**: Enforces security and licensing policies |
| 153 | +3. **Dependabot**: Automated security updates |
| 154 | +4. **npm audit**: Checks npm dependencies for vulnerabilities |
| 155 | + |
| 156 | +## Status Badges |
| 157 | + |
| 158 | +The README includes badges for: |
| 159 | +- All Checks status |
| 160 | +- Rust CI status |
| 161 | +- Frontend Build status |
| 162 | +- Security Audit status |
| 163 | +- Code Coverage percentage |
| 164 | + |
| 165 | +## Troubleshooting |
| 166 | + |
| 167 | +### Workflow Failures |
| 168 | + |
| 169 | +**Rust CI fails on formatting**: |
| 170 | +```bash |
| 171 | +cargo fmt --all |
| 172 | +``` |
| 173 | + |
| 174 | +**Rust CI fails on clippy**: |
| 175 | +```bash |
| 176 | +cargo clippy --workspace --all-features |
| 177 | +``` |
| 178 | + |
| 179 | +**Frontend build fails**: |
| 180 | +```bash |
| 181 | +cd crates/board |
| 182 | +trunk build |
| 183 | +``` |
| 184 | + |
| 185 | +**Tests fail**: |
| 186 | +```bash |
| 187 | +cargo test --workspace |
| 188 | +``` |
| 189 | + |
| 190 | +### Common Issues |
| 191 | + |
| 192 | +1. **Workspace member not found**: Examples are excluded from workspace as they depend on external repos |
| 193 | +2. **Cache issues**: Manually trigger cache-warmup workflow or wait for weekly refresh |
| 194 | +3. **Outdated dependencies**: Wait for Dependabot PRs or run `cargo update` / `npm update` |
| 195 | + |
| 196 | +## Manual Triggers |
| 197 | + |
| 198 | +Some workflows can be triggered manually: |
| 199 | + |
| 200 | +1. **Cache Warmup**: Go to Actions → Cache Warmup → Run workflow |
| 201 | +2. **Release**: Push a version tag (preferred over manual trigger) |
| 202 | + |
| 203 | +## Contributing |
| 204 | + |
| 205 | +When contributing, ensure: |
| 206 | +- All CI checks pass before requesting review |
| 207 | +- Follow the PR template |
| 208 | +- Update documentation if needed |
| 209 | +- Add tests for new features |
| 210 | + |
| 211 | +For more details, see [CONTRIBUTING.md](../CONTRIBUTING.md). |
| 212 | + |
| 213 | +## Future Improvements |
| 214 | + |
| 215 | +Potential enhancements: |
| 216 | +- [ ] Nightly builds for testing against Rust nightly |
| 217 | +- [ ] Performance benchmarking |
| 218 | +- [ ] Automated changelog generation |
| 219 | +- [ ] Deploy previews for frontend changes |
| 220 | +- [ ] Integration tests with example services |
0 commit comments