108 lines
2.3 KiB
YAML
108 lines
2.3 KiB
YAML
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/v2/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 formatting
|
|
run: bun run format:check
|
|
|
|
- name: Run oxlint
|
|
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
|
|
shell: bash
|
|
run: |
|
|
if ! command -v docker &>/dev/null; then
|
|
echo "docker not found — skipping"
|
|
exit 0
|
|
fi
|
|
docker build --pull --no-cache -t mal:ci .
|