Skip to content

Improve PR CI workflow readability, caching, and structure #1009

Improve PR CI workflow readability, caching, and structure

Improve PR CI workflow readability, caching, and structure #1009

Workflow file for this run

name: PR Check
on:
pull_request:
branches:
- main
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
linting:
name: Linting
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout Code
uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version: "22"
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: |
backend/requirements.txt
sync-microservice/requirements.txt
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
frontend/src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Backend Dependencies
working-directory: backend
run: |
python -m pip install --upgrade pip
pip install pre-commit ruff black
- name: Install Frontend Dependencies
working-directory: frontend
run: npm ci
- name: Run Frontend Linters
working-directory: frontend
run: |
npm run lint:check
npm run format:check
- name: Run backend Linters
working-directory: backend
run: pre-commit run --config ../.pre-commit-config.yaml --all-files || exit 1
- name: Run Rust
working-directory: frontend/src-tauri
run: cargo fmt -- --check
# Frontend Test Job
frontend:
needs: [linting]
name: Frontend Tests
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout Code
uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version: "22"
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install Dependencies
working-directory: frontend
run: npm ci
- name: Run Tests
working-directory: frontend
run: npm test
# Backend Test Job
backend:
needs: [linting,frontend]
name: Backend Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: |
backend/requirements.txt
sync-microservice/requirements.txt
- name: Install Backend Dependencies
working-directory: backend
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build Backend Executable
working-directory: backend
run: pyinstaller main.py --name PictoPy_Server --onedir --distpath dist
- name: Install Micro Services Dependencies
working-directory: sync-microservice
run: |
pip install -r requirements.txt
- name: Build Sync Microservice Executable
working-directory: sync-microservice
run: pyinstaller main.py --name PictoPy_Sync_Microservice --onedir --distpath dist
- name: Run Tests
working-directory: backend
run: pytest