chore: prepare JS + CSS linter and add CI depending frontend of backend changes
This commit is contained in:
@@ -2,7 +2,11 @@ name: CI
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main", "dev" ]
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
|
- "feat/**"
|
||||||
|
- "fix/**"
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main", "dev" ]
|
branches: [ "main", "dev" ]
|
||||||
|
|
||||||
@@ -12,8 +16,46 @@ env:
|
|||||||
DATABASE_URL: "postgres://postgres:postgres@localhost/oxicloud_test"
|
DATABASE_URL: "postgres://postgres:postgres@localhost/oxicloud_test"
|
||||||
|
|
||||||
jobs:
|
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
|
name: Rustfmt
|
||||||
|
needs: changes
|
||||||
|
if: needs.changes.outputs.backend == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
@@ -22,8 +64,10 @@ jobs:
|
|||||||
components: rustfmt
|
components: rustfmt
|
||||||
- run: cargo fmt --all --check
|
- run: cargo fmt --all --check
|
||||||
|
|
||||||
clippy:
|
rust-clippy:
|
||||||
name: Clippy
|
name: Clippy
|
||||||
|
needs: changes
|
||||||
|
if: needs.changes.outputs.backend == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
@@ -33,8 +77,10 @@ jobs:
|
|||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: cargo clippy --all-targets --all-features -- -D warnings
|
- run: cargo clippy --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
test:
|
rust-test:
|
||||||
name: Tests
|
name: Tests
|
||||||
|
needs: changes
|
||||||
|
if: needs.changes.outputs.backend == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
@@ -65,8 +111,10 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
DATABASE_URL: "postgres://postgres:postgres@localhost/oxicloud_test"
|
DATABASE_URL: "postgres://postgres:postgres@localhost/oxicloud_test"
|
||||||
|
|
||||||
audit:
|
rust-audit:
|
||||||
name: Security Audit
|
name: Security Audit
|
||||||
|
needs: changes
|
||||||
|
if: needs.changes.outputs.backend == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
@@ -81,7 +129,7 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
name: Build Check
|
name: Build Check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [fmt, clippy, test]
|
needs: [frontend-linter, rust-fmt, rust-clippy, rust-test]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
|||||||
@@ -214,6 +214,8 @@ Full reference: [`example.env`](example.env) · [Deployment guide](doc/deploymen
|
|||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
### Server side
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo build # Dev build
|
cargo build # Dev build
|
||||||
cargo run # Run locally
|
cargo run # Run locally
|
||||||
@@ -223,6 +225,16 @@ cargo fmt --all --check # Format check
|
|||||||
RUST_LOG=debug cargo run # Debug logging
|
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
|
### Project stats
|
||||||
|
|
||||||
| Metric | Value |
|
| Metric | Value |
|
||||||
|
|||||||
+42
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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": []
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user