- Go 86.5%
- Dockerfile 13.5%
The README opened with `# Go` and never said what the service does. It now: - names the service and documents its two routes and `PORT` - links the places worth a look: #6, the CI runs, releases, the container image, #5, and the list of what Codebahn does not have - describes CI as it runs after #9 (pull requests, pushes to `main`, and a weekly build) - adds a Releases section for the workflow in #10 - links the current docs paths (`/docs/ci-runners/` instead of the old `/docs/features/ci-runners/` redirect) Links use full `codebahn.net` URLs so the same README works on the GitHub copy. From there, a signed-out reader lands on the login page until signed-out deep links into the demo ship (codebahn-forgejo #312); after that they open the page itself. Merge after #9 and #10, and after `v1.0.0` exists, so every link on the page lands on something. Reviewed-on: #11 |
||
|---|---|---|
| .github/workflows | ||
| .gitignore | ||
| Dockerfile | ||
| go.mod | ||
| main.go | ||
| main_test.go | ||
| README.md | ||
Go HTTP service
A small Go web service with tests, a container image and versioned releases.
| Route | Response |
|---|---|
GET /health |
ok |
GET /hello?name=Ada |
Hello, Ada! (the name defaults to world) |
It listens on PORT, or 8080 when that is unset.
This is one of Codebahn's example repositories. Its home is codebahn.net, where you can browse it read-only without an account.
Look around
- Pull request #6: a smoke test that had never probed anything, the red runs that gave it away, and the fix.
- CI runs: every pull request, every push to
mainand a weekly build, with full logs. - Releases: binaries built and attached for each version tag.
- Container image: pushed to the built-in registry for each version tag.
- Pull request #5: an open change with review comments and passing checks.
- What Codebahn does not have: worth reading before you move.
CI
ci.yml is a GitHub Actions workflow, unchanged. On Codebahn:
.github/workflows/is read directly. There is no.forgejo/directory.runs-on: ubuntu-latestroutes to a Codebahn runner in Paris.actions/checkoutandactions/setup-goresolve from GitHub automatically.
On every pull request, every push to main, and every Monday morning it:
- Runs
go vetandgo test - Builds the container image
- Starts the container and checks that
/healthanswers
Need more than the 3 GB default? Set runs-on: codebahn-medium for 7 GB. See CI runners.
Releases
Push a version tag to publish one:
git tag v1.1.0
git push origin v1.1.0
release.yml pushes codebahn.net/demo-org/example-go:1.1.0 and :latest to the container registry, then publishes a release with static binaries for Linux, macOS and Windows plus SHA256SUMS. Both steps authenticate with the job's built-in token, so there are no secrets to configure. See Publish container images.
Run locally
go test ./...
go run .
# or
docker build -t example-go . && docker run -p 8080:8080 example-go