Skip to content

Commit

Permalink
🔧 Set up ruff and mypy, and extend the pre-commit configuration (
Browse files Browse the repository at this point in the history
…#603)

* 🔧 Add `check-jsonschema`, `validate-pyproject-schema-store`, and `nb-clean` to the `pre-commit` configuration

* 🔧 Add `prettier` to the `pre-commit` configuration and apply it to refactor files

* 🔧 Add static type checking via `mypy` and also add `mypy` to the `pre-commit` configuration

* 🔧 Add linting via `ruff` and also add `ruff` to the `pre-commit` configuration

* 🔧 Extend the `ruff` configuration

* 🚨 Fix `ruff` linter warnings
  • Loading branch information
marcelwa authored Dec 4, 2024
1 parent af4650b commit a30097d
Show file tree
Hide file tree
Showing 96 changed files with 1,980 additions and 1,565 deletions.
4 changes: 1 addition & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ IncludeCategories:
Priority: 4
- Regex: '<z3[a-zA-Z0-9_\+]+.+>$'
Priority: 5
- Regex: '<[a-zA-Z0-9_]+>$'
- Regex: "<[a-zA-Z0-9_]+>$"
Priority: 6
IndentCaseLabels: true
IndentWidth: 4
Expand All @@ -85,5 +85,3 @@ SpacesInSquareBrackets: false
Standard: c++17
UseTab: Never
LineEnding: LF

...
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 🐛 Bug report
description: Something is not working correctly.
title: "🐛 <title>"
labels: [ "bug" ]
labels: ["bug"]
assignees:
- marcelwa
body:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: ✨ Feature request
description: Suggest an idea
title: "✨ <title>"
labels: [ "enhancement" ]
labels: ["enhancement"]
assignees:
- marcelwa
body:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-tidy-review-post.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 🚨 • Post Clang-Tidy Review

on:
workflow_run:
workflows: [ 'Clang-Tidy Review' ]
workflows: ["Clang-Tidy Review"]
types:
- completed

Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/clang-tidy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: Clang-Tidy Review
on:
pull_request:
paths:
- '**/*.hpp'
- '**/*.cpp'
- 'libs/**'
- '.github/workflows/clang-tidy-review.yml'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- "**/*.hpp"
- "**/*.cpp"
- "libs/**"
- ".github/workflows/clang-tidy-review.yml"
- "!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down Expand Up @@ -37,16 +37,16 @@ jobs:
-DFICTION_EXPERIMENTS=ON
-DMOCKTURTLE_EXAMPLES=OFF
build_dir: build
apt_packages: 'libreadline-dev,libtbb-dev'
config_file: '.clang-tidy'
exclude: 'libs/*,docs/*,benchmarks/*,bib/*,*/pyfiction/pybind11_mkdoc_docstrings.hpp,*/pyfiction/documentation.hpp'
apt_packages: "libreadline-dev,libtbb-dev"
config_file: ".clang-tidy"
exclude: "libs/*,docs/*,benchmarks/*,bib/*,*/pyfiction/pybind11_mkdoc_docstrings.hpp,*/pyfiction/documentation.hpp"
split_workflow: true

- name: Make sure that the review file exists
id: check-review-output
uses: andstor/file-existence-action@v3.0.0
with:
files: 'clang-tidy-review-output.json'
files: "clang-tidy-review-output.json"
ignore_case: true

- name: Upload review artifact
Expand Down
50 changes: 25 additions & 25 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ name: 📝 • CodeQL

on:
push:
branches: [ 'main' ]
branches: ["main"]
paths:
- '**/*.hpp'
- '**/*.cpp'
- '**/*.cmake'
- '**/CMakeLists.txt'
- '**/*.py'
- 'libs/**'
- '.github/workflows/codeql-analysis.yml'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- "**/*.hpp"
- "**/*.cpp"
- "**/*.cmake"
- "**/CMakeLists.txt"
- "**/*.py"
- "libs/**"
- ".github/workflows/codeql-analysis.yml"
- "!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp"
pull_request:
branches: [ 'main' ]
branches: ["main"]
paths:
- '**/*.hpp'
- '**/*.cpp'
- '**/*.cmake'
- '**/CMakeLists.txt'
- '**/*.py'
- 'libs/**'
- '.github/workflows/codeql-analysis.yml'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- "**/*.hpp"
- "**/*.cpp"
- "**/*.cmake"
- "**/CMakeLists.txt"
- "**/*.py"
- "libs/**"
- ".github/workflows/codeql-analysis.yml"
- "!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp"
merge_group:
schedule:
- cron: '30 5 * * 6'
- cron: "30 5 * * 6"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -46,9 +46,9 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'cpp', 'python' ]
compiler: [ clang++-17 ]
build_type: [ Debug ]
language: ["cpp", "python"]
compiler: [clang++-17]
build_type: [Debug]

steps:
- name: Free Disk Space (Ubuntu)
Expand All @@ -74,16 +74,16 @@ jobs:
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: '${{matrix.os}}-${{matrix.compiler}}'
key: "${{matrix.os}}-${{matrix.compiler}}"
variant: ccache
save: true
max-size: 10G

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13.x'
cache: 'pip'
python-version: "3.13.x"
cache: "pip"

- name: Setup mold
uses: rui314/setup-mold@v1
Expand Down
42 changes: 21 additions & 21 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ name: ☂️ • Coverage

