diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 06cb09ae1..555b05d16 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -431,18 +431,6 @@ jobs: git config --global --add safe.directory $GITHUB_WORKSPACE $GITHUB_WORKSPACE/test/scripts/shellcheck - # Test markdown - markdownlint: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - - name: Run markdownlint - shell: bash - run: | - sudo snap install mdl - $GITHUB_WORKSPACE/test/scripts/markdownlint - # Test YAML yamllint: runs-on: ubuntu-20.04 @@ -454,4 +442,31 @@ jobs: run: | sudo apt install yamllint $GITHUB_WORKSPACE/test/scripts/yamllint + + # Lint with pre-commit + lint: + container: johnmcfarlane/cnl_ci:clang-14 + runs-on: ubuntu-22.04 + steps: + - name: Clone repository + uses: actions/checkout@v3 + + - name: Load package caches + uses: actions/cache@v2 + env: + CACHE_SLUG: ${{ github.job }}-${{ matrix.name }} + with: + path: | + /github/home/.cache/pre-commit + key: ${{ env.CACHE_SLUG }}-${{ github.ref_name }} + restore-keys: | + ${{ env.CACHE_SLUG }}-main + ${{ env.CACHE_SLUG }}-${{ github.ref_name }} + ${{ env.CACHE_SLUG }}- + + - name: Run pre-commit + shell: bash + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + $GITHUB_WORKSPACE/test/scripts/lint ... diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..44e7ad3d5 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + exclude: ^(.*).md$ + + - repo: https://github.com/markdownlint/markdownlint + rev: v0.11.0 + hooks: + - id: markdownlint + args: ["--style", "test/scripts/mdl.style"] diff --git a/README.md b/README.md index 8e6fa73c0..8f0e6e644 100644 --- a/README.md +++ b/README.md @@ -176,5 +176,5 @@ Examples of projects using CNL: All feedback greatly appreciated. -* [CNL Issues](https://github.com/johnmcfarlane/cnl/issues) -* [cnl@john.mcfarlane.name](mailto:cnl@john.mcfarlane.name) +- [CNL Issues](https://github.com/johnmcfarlane/cnl/issues) +- [cnl@john.mcfarlane.name](mailto:cnl@john.mcfarlane.name) diff --git a/include/cnl/_impl/ckormanyos/uintwide_t.h b/include/cnl/_impl/ckormanyos/uintwide_t.h index 1a7bad003..f6631b597 100644 --- a/include/cnl/_impl/ckormanyos/uintwide_t.h +++ b/include/cnl/_impl/ckormanyos/uintwide_t.h @@ -2522,7 +2522,7 @@ ? static_cast(std::numeric_limits::digits + 1) : static_cast(std::numeric_limits::digits + 0)>::exact_unsigned_type; - static constexpr unsigned_fast_type value = + static constexpr unsigned_fast_type value = static_cast( std::numeric_limits::digits / std::numeric_limits::digits); @@ -5574,7 +5574,7 @@ static_assert((digits_generator_result_type % UINT32_C(8)) == UINT32_C(0), "Error: Generator result type must have a multiple of 8 bits."); - constexpr auto digits_limb_ratio = + constexpr auto digits_limb_ratio = static_cast(std::numeric_limits::digits / 8U); constexpr auto digits_gtor_ratio = static_cast(digits_generator_result_type / 8U); @@ -5701,7 +5701,7 @@ // See also: // https://www.wolframalpha.com/input/?i=Table%5BPrime%5Bi%5D%2C+%7Bi%2C+2%2C+49%7D%5D - constexpr std::array small_primes = + constexpr std::array small_primes = {{ UINT8_C( 3), UINT8_C( 5), UINT8_C( 7), UINT8_C( 11), UINT8_C( 13), UINT8_C( 17), UINT8_C( 19), UINT8_C( 23), UINT8_C( 29), UINT8_C( 31), UINT8_C( 37), UINT8_C( 41), UINT8_C( 43), UINT8_C( 47), UINT8_C( 53), UINT8_C( 59), diff --git a/test/scripts/lint b/test/scripts/lint new file mode 100755 index 000000000..a5fd75bda --- /dev/null +++ b/test/scripts/lint @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +PROJECT_DIR=$( + cd "$(dirname "$0")"/../.. + pwd +) +cd "${PROJECT_DIR}" + +pre-commit run --all-files --show-diff-on-failure diff --git a/test/scripts/markdownlint b/test/scripts/markdownlint deleted file mode 100755 index a2dbddf90..000000000 --- a/test/scripts/markdownlint +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -# run markdownlint linter over all markdown documents in project directory - -set -euo pipefail - -PROJECT_DIR=$( - cd "$(dirname "$0")"/../.. - pwd -) - -cd "${PROJECT_DIR}" - -find "${PROJECT_DIR}" -name "*.md" | while read -r TEST; do - mdl \ - --style "${PROJECT_DIR}/test/scripts/mdl.style" \ - "$TEST" -done - -echo mdl success