Compare commits
1 Commits
cc6a5a00e7
...
1e21653f44
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e21653f44 |
@@ -94,13 +94,11 @@ style conventions are in separate documents:
|
|||||||
reading the Makefile.
|
reading the Makefile.
|
||||||
|
|
||||||
- Every repo should have a `Dockerfile`. All Dockerfiles must run `make check`
|
- Every repo should have a `Dockerfile`. All Dockerfiles must run `make check`
|
||||||
as a build step so the build fails if the branch is not green — the one
|
as a build step so the build fails if the branch is not green — which requires
|
||||||
exception being `Dockerfile.lint`, which runs `make lint` alone because that
|
`ARG CHECK_EPOCH` and its guard in every stage containing a check-running
|
||||||
is its entire purpose — which requires `ARG CHECK_EPOCH` and its guard in
|
`RUN`, per the `CHECK_EPOCH` rule below. Without them a Dockerfile satisfies
|
||||||
every stage containing a check-running `RUN`, per the `CHECK_EPOCH` rule
|
this criterion while its check layers are served from cache, so the build
|
||||||
below. Without them a Dockerfile satisfies this criterion while its check
|
cannot fail on a branch that is not green.
|
||||||
layers are served from cache, so the build cannot fail on a branch that is not
|
|
||||||
green.
|
|
||||||
|
|
||||||
**Every Dockerfile must also set `ENV LINT_IN_CONTAINER=1`**, above the
|
**Every Dockerfile must also set `ENV LINT_IN_CONTAINER=1`**, above the
|
||||||
checks. `script/lint` builds `Dockerfile.lint` when it is not already in a
|
checks. `script/lint` builds `Dockerfile.lint` when it is not already in a
|
||||||
@@ -126,17 +124,11 @@ style conventions are in separate documents:
|
|||||||
**after** the dependency-install layer so that layer stays cached:
|
**after** the dependency-install layer so that layer stays cached:
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
ENV LINT_IN_CONTAINER=1
|
|
||||||
ARG CHECK_EPOCH
|
ARG CHECK_EPOCH
|
||||||
RUN [ -n "$CHECK_EPOCH" ] || exit 1
|
RUN [ -n "$CHECK_EPOCH" ] || exit 1
|
||||||
RUN echo "check epoch: ${CHECK_EPOCH}" && make check
|
RUN echo "check epoch: ${CHECK_EPOCH}" && make check
|
||||||
```
|
```
|
||||||
|
|
||||||
`ENV LINT_IN_CONTAINER=1` belongs in every such stage too, and is the line
|
|
||||||
most often missed: without it `make check` reaches `script/lint`, which
|
|
||||||
tries to build `Dockerfile.lint` from inside a build step where there is no
|
|
||||||
daemon. See the containerised-lint rule below.
|
|
||||||
|
|
||||||
and in both `script/cibuild` and `script/docker`:
|
and in both `script/cibuild` and `script/docker`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -237,11 +229,6 @@ style conventions are in separate documents:
|
|||||||
cd "$ROOT"
|
cd "$ROOT"
|
||||||
|
|
||||||
if [ "${LINT_IN_CONTAINER:-}" = "1" ]; then
|
if [ "${LINT_IN_CONTAINER:-}" = "1" ]; then
|
||||||
# config verify lives here, not in a Dockerfile, so every path
|
|
||||||
# that lints inherits it — the lint stage of the main image as
|
|
||||||
# well as Dockerfile.lint. Duplicating it into each Dockerfile
|
|
||||||
# is how one of them silently loses it.
|
|
||||||
golangci-lint config verify --config .golangci.yml
|
|
||||||
exec golangci-lint run --config .golangci.yml ./...
|
exec golangci-lint run --config .golangci.yml ./...
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -276,7 +263,9 @@ style conventions are in separate documents:
|
|||||||
# ARG after the dependency layer so only the lint re-runs.
|
# ARG after the dependency layer so only the lint re-runs.
|
||||||
ARG CHECK_EPOCH
|
ARG CHECK_EPOCH
|
||||||
RUN [ -n "$CHECK_EPOCH" ] || exit 1
|
RUN [ -n "$CHECK_EPOCH" ] || exit 1
|
||||||
RUN echo "lint epoch: ${CHECK_EPOCH}" && make lint
|
RUN echo "lint epoch: ${CHECK_EPOCH}" && \
|
||||||
|
golangci-lint config verify --config .golangci.yml
|
||||||
|
RUN make lint
|
||||||
```
|
```
|
||||||
|
|
||||||
Load-bearing properties:
|
Load-bearing properties:
|
||||||
@@ -298,10 +287,7 @@ style conventions are in separate documents:
|
|||||||
- **Non-Go repos get the same pattern around their own linter** — `eslint`,
|
- **Non-Go repos get the same pattern around their own linter** — `eslint`,
|
||||||
`ruff`, `prettier`, `shellcheck`. Only the base image and the native lint
|
`ruff`, `prettier`, `shellcheck`. Only the base image and the native lint
|
||||||
command change.
|
command change.
|
||||||
- **Keep `golangci-lint config verify`, put it in `script/lint`, and it
|
- **Keep `golangci-lint config verify`, and it costs no network.** The two
|
||||||
costs no network.** It goes in the native branch, not in a Dockerfile, so
|
|
||||||
the lint stage of the main image inherits it along with `Dockerfile.lint`;
|
|
||||||
putting it in one Dockerfile leaves the other path unverified. The two
|
|
||||||
commands catch disjoint classes, measured under the pinned v2.12.2: a
|
commands catch disjoint classes, measured under the pinned v2.12.2: a
|
||||||
bogus top-level key and a bogus key under `linters.settings.lll` both pass
|
bogus top-level key and a bogus key under `linters.settings.lll` both pass
|
||||||
`golangci-lint run` with **exit 0 and `0 issues`** while `config verify`
|
`golangci-lint run` with **exit 0 and `0 issues`** while `config verify`
|
||||||
@@ -338,9 +324,9 @@ style conventions are in separate documents:
|
|||||||
3. Add `ENV LINT_IN_CONTAINER=1` to **every** stage of every Dockerfile that
|
3. Add `ENV LINT_IN_CONTAINER=1` to **every** stage of every Dockerfile that
|
||||||
runs checks — the lint stage and the build stage both.
|
runs checks — the lint stage and the build stage both.
|
||||||
4. Delete any golangci-lint install from `script/bootstrap`, with its
|
4. Delete any golangci-lint install from `script/bootstrap`, with its
|
||||||
version and ref variables and its call site. No lint verdict comes from
|
version and ref variables and its call site. Nothing on the host lints,
|
||||||
the host any more, so it can only reintroduce version skew. A JS repo's
|
so it can only reintroduce version skew. A JS repo's `yarn install`
|
||||||
`yarn install` stays.
|
stays.
|
||||||
5. Delete the per-checkout lint state: `GOLANGCI_LINT_CACHE` and `TMPDIR`
|
5. Delete the per-checkout lint state: `GOLANGCI_LINT_CACHE` and `TMPDIR`
|
||||||
exports, `--allow-serial-runners`, the retry/VOID wrapper, and
|
exports, `--allow-serial-runners`, the retry/VOID wrapper, and
|
||||||
`.lint-cache/` from both `.gitignore` and `.dockerignore`.
|
`.lint-cache/` from both `.gitignore` and `.dockerignore`.
|
||||||
|
|||||||
Reference in New Issue
Block a user