From e6ae8a755f87e93ccfde96858fc42a09acca76dd Mon Sep 17 00:00:00 2001 From: Darius Neatu Date: Tue, 25 Jun 2024 03:24:59 +0300 Subject: [PATCH] Configure linters for C++, MD and Shell --- .markdownlint.json | 3 +++ .shellcheckrc | 2 ++ README.md | 20 +++++++++++--------- examples/README.md | 3 ++- scripts/lint-all.sh | 26 ++++++++++++++++++++++++++ scripts/test-all.sh | 2 +- 6 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 .markdownlint.json create mode 100644 .shellcheckrc create mode 100755 scripts/lint-all.sh diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 00000000..1344b312 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,3 @@ +{ + "MD013": false +} diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 00000000..fcb6401e --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1,2 @@ +# shellcheck +disable=SC2038 diff --git a/README.md b/README.md index b981a473..251124a8 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ SPDX-License-Identifier: 2.0 license with LLVM exceptions This repository implements `std::optional` extensions targeting C++26. The `Beman.Optional26` library aims to evaluate the stability, the usability, and the performance of these proposed changes before they are officially adopted by WG21 into the C++ Working Draft. Additionally, it allows developers to use these new features before they are implemented in major standard library compilers. **Implements**: + * [Give *std::optional* Range Support (P3168R1)](https://wg21.link/P3168R1) * [`std::optional` (P2988R5)](https://wg21.link/P2988R5) @@ -16,7 +17,6 @@ Source, documentation and associated papers are licensed with the Apache 2.0 lic // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - ## Examples Full runable examples can be found in `examples/` - please check [./examples/README.md](./examples/README.md). @@ -91,11 +91,12 @@ This project is mainly tested on `Ubuntu 22.04` and `Ubuntu 24.04`, but it shoul Build-time dependencies: -- `cmake` -- `ninja`, `make`, or another CMake-supported build system - - CMake defaults to "Unix Makefiles" on POSIX systems +* `cmake` +* `ninja`, `make`, or another CMake-supported build system + * CMake defaults to "Unix Makefiles" on POSIX systems Example of installation on `Ubuntu 24.04`: + ```shell # Install tools: apt-get install -y cmake make ninja-build @@ -108,7 +109,7 @@ apt-get install \ ### Instructions -Full set of supported toolchains can be found in [.github/workflows/ci.yml](#.github/workflows/ci.yml). +Full set of supported toolchains can be found in [.github/workflows/ci.yml](.github/workflows/ci.yml). #### Basic Build @@ -168,14 +169,15 @@ The makefile will use your system compiler, `c++`, if no toolchain name is provi ## Papers Latest revision(s) of the papers can be built / found at: + * [give-std-optional-range-support](https://github.com/neatudarius/give-std-optional-range-support/) for `Give *std::optional* Range Support (P3168)` - * issue: [#1831](https://github.com/cplusplus/papers/issues/1831) + * issue: [#1831](https://github.com/cplusplus/papers/issues/1831) * LEWG: * Reviewed in Tokyo 2024. * Forwarded by LEWG April electronic poll to LWG. * LWG: * To be reviewed in Saint Louis 2024. * [./papers/P2988/README.md](./papers/P2988/README.md) for `std::optional (P2988)`. - * issue: [#1661](https://github.com/cplusplus/papers/issues/1661) - * LEWG: - * Reviewed in Tokyo 2024. + * issue: [#1661](https://github.com/cplusplus/papers/issues/1661) + * LEWG: + * Reviewed in Tokyo 2024. diff --git a/examples/README.md b/examples/README.md index 3d60a577..fdeb75a0 100644 --- a/examples/README.md +++ b/examples/README.md @@ -11,6 +11,7 @@ List of usage examples for `Beman.Optional26`. Check [sample](sample.cpp) for basic `Beman.Optional26` library usage. Build and run instructions: + ```shell # build $ cmake --workflow --preset gcc-14 @@ -29,10 +30,10 @@ std_vs_beman: .value() matches?: yes ## Range Support (P3168R1) Range support added in [*Give std::optional Range Support* (P3168R1)](https://wg21.link/P3168R1) examples: + * [./range_loop.cpp](./range_loop.cpp) * [./pythagorean_triples.cpp](./pythagorean_triples.cpp) - Build and run instructions: ```shell diff --git a/scripts/lint-all.sh b/scripts/lint-all.sh new file mode 100755 index 00000000..78113521 --- /dev/null +++ b/scripts/lint-all.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Lint all files in the project. +# Expected to be run from the root of the project. +# Expected tools to be installed on the system. +# Usage: ./scripts/lint-all.sh + +set -e +set -x + +# Lint all C++ files in the project. +find include/ examples/ src/ -name "*.h" -o -name "*.cpp" | xargs clang-format -i -style=file || echo "clang-format failed." +echo "All C++ files were linted." + +# Lint all scripts in the project. +find scripts/ -name "*.sh" | xargs shellcheck || echo "shellcheck failed." +echo "All scripts files were linted." + +# TODO: Lint all CMake files in the project. +# echo "All CMake files were linted." + +# Lint all Markdown files in the project. +find README.md examples/ -name "*.md" | xargs markdownlint -f || echo "markdownlint failed." +echo "All Markdown files were linted." diff --git a/scripts/test-all.sh b/scripts/test-all.sh index ee5dbda2..1c407f02 100644 --- a/scripts/test-all.sh +++ b/scripts/test-all.sh @@ -10,7 +10,7 @@ set -e set -x -# rm -rf .build +rm -rf .build cmake --workflow --preset gcc-14 &> /dev/null && echo "passed" || echo "gcc-14 test failed." cmake --workflow --preset gcc-13 &> /dev/null && echo "passed" || echo "gcc-13 test failed."