diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b7f0e2f..9add9751 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,11 @@ name: CI on: push: - branches: [ "main", "dev" ] + branches: + - main + - dev + - "feat/**" + - "fix/**" pull_request: branches: [ "main", "dev" ] @@ -12,8 +16,46 @@ env: DATABASE_URL: "postgres://postgres:postgres@localhost/oxicloud_test" jobs: - fmt: + + # Detect which parts of the codebase changed + changes: + runs-on: ubuntu-latest + outputs: + frontend: ${{ steps.filter.outputs.frontend }} + backend: ${{ steps.filter.outputs.backend }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + frontend: + - 'static/**' + - 'biome.json' + - 'jsconfig.json' + backend: + - 'src/**' + - 'Cargo.toml' + - 'Cargo.lock' + + frontend-linter: + name: Frontend — Biome + needs: changes + if: needs.changes.outputs.frontend == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Biome + uses: biomejs/setup-biome@v2 + + - name: Run Biome check + run: biome ci static/ + + rust-fmt: name: Rustfmt + needs: changes + if: needs.changes.outputs.backend == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 @@ -22,8 +64,10 @@ jobs: components: rustfmt - run: cargo fmt --all --check - clippy: + rust-clippy: name: Clippy + needs: changes + if: needs.changes.outputs.backend == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 @@ -33,8 +77,10 @@ jobs: - uses: Swatinem/rust-cache@v2 - run: cargo clippy --all-targets --all-features -- -D warnings - test: + rust-test: name: Tests + needs: changes + if: needs.changes.outputs.backend == 'true' runs-on: ubuntu-latest services: postgres: @@ -65,8 +111,10 @@ jobs: env: DATABASE_URL: "postgres://postgres:postgres@localhost/oxicloud_test" - audit: + rust-audit: name: Security Audit + needs: changes + if: needs.changes.outputs.backend == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 @@ -81,7 +129,7 @@ jobs: build: name: Build Check runs-on: ubuntu-latest - needs: [fmt, clippy, test] + needs: [frontend-linter, rust-fmt, rust-clippy, rust-test] steps: - uses: actions/checkout@v6 - uses: dtolnay/rust-toolchain@stable diff --git a/README.md b/README.md index f11b9a00..c0231010 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,8 @@ Full reference: [`example.env`](example.env) · [Deployment guide](doc/deploymen ## Development +### Server side + ```bash cargo build # Dev build cargo run # Run locally @@ -223,6 +225,16 @@ cargo fmt --all --check # Format check RUST_LOG=debug cargo run # Debug logging ``` +### Client side + +Run server in dev profile: + +```bash +PROFILE=dev cargo run +``` + +CSS & JS linter is `biome` (can be installed via `cargo install biome-cli` or on MacOS: `brew install biome`) + ### Project stats | Metric | Value | diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..56b68bf9 --- /dev/null +++ b/biome.json @@ -0,0 +1,42 @@ +{ + "files": { + "includes": ["static/**/*.js", "static/**/*.css", "static/**/*.json" ] + }, + "formatter": { + "enabled": true, + "indentStyle": "space", + "indentWidth": 4, + "lineWidth": 160, + "lineEnding": "lf" + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "correctness": { + "noUnusedVariables": "warn" + } + } + }, + "javascript": { + "formatter": { + "indentStyle": "space", + "indentWidth": 4, + "quoteStyle": "single", + "semicolons": "always", + "trailingCommas": "none", + "bracketSameLine": false, + "bracketSpacing": true, + "operatorLinebreak": "after" + + } + }, + "css": { + "linter": { + "enabled": true + }, + "formatter": { + "enabled": true + } + } +} diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 00000000..f09567bd --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + // Enable type checking on all JS files (equivalent to @ts-check globally) + "checkJs": true, + "strict": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "exactOptionalPropertyTypes": true, + "target": "ES2022", + "lib": ["ES2022", "DOM"], + // Treat all JS files as modules + "moduleDetection": "force" + }, + "include": ["static/js/**/*.js"], + "exclude": [] +}