Skip to content

Commit

Permalink
coding-conventions: use new formatting helpers (#1982)
Browse files Browse the repository at this point in the history
* coding-conventions: use new formatting helpers.
* coreneuron: update submodule.
* docs CI: fix by banning the new matplotlib version.
  • Loading branch information
olupton committed Sep 16, 2022
1 parent d788da2 commit b226aab
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 100 deletions.
14 changes: 14 additions & 0 deletions .bbp-project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tools:
Black:
enable: True
include:
match:
- '.*\.(py|ipynb)$'
option: [--color, --diff, --target-version, py37]
version: '[jupyter] ~=22.3'
ClangFormat:
enable: True
version: == 12.0.1
CMakeFormat:
enable: True
version: == 0.6.13
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
shell: bash

- name: Set up Python@${{ env.DEFAULT_PY_VERSION }}
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: ${{ env.DEFAULT_PY_VERSION }}

Expand All @@ -50,6 +50,7 @@ jobs:
working-directory: ${{runner.workspace}}/nrn
run: |
python -m pip install --upgrade -r docs/docs_requirements.txt
python -c 'import plotnine; print(plotnine.__version__); print(plotnine)'
- name: Documentation
id: documentation
Expand Down
101 changes: 7 additions & 94 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,102 +15,15 @@ on:
- release/**

jobs:
black:
name: Python
runs-on: ubuntu-20.04
all:
name: C/C++, CMake and Python
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Set up Python@3.7
uses: actions/setup-python@v3
with:
python-version: 3.7

- name: Install Black
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade black[jupyter]
- uses: actions/checkout@v3

- name: Check Python formatting
- name: Update submodule
working-directory: ${{runner.workspace}}/nrn
run: |
git ls-tree -z -r HEAD --name-only \
| grep -z '\.\(py\|ipynb\)$' \
| xargs -0 black --check --color --diff --target-version py37
cmake:
name: CMake
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- name: Set up Python@3.7
uses: actions/setup-python@v3
with:
python-version: 3.7

- name: Install cmake-format
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade cmake-format pyyaml
- name: Install Ninja
run: |
sudo apt-get update
sudo apt-get install ninja-build
- uses: actions/checkout@v3

- name: Configure
run: git submodule update --init external/coding-conventions
- name: Check formatting
working-directory: ${{runner.workspace}}/nrn
run: |
mkdir build
cd build/
# Need to configure the build to trigger the hpc-coding-conventions
# YAML magic
cmake -G Ninja .. \
-DNRN_CMAKE_FORMAT=ON \
-DNRN_ENABLE_RX3D=OFF \
-DNRN_ENABLE_PYTHON=OFF \
-DNRN_ENABLE_INTERVIEWS=OFF \
-DNRN_ENABLE_MPI=OFF
- name: Check CMake formatting
working-directory: ${{runner.workspace}}/nrn/build
run: ninja check-cmake-format

cpp:
name: C/C++
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install ninja-build
# The last .1 refers to ssciwr/clang-format-wheel#23.
sudo pip install clang-format==12.0.1.1
command -v clang-format
clang-format --version
- uses: actions/checkout@v3

- name: Configure
working-directory: ${{runner.workspace}}/nrn
run: |
mkdir build
cd build/
# Need to configure the build to trigger the hpc-coding-conventions
# YAML magic. Disable as much as possible now that the list of files
# to format is based on git ls-tree.
cmake -G Ninja .. \
-DClangFormat_EXECUTABLE=$(command -v clang-format) \
-DNRN_CLANG_FORMAT=ON \
-DNRN_ENABLE_INTERVIEWS=OFF \
-DNRN_ENABLE_MPI=OFF \
-DNRN_ENABLE_PYTHON=OFF \
-DNRN_ENABLE_RX3D=OFF
- name: Check C/C++ formatting
working-directory: ${{runner.workspace}}/nrn/build
run: ninja check-clang-format
run: external/coding-conventions/bin/format -v --dry-run
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.bbp-project-venv/
.clang-format
.cmake-format.yaml
external/tests/
Expand Down
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ configure_file(src/nrnoc/nrnsemanticversion.h.in src/nrnoc/nrnsemanticversion.h
# =============================================================================
set(CODING_CONV_PREFIX "NRN")
set(${CODING_CONV_PREFIX}_3RDPARTY_DIR "external")
set(${CODING_CONV_PREFIX}_ClangFormat_REQUIRED_VERSION 12.0.1)
set(${CODING_CONV_PREFIX}_ClangFormat_EXCLUDES_RE CACHE STRING "") # None needed
set(CODING_CONV_CMAKE "${PROJECT_SOURCE_DIR}/${NRN_3RDPARTY_DIR}/coding-conventions/cpp/cmake")
if(NOT EXISTS "${CODING_CONV_CMAKE}/3rdparty.cmake")
# Abort with a helpful message if the current source tree lacks .git information, as in that case
Expand Down
3 changes: 2 additions & 1 deletion docs/docs_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ sphinx_rtd_theme
jupyter
nbconvert
recommonmark
matplotlib
# 3.6.0 clashes with plotnine 0.9.0
matplotlib == 3.5.3
bokeh
# do not check import of next line
ipython
Expand Down

0 comments on commit b226aab

Please sign in to comment.