Ran the installed ocdsgen, and added a script that installs the dev tools

go generate ran ocdsgen with go run, from go.mod, but go-ocds had been
dropped from go.mod (nothing imports it, so go mod tidy removes it), which
broke go generate and so scripts/build.sh. It now runs the installed
ocdsgen from PATH, as it does swag.

scripts/install-dev-tools.sh installs the Go tools (ocdsgen v1.0.0 and swag
v2.0.0-rc6 pinned, as other versions could generate different code;
golangci-lint, goose and cobra-cli at their latest), checks for Node.js 24
or later and runs npm ci in web/. The README's dev tools section now points
to it and lists what each tool is for.
This commit is contained in:
bwilliams committed 2026-10-16 16:03:48 +01:00
1 parent 5e6c011ecb
commit 1988d07a29
3 files changed
+83 -18

No files matched your search

+21 -17
View File
@@ -18,7 +18,8 @@ scripts/build.sh --release # also package release/job-search-<version>-
The build script builds the frontend and copies it into place for embedding
(`npm run build` and `npm run sync` in `web/`, which need Node and npm; it
runs `npm ci` first for a release, or when `web/node_modules` is missing). It
then runs `go generate ./...`, which needs `swag` installed (see
then runs `go generate ./...`, which needs `ocdsgen` and `swag` installed
(`scripts/install-dev-tools.sh`; see
[Installation of dev tools](#installation-of-dev-tools)), and stamps the
version from the latest git tag. A build from untagged commits is marked as a development build
and isn't packaged unless `--force` is also given.
@@ -246,24 +247,27 @@ Using a source called `example` as an illustration:
## Installation of dev tools
A number of tools have been used in the development of the project. Installation
of these tools can be done using `go install`.
`scripts/install-dev-tools.sh` installs everything needed to develop and
build the project: the Go tools below, with `go install`, and the frontend's
npm packages (`npm ci` in `web/`). It needs Go and Node.js 24 or later (with
npm), as the frontend's scripts run TypeScript directly. Run it again after
a tool's version in it changes.
To install the tools:
```bash
go install github.com/spf13/cobra-cli@latest
go install git.avsdev.uk/Go/go-ocds/cmd/ocdsgen@latest
go install github.com/pressly/goose/v3/cmd/goose@latest
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
go install github.com/swaggo/swag/v2/cmd/swag@v2.0.0-rc6
scripts/install-dev-tools.sh
```
`goose` creates new migration files (see `internal/store`); the migrations
themselves are applied by `job-search migrate`. `golangci-lint` uses the
project's `.golangci.json`. `swag` generates the API's OpenAPI 3.1 spec from
the handlers' comments (`swag init --v3.1`). Its v2, the version with OpenAPI
3 support, has only had release candidates so far, so it is pinned to one
rather than `@latest`.
| Tool | Version | Used for |
|---|---|---|
| `ocdsgen` (`git.avsdev.uk/Go/go-ocds`) | v1.0.0 | Generates the OCDS types in `internal/findatender/ocds` (`ocds_gen.go`) from `extensions.json`, run by `go generate` |
| `swag` | v2.0.0-rc6 | Generates the API's OpenAPI 3.1 description from the handlers' comments (`swag init --v3.1`), run by `go generate` |
| `golangci-lint` | latest | Lints the Go code with the project's `.golangci.json` |
| `goose` | latest | Creates new migration files (see `internal/store`); the migrations themselves are applied by `job-search migrate` |
| `cobra-cli` | latest | Adds cobra commands |
Ensure that the GOBIN path ($HOME/go/bin) is added to the environment before
running any of the tools.
The generators are pinned, as another version could generate different code.
`swag`'s v2, the version with OpenAPI 3 support, has only had release
candidates so far. `go generate ./...` and the build script run the
generators from PATH, so ensure that the GOBIN path (`$HOME/go/bin` by
default) is added to the environment before running any of the tools; the
script says if it isn't.