Rename the project to fejkdata and record the fork source #1
@@ -16,12 +16,12 @@ jobs:
|
|||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
# `docker build` streams the context to the daemon. A compose bind-mount of
|
||||||
|
# `.` mounts an empty host dir instead, because the job is itself a container.
|
||||||
- name: Latest supported Go
|
- name: Latest supported Go
|
||||||
run: docker compose run --rm ci
|
run: docker build .
|
||||||
# Runs even when the step above failed, so a red build says whether the
|
# Runs even when the step above failed, so a red build says whether the
|
||||||
# failure is version-specific.
|
# failure is version-specific.
|
||||||
- name: Lowest supported Go
|
- name: Lowest supported Go
|
||||||
if: ${{ !cancelled() }}
|
if: ${{ !cancelled() }}
|
||||||
env:
|
run: docker build --build-arg GO_VERSION=1.22.12 .
|
||||||
GO_VERSION: 1.22.12
|
|
||||||
run: docker compose run --rm ci
|
|
||||||
|
|||||||
+8
-5
@@ -1,7 +1,7 @@
|
|||||||
# Reproducible test/build image. `docker build .` fails if vet or tests fail,
|
# The merge gate: `docker build .` fails if vet, formatting or tests fail, and CI
|
||||||
# so it doubles as CI. Day-to-day, prefer `docker compose run` (bind-mounts
|
# runs exactly this. Day-to-day, prefer `docker compose run` (bind-mounts source,
|
||||||
# source, no rebuilds). GO_VERSION defaults to the latest stable Go; override it
|
# no rebuilds). GO_VERSION defaults to the latest stable Go; override it to test
|
||||||
# to test the lowest supported version: docker build --build-arg GO_VERSION=1.22 .
|
# the lowest supported version: docker build --build-arg GO_VERSION=1.22.12 .
|
||||||
ARG GO_VERSION=1.26.4
|
ARG GO_VERSION=1.26.4
|
||||||
FROM golang:${GO_VERSION}
|
FROM golang:${GO_VERSION}
|
||||||
|
|
||||||
@@ -12,4 +12,7 @@ COPY go.mod ./
|
|||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN go vet ./... && go test ./...
|
RUN go vet ./... && \
|
||||||
|
{ unformatted="$(gofmt -l .)"; test -z "$unformatted" || \
|
||||||
|
{ echo "unformatted files:"; echo "$unformatted"; exit 1; }; } && \
|
||||||
|
go test ./...
|
||||||
|
|||||||
@@ -482,7 +482,6 @@ Source is bind-mounted; build caches persist in the `gocache` volume.
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker compose run --rm test # run tests
|
docker compose run --rm test # run tests
|
||||||
docker compose run --rm ci # vet + format check + tests
|
|
||||||
docker compose run --rm cover # tests with coverage
|
docker compose run --rm cover # tests with coverage
|
||||||
docker compose run --rm bench # benchmarks
|
docker compose run --rm bench # benchmarks
|
||||||
docker compose run --rm build # compile the library
|
docker compose run --rm build # compile the library
|
||||||
@@ -497,9 +496,14 @@ docker compose run --rm --user "$(id -u):$(id -g)" fmt # gofmt -w .
|
|||||||
docker compose run --rm --user "$(id -u):$(id -g)" tidy # go mod tidy
|
docker compose run --rm --user "$(id -u):$(id -g)" tidy # go mod tidy
|
||||||
```
|
```
|
||||||
|
|
||||||
Every pull request runs `docker compose run --rm ci` against both the latest and
|
Every pull request runs `docker build .` against both the latest and the lowest
|
||||||
the lowest supported Go, and must pass before it can be merged. `docker build .`
|
supported Go, and must pass before it can be merged. That build is the whole
|
||||||
runs the same vet and tests locally.
|
gate — vet, format check and tests — so run it locally before pushing:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker build . # latest
|
||||||
|
docker build --build-arg GO_VERSION=1.22.12 . # lowest supported
|
||||||
|
```
|
||||||
|
|
||||||
Tests run against the latest Go by default. Set `GO_VERSION` to check the lowest
|
Tests run against the latest Go by default. Set `GO_VERSION` to check the lowest
|
||||||
supported version too:
|
supported version too:
|
||||||
|
|||||||
@@ -176,8 +176,9 @@ func TestRunVersion(t *testing.T) {
|
|||||||
if code != 0 {
|
if code != 0 {
|
||||||
t.Fatalf("-version = %d, stderr=%q", code, errb)
|
t.Fatalf("-version = %d, stderr=%q", code, errb)
|
||||||
}
|
}
|
||||||
if strings.TrimSpace(out) == "" {
|
version, ok := strings.CutPrefix(out, "fejkdata ")
|
||||||
t.Error("-version: want a version on stdout")
|
if !ok || strings.TrimSpace(version) == "" {
|
||||||
|
t.Errorf("-version = %q, want the command name and a version on stdout", out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-10
@@ -1,10 +1,12 @@
|
|||||||
# Docker-based dev workflow — no local tooling beyond Docker is required.
|
# Docker-based dev workflow — no local tooling beyond Docker is required.
|
||||||
#
|
#
|
||||||
# docker compose run --rm test
|
# docker compose run --rm test
|
||||||
# docker compose run --rm ci
|
|
||||||
# docker compose run --rm vet
|
# docker compose run --rm vet
|
||||||
# docker compose run --rm build
|
# docker compose run --rm build
|
||||||
#
|
#
|
||||||
|
# The full gate — vet, formatting and tests — is `docker build .`, which is what
|
||||||
|
# CI runs.
|
||||||
|
#
|
||||||
# Build caches persist in the `gocache` volume, so re-runs are fast and the
|
# Build caches persist in the `gocache` volume, so re-runs are fast and the
|
||||||
# host tree stays clean. Commands that rewrite source (fmt, tidy) keep your
|
# host tree stays clean. Commands that rewrite source (fmt, tidy) keep your
|
||||||
# ownership when run with `--user "$(id -u):$(id -g)"`.
|
# ownership when run with `--user "$(id -u):$(id -g)"`.
|
||||||
@@ -52,15 +54,6 @@ services:
|
|||||||
<<: *go
|
<<: *go
|
||||||
command: go mod tidy
|
command: go mod tidy
|
||||||
|
|
||||||
# vet + format check + tests, in one container.
|
|
||||||
ci:
|
|
||||||
<<: *go
|
|
||||||
command: >
|
|
||||||
sh -c 'go vet ./... &&
|
|
||||||
{ unformatted=$$(gofmt -l .); test -z "$$unformatted" ||
|
|
||||||
{ echo "unformatted files:"; echo "$$unformatted"; exit 1; }; } &&
|
|
||||||
go test ./...'
|
|
||||||
|
|
||||||
# Interactive shell for ad-hoc work: docker compose run --rm dev
|
# Interactive shell for ad-hoc work: docker compose run --rm dev
|
||||||
dev:
|
dev:
|
||||||
<<: *go
|
<<: *go
|
||||||
|
|||||||
Reference in New Issue
Block a user