|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main", "master" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "main", "master" ] |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + SQLX_OFFLINE: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + backend: |
| 15 | + name: Backend (Rust) |
| 16 | + runs-on: ubuntu-latest |
| 17 | + services: |
| 18 | + postgres: |
| 19 | + image: postgres:15-alpine |
| 20 | + env: |
| 21 | + POSTGRES_USER: postgres |
| 22 | + POSTGRES_PASSWORD: password |
| 23 | + POSTGRES_DB: payego |
| 24 | + ports: |
| 25 | + - 5432:5432 |
| 26 | + options: >- |
| 27 | + --health-cmd pg_isready |
| 28 | + --health-interval 10s |
| 29 | + --health-timeout 5s |
| 30 | + --health-retries 5 |
| 31 | +
|
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Install Rust |
| 36 | + uses: dtolnay/rust-toolchain@stable |
| 37 | + with: |
| 38 | + components: clippy, rustfmt |
| 39 | + |
| 40 | + - name: Cache Cargo registry |
| 41 | + uses: actions/cache@v3 |
| 42 | + with: |
| 43 | + path: | |
| 44 | + ~/.cargo/bin/ |
| 45 | + ~/.cargo/registry/index/ |
| 46 | + ~/.cargo/registry/cache/ |
| 47 | + ~/.cargo/git/db/ |
| 48 | + target/ |
| 49 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 50 | + |
| 51 | + - name: Install dependencies |
| 52 | + run: sudo apt-get update && sudo apt-get install -y libpq-dev openssl libssl-dev pkg-config |
| 53 | + |
| 54 | + - name: Install diesel_cli |
| 55 | + run: | |
| 56 | + if ! command -v diesel &> /dev/null; then |
| 57 | + cargo install diesel_cli --no-default-features --features postgres |
| 58 | + fi |
| 59 | + |
| 60 | + - name: Install cargo-audit |
| 61 | + run: | |
| 62 | + if ! command -v cargo-audit &> /dev/null; then |
| 63 | + cargo install cargo-audit |
| 64 | + fi |
| 65 | +
|
| 66 | + - name: Check Formatting |
| 67 | + run: cargo fmt --all -- --check |
| 68 | + |
| 69 | + - name: Linting |
| 70 | + run: cargo clippy --workspace --all-targets --all-features -- -D warnings |
| 71 | + |
| 72 | + - name: Run Tests |
| 73 | + env: |
| 74 | + DATABASE_URL: postgres://postgres:password@localhost:5432/payego |
| 75 | + TEST_DATABASE_URL: postgres://postgres:password@localhost:5432/payego |
| 76 | + APP_ENV: test |
| 77 | + JWT_SECRET: super_secret_testing_key_must_be_long_enough |
| 78 | + RUST_LOG: info |
| 79 | + run: cargo test --workspace |
| 80 | + |
| 81 | + - name: Security Audit |
| 82 | + run: cargo audit |
| 83 | + |
| 84 | + frontend: |
| 85 | + name: Frontend (React) |
| 86 | + runs-on: ubuntu-latest |
| 87 | + defaults: |
| 88 | + run: |
| 89 | + working-directory: ./payego_ui |
| 90 | + |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@v4 |
| 93 | + |
| 94 | + - name: Setup Node.js |
| 95 | + uses: actions/setup-node@v4 |
| 96 | + with: |
| 97 | + node-version: '18' |
| 98 | + cache: 'npm' |
| 99 | + cache-dependency-path: payego_ui/package-lock.json |
| 100 | + |
| 101 | + - name: Install Dependencies |
| 102 | + run: npm ci |
| 103 | + |
| 104 | + - name: Lint |
| 105 | + run: npm run lint |
| 106 | + |
| 107 | + - name: Test |
| 108 | + run: npm run test |
| 109 | + |
| 110 | + - name: Build |
| 111 | + run: npm run build |
0 commit comments