ci: add Go/Node CI, Docker multi-stage, Makefile, and pre-commit hooks; update README
This commit is contained in:
114
.github/workflows/ci.yml
vendored
114
.github/workflows/ci.yml
vendored
@@ -7,64 +7,92 @@ on:
|
||||
branches: [ main, development ]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint (ruff & flake8)
|
||||
backend-lint:
|
||||
name: Backend - Go Lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v4
|
||||
go-version: '1.22'
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
- name: Install dev dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.dev.txt
|
||||
- name: Run ruff
|
||||
run: |
|
||||
ruff check .
|
||||
- name: Run flake8
|
||||
run: |
|
||||
flake8 . || true
|
||||
version: latest
|
||||
working-directory: backend
|
||||
|
||||
test-and-coverage:
|
||||
name: Tests & Coverage
|
||||
backend-test:
|
||||
name: Backend - Go Tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint]
|
||||
needs: [backend-lint]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
- name: Cache pip
|
||||
go-version: '1.22'
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt || true
|
||||
pip install -r requirements.dev.txt
|
||||
- name: Run tests with coverage
|
||||
run: |
|
||||
# run pytest under coverage and fail if tests fail
|
||||
coverage run -m pytest -q
|
||||
coverage report -m --fail-under=75
|
||||
${{ runner.os }}-go-
|
||||
- name: Run tests
|
||||
working-directory: backend
|
||||
run: go test -v -race -coverprofile=coverage.out ./...
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
fail_ci_if_error: true
|
||||
file: backend/coverage.out
|
||||
flags: backend
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# Optional: set CODECOV_TOKEN in repo secrets if needed for private repos
|
||||
|
||||
frontend-lint:
|
||||
name: Frontend - ESLint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: frontend/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
- name: Install dependencies
|
||||
working-directory: frontend
|
||||
run: npm ci
|
||||
- name: Run ESLint
|
||||
working-directory: frontend
|
||||
run: npm run lint
|
||||
|
||||
frontend-build:
|
||||
name: Frontend - Build
|
||||
runs-on: ubuntu-latest
|
||||
needs: [frontend-lint]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: frontend/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
- name: Install dependencies
|
||||
working-directory: frontend
|
||||
run: npm ci
|
||||
- name: Build frontend
|
||||
working-directory: frontend
|
||||
run: npm run build
|
||||
|
||||
Reference in New Issue
Block a user