diff --git a/README.md b/README.md index 8e5a564..fc5ccd9 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,6 @@ In various places across the ILF ecosystem we need custom built images. Quite of Image: Chart Validator Description: Kustomize, Helm, GCloud SDK and Kubeconform. For easy chart validation. +Image: Go Tester +Description: Go 1.25, golangci-lint, Atlas CLI, and PostgreSQL client. Pre-built image for running Go unit tests, mock-service tests, and linting in CI. + diff --git a/gotester/Dockerfile b/gotester/Dockerfile new file mode 100644 index 0000000..da85dcb --- /dev/null +++ b/gotester/Dockerfile @@ -0,0 +1,36 @@ +FROM golang:1.25-alpine + +# System dependencies needed by both go-test and mock-tester CI workflows: +# bash - shell scripts in CI steps +# bc - floating-point coverage threshold comparison +# curl - downloading tools (Atlas CLI) +# git - Go modules, golangci-lint VCS checks +# grep - GNU grep with -P (PCRE) for extracting coverage thresholds +# make - mock service Makefiles +# postgresql17-client - pg_isready to wait for Postgres service containers +RUN apk add --no-cache \ + bash \ + bc \ + curl \ + git \ + grep \ + make \ + postgresql17-client + +# golangci-lint v2.5.0 — used by both mock-tester and linting workflows +# Installed from versioned release artifact with checksum verification. +ARG GOLANGCI_LINT_VERSION=2.5.0 +ARG GOLANGCI_LINT_SHA256=c77313a77e19b06123962c411d9943cc0d092bbec76b956104d18964e274902e +RUN curl -sSfL "https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz" \ + -o /tmp/golangci-lint.tar.gz \ + && echo "${GOLANGCI_LINT_SHA256} /tmp/golangci-lint.tar.gz" | sha256sum -c - \ + && tar -xzf /tmp/golangci-lint.tar.gz -C /tmp \ + && mv /tmp/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64/golangci-lint /usr/local/bin/ \ + && rm -rf /tmp/golangci-lint* + +# Atlas CLI — generates test migrations for backend/pacioli database schemas +# Pinned to a specific version via ATLAS_VERSION; bump the ARG to upgrade. +ARG ATLAS_VERSION=v1.2.0 +RUN ATLAS_VERSION=${ATLAS_VERSION} curl -sSf https://atlasgo.sh | sh + +WORKDIR /app diff --git a/gotester/README.md b/gotester/README.md new file mode 100644 index 0000000..ecd4996 --- /dev/null +++ b/gotester/README.md @@ -0,0 +1,47 @@ +# Go Tester + +Pre-built image for running Go unit tests, mock-service tests, and linting in the [interledger-app](https://github.com/interledger/interledger-app) CI pipeline. + +## What's inside + +| Tool | Version | Purpose | +|------|---------|---------| +| Go | 1.25 | Compile and test Go code | +| golangci-lint | 2.5.0 | Lint all Go packages | +| Atlas CLI | 1.2.0 | Generate database test migrations | +| PostgreSQL 17 client | 17.x | `pg_isready` to wait for Postgres service containers | +| GNU grep (PCRE) | — | Extract coverage thresholds with `-oP` | +| bc | — | Floating-point coverage comparison | +| make | — | Run mock-service Makefiles | +| bash, git, curl | — | Standard CI utilities | + +## Replaces + +This single image replaces the tool-installation steps in two interledger-app workflow templates: + +- **`go-test-template.yml`** — `setup-go`, `Install Atlas CLI`, `pg_isready` wait loop +- **`mock-tester.yml`** — `setup-go`, `golangci-lint-action`, Docker setup + +## Usage + +```yaml +# GitHub Actions example +jobs: + test: + runs-on: ubuntu-latest + container: + image: ghcr.io/interledger/builders/gotester:latest + services: + postgres: + image: postgres:17 + steps: + - uses: actions/checkout@v4 + - run: go test -coverprofile=coverage.out ./go/backend/... +``` + +## Building locally + +```bash +cd gotester +docker build -t gotester . +```