From 34d8620d752da172db91bb3395130b450f6139a1 Mon Sep 17 00:00:00 2001 From: xray33 Date: Sun, 11 Oct 2026 09:52:39 +0300 Subject: [PATCH 1/4] ci: add GitHub Actions workflow and CI documentation --- .github/workflows/ci.yml | 117 +++++++++++++++++++++++++++++++++++++++ AGENTS.md | 3 +- Makefile | 9 ++- README.md | 1 + 4 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..326d459 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,117 @@ +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: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: latest + args: --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: actions/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 diff --git a/AGENTS.md b/AGENTS.md index 290e396..d786f39 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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**: diff --git a/Makefile b/Makefile index 02e91cf..b5f1ccd 100644 --- a/Makefile +++ b/Makefile @@ -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") @@ -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 ./... @@ -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 diff --git a/README.md b/README.md index 4ef5edb..ba11146 100644 --- a/README.md +++ b/README.md @@ -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. From 763afcceb2b6d40260a6b91a4f77922bc7047ed2 Mon Sep 17 00:00:00 2001 From: xray33 Date: Sun, 11 Oct 2026 10:08:09 +0300 Subject: [PATCH 2/4] ci: fix setup-buildx action and compile golangci-lint with go 1.26 --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 326d459..b2c6928 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,7 @@ jobs: uses: golangci/golangci-lint-action@v6 with: version: latest + install-mode: go args: --timeout=5m backend-test: @@ -98,7 +99,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Docker Buildx - uses: actions/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v3 - name: Build Backend Docker Image uses: docker/build-push-action@v6 From 7d0a8066a7aeab62d94e303d0674dc2dbe5b4169 Mon Sep 17 00:00:00 2001 From: xray33 Date: Sun, 11 Oct 2026 10:12:30 +0300 Subject: [PATCH 3/4] ci: compile golangci-lint directly with Go 1.26 --- .github/workflows/ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2c6928..4e20654 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,12 +25,13 @@ jobs: go-version-file: 'go.mod' cache: false + - name: Install golangci-lint + run: | + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + - name: Run golangci-lint - uses: golangci/golangci-lint-action@v6 - with: - version: latest - install-mode: go - args: --timeout=5m + run: | + golangci-lint run --timeout=5m ./... backend-test: name: Backend Tests & Build From eee9d059cfb962510038c0f2f21a100c75b0e05f Mon Sep 17 00:00:00 2001 From: xray33 Date: Sun, 11 Oct 2026 10:18:43 +0300 Subject: [PATCH 4/4] ci: install golangci-lint v2 for Go 1.26 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e20654..154e728 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - name: Install golangci-lint run: | - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest - name: Run golangci-lint run: |