diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..eac1fae --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,23 @@ +name: ci + +on: + pull_request: + push: + branches: [main] + +jobs: + check: + name: build and test + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: false + + - name: Run checks + run: ./scripts/check.sh diff --git a/docs/workflow.md b/docs/workflow.md index 90b4c25..52bc521 100644 --- a/docs/workflow.md +++ b/docs/workflow.md @@ -18,6 +18,28 @@ It works with any project type and supports monorepos. --- +## Continuous Integration + +Every pull request and every push to `main` runs the `ci` workflow in +[`.gitea/workflows/ci.yml`](../.gitea/workflows/ci.yml). Its single `check` job +runs [`scripts/check.sh`](../scripts/check.sh), which: + +1. fails if any Go file is not `gofmt`-formatted, +2. runs `go mod verify` to confirm the dependency modules match `go.sum`, +3. runs `go vet ./...` and `go build ./...`, +4. runs `go test -cover ./...`. + +Run the same checks locally with: + +```sh +./scripts/check.sh +``` + +The job fails when any check fails, so a pull request cannot land with broken +code or tests. + +--- + ## Two Release Workflows ### Direct release @@ -483,4 +505,4 @@ Tag format: `@v` for monorepos (e.g. `my-app@v1.3.0`), or `v gofmt' +unformatted="$(gofmt -l .)" +if [ -n "$unformatted" ]; then + echo 'These files are not gofmt-formatted:' >&2 + printf '%s\n' "$unformatted" >&2 + exit 1 +fi + +echo '==> go mod verify' +go mod verify + +echo '==> go vet' +go vet ./... + +echo '==> go build' +go build ./... + +echo '==> go test' +go test -cover ./...