ci: add forgejo actions workflows
This commit is contained in:
101
.forgejo/workflows/ci.yml
Normal file
101
.forgejo/workflows/ci.yml
Normal file
@@ -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 .
|
||||
26
README.md
26
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.
|
||||
|
||||
Reference in New Issue
Block a user