Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ jobs:
run: >
make compose/lint/yaml

run-lint-json:
name: "Run in docker: JSON LINT"
runs-on: ubuntu-26.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

- name: Run JSON lint
run: >
make compose/lint/json

run-lint:
name: "Run in docker: LINT"
runs-on: ubuntu-26.04
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/prettier-json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Prettier JSON Lint

on: # yamllint disable-line rule:truthy
push:
branches: ["main"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["main"]
workflow_dispatch:

jobs:
json-lint:
name: "Prettier JSON Lint"
runs-on: ["ubuntu-26.04"]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: 26.x

- name: Install Prettier
run: |
npm install -g --ignore-scripts prettier@3.9.8

- name: Tool check
run: |
prettier --version

- name: Prettier LINT / Style JSON
run: >
prettier --check ./**/*.json
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*.json
7 changes: 7 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
singleQuote: true
quoteProps: preserve
useTabs: false
printWidth: 80
tabWidth: 2
trailingComma: none
20 changes: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@ lint/markdown:
lint/yaml:
yamllint --strict . && echo '✔ Your code looks good.'

lint/json:
prettier --check ./src/**/*.json

lint: test/styling test/static
lint-no-deps: test/styling test/static-no-deps

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

test/static-no-deps:
cppcheck \
Expand All @@ -107,9 +110,14 @@ test/static: prebuild test/static-no-deps
test/styling:
clang-format --dry-run --Werror $(FILES)

format:
format/sources:
clang-format -i --verbose $(FILES)

format/json:
prettier --write ./src/**/*.json

format: format/sources format/json

test: env dependencies build clean/test
cd build && make test

Expand Down Expand Up @@ -152,14 +160,20 @@ compose/lint/markdown:
markdownlint --config /workspace/.markdownlint.json '/workspace/**/*.md' \
&& echo '✔ Your code looks good.'


compose/lint/yaml:
${DOCKER_COMPOSE} --profile lint run --rm \
--workdir /workspace \
-v "$$(pwd):/workspace" \
yamllint --strict /workspace \
&& echo '✔ Your code looks good.'

compose/lint/json:
${DOCKER_COMPOSE} --profile lint run --rm \
--workdir /workspace \
-v "$$(pwd):/workspace" \
prettier --check /workspace/**/*.json \
&& echo '✔ Your code looks good.'

compose/test/styling: compose/build
${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-c-lint make test/styling

Expand Down
19 changes: 13 additions & 6 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
BRUTEFORCE: ${BRUTEFORCE:-false} ## (1) ## true | false
volumes:
- ./coverage:/app/coverage
profiles: ["testing"]
profiles: ['testing']

algorithm-exercises-cpp-lint:
image: algorithm-exercises-cpp:lint
Expand All @@ -21,21 +21,28 @@ services:
- ./.clang-format:/app/.clang-format
- ./Makefile:/app/Makefile
- ./src:/app/src
profiles: ["lint"]
profiles: ['lint']

markdownlint:
image: goncl/markdownlint-cli:latest
working_dir: /workspace
volumes:
- ./:/workspace
profiles: ["lint"]
profiles: ['lint']

yamllint:
image: goncl/yamllint:latest
working_dir: /workspace
volumes:
- ./:/workspace
profiles: ["lint"]
profiles: ['lint']

prettier:
image: goncl/prettier:3.9.8
working_dir: /workspace
volumes:
- ./:/workspace
profiles: ['lint']

algorithm-exercises-cpp-dev:
image: algorithm-exercises-cpp:dev
Expand All @@ -47,7 +54,7 @@ services:
BRUTEFORCE: ${BRUTEFORCE:-false} ## (1) ## true | false
volumes:
- ./:/app
profiles: ["development"]
profiles: ['development']

algorithm-exercises-cpp:
image: algorithm-exercises-cpp:latest
Expand All @@ -56,7 +63,7 @@ services:
target: production
# volumes:
# - ./:/app
profiles: ["production"]
profiles: ['production']

## REFERENCES:
## (1) Passing Environment variable with fallback value:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[
{"input": [3, 2, 1, 3], "expected": 2},
{"input": [1, 2, 3, 3], "expected": 2}
{ "input": [3, 2, 1, 3], "expected": 2 },
{ "input": [1, 2, 3, 3], "expected": 2 }
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{ "matrix":
[
{
"matrix": [
[11, 2, 4],
[4, 5, 6],
[10, 8, -12]
Expand Down
Loading