Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
backend-lint:
name: Backend Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: false

- name: Install golangci-lint
run: |
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest

- name: Run golangci-lint
run: |
golangci-lint run --timeout=5m ./...

backend-test:
name: Backend Tests & Build
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:11
env:
MARIADB_ROOT_PASSWORD: root_password
MARIADB_DATABASE: selfcloud
MARIADB_USER: selfcloud
MARIADB_PASSWORD: selfcloud_pass
ports:
- 3306:3306
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval 5s --health-timeout 5s --health-retries 10
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Run Unit & Functional Tests
env:
DB_DSN: "selfcloud:selfcloud_pass@tcp(127.0.0.1:3306)/selfcloud?parseTime=true"
run: |
go test -v -race -coverprofile=coverage.out ./...

- name: Build Backend Binary
run: |
go build -v -ldflags="-X main.buildVersion=${{ github.sha }} -X main.buildCommit=${{ github.sha }}" -o bin/selfcloud ./cmd/selfcloud

frontend-check:
name: Frontend Lint & Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: web
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
cache-dependency-path: web/package-lock.json

- name: Install dependencies
run: npm ci

- name: TypeScript Lint / Typecheck
run: npm run lint

- name: Build Web UI
run: npm run build

docker-build:
name: Docker Build Verification
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Backend Docker Image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: false
tags: selfcloud-backend:test

- name: Build Web Docker Image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.web
push: false
tags: selfcloud-web:test
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ It allows ownCloud desktop sync clients, mobile apps, and modern web browsers to
- `/`: Single-binary serving of compiled React Web UI static assets (`web/dist`).

## 5. Development & Testing Commands
- **Linting**: Run `make lint` (Go linter) and `make ui-build` (React typecheck & build).
- **CI & Pre-Commit Check**: Run `make ci` (runs Go lint, Go tests, UI lint, UI build, and backend build).
- **Linting**: Run `make lint` (Go linter) and `make ui-lint` / `make ui-build` (React typecheck & build).
- **Tests**: Run `make test` (runs unit & functional tests against MariaDB configured via `DB_DSN`).
- **Build**: Run `make build` (compiles `bin/selfcloud`) and `make ui-build` (builds `web/dist`).
- **Docker Targets**:
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all lint test test-coverage build docker-build docker-build-backend docker-build-web docker-up docker-down docker-logs docker-clean up-db down-db clean
.PHONY: all lint test test-coverage build docker-build docker-build-backend docker-build-web docker-up docker-down docker-logs docker-clean up-db down-db clean ui-install ui-build ui-lint ui-dev ci check

ENV_PATH := PATH="$(HOME)/.goenv/shims:/opt/homebrew/bin:/usr/local/bin:$(PATH)"
GIT_COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "latest")
Expand All @@ -12,6 +12,8 @@ LDFLAGS := -X main.buildVersion=$(IMAGE_TAG) -X main.buildCommit=$(GIT_COMMI

all: lint test build

ci: lint test ui-lint ui-build build

lint:
$(ENV_PATH) golangci-lint run ./...

Expand Down Expand Up @@ -59,9 +61,14 @@ ui-install:
ui-build:
$(MAKE) -C web build

ui-lint:
$(MAKE) -C web lint

ui-dev:
$(MAKE) -C web dev

check: ci

clean:
rm -rf bin/
$(MAKE) -C web clean
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Go Version](https://img.shields.io/badge/Go-1.26-00ADD8?style=flat&logo=go)](https://golang.org/)
[![React Version](https://img.shields.io/badge/React-19.0-61DAFB?style=flat&logo=react)](https://react.dev/)
[![CI](https://github.com/xray33/selfcloud/actions/workflows/ci.yml/badge.svg)](https://github.com/xray33/selfcloud/actions/workflows/ci.yml)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

**SelfCloud** is a lightweight, high-performance, 100% ownCloud-compatible WebDAV backend server and modern Web UI written in Go and React.
Expand Down
Loading