Merge pull request 'Continuous integration on Codeberg' (#21) from chore/ci into main
This commit is contained in:
commit
3b7e8c0d9a
4 changed files with 62 additions and 1 deletions
23
.forgejo/workflows/ci.yaml
Normal file
23
.forgejo/workflows/ci.yaml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Runs on Forgejo Actions (Codeberg). Enable Actions in the repository settings and make sure
|
||||
# a runner with the `docker` label is available; change `runs-on` if yours is named differently.
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
go:
|
||||
runs-on: docker
|
||||
container: golang:1.27
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: make go-ci
|
||||
|
||||
admin:
|
||||
runs-on: docker
|
||||
container: node:24
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: make admin-ci
|
||||
16
.forgejo/workflows/e2e.yaml
Normal file
16
.forgejo/workflows/e2e.yaml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# The end-to-end test starts Postfix and parsimony in Docker, so it needs a runner that can run
|
||||
# Docker itself. Start it by hand from the Actions tab (or run `make e2e` locally).
|
||||
name: e2e
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
e2e:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- run: make e2e
|
||||
15
Makefile
15
Makefile
|
|
@ -1,4 +1,4 @@
|
|||
.PHONY: all admin test build e2e clean
|
||||
.PHONY: all admin test build e2e clean fmt-check go-ci admin-ci ci
|
||||
|
||||
all: admin build
|
||||
|
||||
|
|
@ -13,6 +13,19 @@ test:
|
|||
go test ./...
|
||||
cd admin && npm test
|
||||
|
||||
# CI jobs. `make ci` runs them all locally, exactly as the workflow does.
|
||||
fmt-check:
|
||||
@unformatted="$$(gofmt -l .)"; if [ -n "$$unformatted" ]; then echo "gofmt needed:"; echo "$$unformatted"; exit 1; fi
|
||||
|
||||
go-ci: fmt-check
|
||||
go vet ./...
|
||||
go test -race -count=1 ./...
|
||||
|
||||
admin-ci:
|
||||
cd admin && npm ci && npm test && npm run build
|
||||
|
||||
ci: go-ci admin-ci build
|
||||
|
||||
# End-to-end test: parsimony behind a real Postfix, both in Docker (needs a running Docker daemon).
|
||||
# Set E2E_PARSIMONY_IMAGE to reuse an image instead of building one.
|
||||
e2e:
|
||||
|
|
|
|||
|
|
@ -109,12 +109,21 @@ It is served on the API listener together with `/api`, so it needs no CORS, and
|
|||
make admin # npm ci && npm run build
|
||||
make build # go build, embeds the UI
|
||||
make test # go test + vitest
|
||||
make ci # what CI runs: gofmt, vet, race tests, frontend tests and build
|
||||
make e2e # end-to-end with a real Postfix in Docker (about 2 minutes, mostly the image build)
|
||||
```
|
||||
|
||||
Without `make admin` the binary still builds and the UI answers 503 with a hint.
|
||||
For frontend work run the daemon, then `cd admin && npm run dev` (Vite proxies `/api` to `127.0.0.1:8080`).
|
||||
|
||||
## Continuous integration
|
||||
|
||||
`.forgejo/workflows/ci.yaml` runs on Forgejo Actions (Codeberg) for pushes to `main` and for pull requests:
|
||||
a Go job (`make go-ci`: gofmt, `go vet`, tests with the race detector) and an admin UI job (`make admin-ci`:
|
||||
`npm ci`, tests, type check, build). Enable Actions in the repository settings and provide a runner with the
|
||||
`docker` label (change `runs-on` if yours is named differently). `make ci` does the same locally.
|
||||
`.forgejo/workflows/e2e.yaml` runs the Postfix end-to-end test on demand, because it needs a runner that can run Docker.
|
||||
|
||||
## End-to-end test
|
||||
|
||||
`make e2e` starts a real Postfix and parsimony in Docker and walks the whole path: Postfix hands list mail to
|
||||
|
|
|
|||
Loading…
Reference in a new issue