README.md (1510B)
1 # 00 — Golang Lint, Build & Test 2 3 A minimal Jaypore CI example that lints, builds, tests, and optionally 4 publishes a Go HTTP server. 5 6 ## What's in the box 7 8 | File | Purpose | 9 |---|---| 10 | `main.go` | Tiny HTTP server with a `/health` endpoint (`{"status":"ok"}`) | 11 | `main_test.go` | Tests for status code, content-type, and response body | 12 | `.jci/run.sh` | CI pipeline script executed by Jaypore CI | 13 14 ## Pipeline steps 15 16 1. **Module init** — runs `go mod init` if no `go.mod` is present. 17 2. **Lint** — `go vet ./...` (report saved to `$JCI_OUTPUT_DIR/vet-report.txt`). 18 3. **Format check** — `gofmt -l .` fails the build if any file is unformatted. 19 4. **Build** — compiles the binary to `$JCI_OUTPUT_DIR/server`. 20 5. **Test** — `go test -v -cover ./...` (results saved to `$JCI_OUTPUT_DIR/test-results.txt`). 21 6. **Publish** — copies the binary to `$PUBLISH_DIR` when the variable is set; 22 skips gracefully otherwise. 23 24 ## Environment variables 25 26 | Variable | Provided by | Description | 27 |---|---|---| 28 | `JCI_COMMIT` | Jaypore CI | Git commit SHA being built | 29 | `JCI_REPO_ROOT` | Jaypore CI | Absolute path to the repository root | 30 | `JCI_OUTPUT_DIR` | Jaypore CI | Directory for build artefacts (also the initial cwd) | 31 | `PUBLISH_DIR` | User (optional) | If set, the binary is copied here after a successful build | 32 33 ## Running locally 34 35 ```bash 36 export JCI_COMMIT=$(git rev-parse HEAD) 37 export JCI_REPO_ROOT=$(pwd) 38 export JCI_OUTPUT_DIR=$(mktemp -d) 39 bash 00-golang-lint-build-test/.jci/run.sh 40 ```