on:
push:
branches: [ 'main' ]
branches: ["main"]
paths:
- '**/*.hpp'
- '**/*.cpp'
- '**/*.cmake'
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/coverage.yml'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- "**/*.hpp"
- "**/*.cpp"
- "**/*.cmake"
- "**/CMakeLists.txt"
- "libs/**"
- ".github/workflows/coverage.yml"
- "!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp"
pull_request:
branches: [ 'main' ]
branches: ["main"]
paths:
- '**/*.hpp'
- '**/*.cpp'
- '**/*.cmake'
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/coverage.yml'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- "**/*.hpp"
- "**/*.cpp"
- "**/*.cmake"
- "**/CMakeLists.txt"
- "libs/**"
- ".github/workflows/coverage.yml"
- "!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp"
merge_group:

concurrency:
Expand All @@ -39,8 +39,8 @@ jobs:
build_and_test:
strategy:
matrix:
os: [ ubuntu-22.04 ]
compiler: [ g++-11 ]
os: [ubuntu-22.04]
compiler: [g++-11]

name: Coverage on ${{matrix.os}} with ${{matrix.compiler}}
runs-on: ${{matrix.os}}
Expand All @@ -57,16 +57,16 @@ jobs:
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: '${{matrix.os}}-${{matrix.compiler}}'
key: "${{matrix.os}}-${{matrix.compiler}}"
variant: ccache
save: true
max-size: 10G

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13.x'
cache: 'pip'
python-version: "3.13.x"
cache: "pip"

- name: Setup mold
uses: rui314/setup-mold@v1
Expand Down
42 changes: 21 additions & 21 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@ name: 🐳 • Docker Image

on:
push:
branches: [ 'main' ]
branches: ["main"]
paths:
- '**/*.hpp'
- '**/*.cpp'
- '**/*.cmake'
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/docker-image.yml'
- 'Dockerfile'
- '.dockerignore'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- "**/*.hpp"
- "**/*.cpp"
- "**/*.cmake"
- "**/CMakeLists.txt"
- "libs/**"
- ".github/workflows/docker-image.yml"
- "Dockerfile"
- ".dockerignore"
- "!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp"
pull_request:
branches: [ 'main' ]
branches: ["main"]
paths:
- '**/*.hpp'
- '**/*.cpp'
- '**/*.cmake'
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/docker-image.yml'
- 'Dockerfile'
- '.dockerignore'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- "**/*.hpp"
- "**/*.cpp"
- "**/*.cmake"
- "**/CMakeLists.txt"
- "libs/**"
- ".github/workflows/docker-image.yml"
- "Dockerfile"
- ".dockerignore"
- "!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp"
merge_group:
workflow_dispatch:
release:
types: [ published ]
types: [published]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
46 changes: 22 additions & 24 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ name: 🍎 • CI

on:
push:
branches: [ 'main' ]
branches: ["main"]
paths:
- '**/*.hpp'
- '**/*.cpp'
- '**/*.cmake'
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/macos.yml'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- "**/*.hpp"
- "**/*.cpp"
- "**/*.cmake"
- "**/CMakeLists.txt"
- "libs/**"
- ".github/workflows/macos.yml"
- "!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp"
pull_request:
branches: [ 'main' ]
branches: ["main"]
paths:
- '**/*.hpp'
- '**/*.cpp'
- '**/*.cmake'
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/macos.yml'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- "**/*.hpp"
- "**/*.cpp"
- "**/*.cmake"
- "**/CMakeLists.txt"
- "libs/**"
- ".github/workflows/macos.yml"
- "!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp"
merge_group:

concurrency:
Expand All @@ -38,8 +38,8 @@ jobs:
build_and_test:
strategy:
matrix:
os: [ macos-13, macos-14 ]
compiler: [ g++-12, g++-13, g++-14, clang++ ]
os: [macos-13, macos-14]
compiler: [g++-12, g++-13, g++-14, clang++]
include:
- os: macos-13
architecture: x64
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13.x'
python-version: "3.13.x"

# Setup TBB for parallel STL algorithms via Homebrew
- name: Setup TBB
Expand All @@ -88,7 +88,7 @@ jobs:
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: '${{matrix.os}}-${{matrix.compiler}}'
key: "${{matrix.os}}-${{matrix.compiler}}"
variant: ccache
save: true
max-size: 10G
Expand All @@ -103,7 +103,6 @@ jobs:
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}


# Build and test pipeline for Debug mode

- name: Create Build Environment (Debug)
Expand All @@ -128,13 +127,12 @@ jobs:
- name: Build (Debug)
working-directory: ${{github.workspace}}/build_debug
run: cmake --build . --config Debug -j4 # all macOS runners provide at least 3 cores
run: cmake --build . --config Debug -j4 # all macOS runners provide at least 3 cores

- name: Test (Debug)
working-directory: ${{github.workspace}}/build_debug
run: ctest -C Debug --verbose --output-on-failure --repeat until-pass:3 --parallel 4 --exclude-regex "quality"


# Build and test pipeline for Release mode

- name: Create Build Environment (Release)
Expand All @@ -159,7 +157,7 @@ jobs:
- name: Build (Release)
working-directory: ${{github.workspace}}/build_release
run: cmake --build . --config Release -j4 # all macOS runners provide at least 3 cores
run: cmake --build . --config Release -j4 # all macOS runners provide at least 3 cores

- name: Test (Release)
working-directory: ${{github.workspace}}/build_release
Expand Down
Loading

0 comments on commit a30097d

Please sign in to comment.