Skip to content

Commit

Permalink
[CONFIG] [Docker] [make] New config file for yamllint tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonzalo Diaz committed Jun 10, 2024
1 parent 45685ad commit bd4408d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 15 deletions.
1 change: 1 addition & 0 deletions .yamlignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.trunk/*
19 changes: 19 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
extends: default

ignore-from-file: .yamlignore

rules:
comments:
min-spaces-from-content: 1

# yamllint disable rule:line-length
#
# References:
# False positive: interpreting GitHub actions "on:" as a truthy value #430
# https://github.com/adrienverge/yamllint/issues/430
#
# YAML formatting not compliant with yamllint "spaces before comments" requirement #433
# https://github.com/redhat-developer/vscode-yaml/issues/433#issuecomment-1235681987
#
# yamllint enable rule:line-length
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ ENV WORKDIR=/app
WORKDIR ${WORKDIR}

###############################################################################
FROM node:22.2.0-alpine3.20 AS lint
FROM base AS lint

ENV WORKDIR=/app
WORKDIR ${WORKDIR}

COPY ./docs ${WORKDIR}/docs
RUN apk add --update --no-cache make
RUN npm install -g markdownlint-cli
RUN apk add --update --no-cache make nodejs npm
RUN apk add --update --no-cache yamllint

RUN npm install -g --ignore-scripts markdownlint-cli

# [!TIP] Use a bind-mount to lint and test "current" code against this stage
COPY ./ ${WORKDIR}/

###############################################################################
FROM base AS development
Expand Down
36 changes: 27 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,25 @@ dependencies:
$(GO) mod download
@echo "################################################################################"

lint:
gofmt -l . && echo '✔ Your code looks good.'
golangci-lint --verbose run ./...

mdlint:
lint/markdown:
markdownlint '**/*.md' --ignore node_modules && echo '✔ Your code looks good.'

lint/yaml:
yamllint --stric . && echo '✔ Your code looks good.'

lint: lint/markdown lint/yaml test/styling test/static

test/static: dependencies
golangci-lint --verbose run ./...

test/styling: dependencies
gofmt -l . && echo '✔ Your code looks good.'

coverage.out: env dependencies
$(GOTEST) -v -covermode=atomic -coverprofile="coverage.out" ./src/pkg/...

test: coverage.out
test: env dependencies coverage.out

coverage: coverage.out
$(GOCOVER) -func=coverage.out
Expand All @@ -100,16 +108,26 @@ clean:
build: env lint test

compose/build: env
docker-compose --profile lint build
docker-compose --profile testing build

compose/rebuild: env
docker-compose --profile lint build --no-cache
docker-compose --profile testing build --no-cache

compose/lint: compose/build compose/mdlint
docker-compose --profile lint run --rm algorithm-exercises-go make lint
compose/lint/markdown: compose/build
docker-compose --profile lint run --rm algorithm-exercises-go-lint make lint/markdown

compose/lint/yaml: compose/build
docker-compose --profile lint run --rm algorithm-exercises-go-lint make lint/yaml

compose/test/styling: compose/build
docker-compose --profile lint run --rm algorithm-exercises-go-lint make test/styling

compose/test/static: compose/build
docker-compose --profile lint run --rm algorithm-exercises-go-lint make test/static

compose/mdlint: env
docker-compose --profile lint run --rm algorithm-exercises-go-mdlint make mdlint
compose/lint: compose/lint/markdown compose/lint/yaml compose/test/styling compose/test/static

compose/run: compose/build
docker-compose --profile testing run --rm algorithm-exercises-go make test
Expand Down
4 changes: 2 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ services:
- ./coverage:/app/coverage
profiles: ["testing"]

algorithm-exercises-go-mdlint:
image: algorithm-exercises-go:mdlint
algorithm-exercises-go-lint:
image: algorithm-exercises-go:lint
build:
context: .
target: lint
Expand Down

0 comments on commit bd4408d

Please sign in to comment.