From 98e6ca64d1df87da6b1dc15e99b4387aa460d7e1 Mon Sep 17 00:00:00 2001 From: mkelvers Date: Wed, 27 May 2026 20:50:37 +0200 Subject: [PATCH] ci: add forgejo actions workflows --- .forgejo/workflows/ci.yml | 101 ++++++++++++++++++++++++++++++++++++++ README.md | 26 ++++++++++ 2 files changed, 127 insertions(+) create mode 100644 .forgejo/workflows/ci.yml diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 0000000..7b180bc --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -0,0 +1,101 @@ +name: ci + +on: + push: + branches: ['**'] + pull_request: + schedule: + - cron: '0 2 * * *' + workflow_dispatch: + +concurrency: + group: 'ci-${{ forgejo.ref }}' + cancel-in-progress: true + +jobs: + go: + name: go (fmt, test, lint, build) + runs-on: docker + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Check gofmt + shell: bash + run: | + unformatted="$(gofmt -l .)" + if [[ -n "${unformatted}" ]]; then + echo "gofmt needed on:" + echo "${unformatted}" + exit 1 + fi + + - name: Run go tests + run: go test ./... + + - name: Run go tests (race) + env: + CGO_ENABLED: '1' + run: go test -race ./... + + - name: Build server binary + run: go build -o server ./cmd/server + + - name: Install golangci-lint + run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + + - name: Run golangci-lint + run: golangci-lint run ./... + + - name: Check go.mod tidy + shell: bash + run: | + go mod tidy + if ! git diff --exit-code -- go.mod go.sum; then + echo "go.mod/go.sum changed after 'go mod tidy'." + echo "Run: go mod tidy" + exit 1 + fi + + ts: + name: ts (format, lint, typecheck, build) + runs-on: docker + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Check prettier formatting + run: bunx prettier . --check + + - name: Run eslint + run: bun run lint:ts + + - name: Typecheck + run: bun run typecheck + + - name: Build assets + run: bun run build:assets + + docker: + name: docker (build) + runs-on: docker + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker build + run: docker build --pull --no-cache -t mal:ci . diff --git a/README.md b/README.md index 13b5b1e..e9bcafd 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,32 @@ The schedule board requires an API key from [animeschedule.net](https://animesch just dev ``` +## CI + +This repo uses Forgejo Actions workflows in `.forgejo/workflows/`: + +- `ci.yml`: main PR/push checks (Go + TS) +- `go-deep.yml`: extra Go checks (mod tidy + race) +- `frontend.yml`: frontend-only checks +- `docker.yml`: Docker build verification +- `nightly.yml`: scheduled “full” checks (incl. race + docker build) + +Local equivalents: + +```bash +gofmt -l . +go test ./... +go build -o server ./cmd/server +golangci-lint run ./... +go mod tidy +go test -race ./... +bunx prettier . --check +bun run lint:ts +bun run typecheck +bun run build:assets +docker build -t mal:ci . +``` + ## Contributing Bug reports and pull requests are welcome. This is a personal project, so there is no strict roadmap or issue triage cycle. If something is broken or missing, open an issue or send a PR.