mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
ci: lint with uncrustify #18563
This lint job will ensure that the C codebase is properly formatted at all times. This helps eliminate most of clint.py. To save CI time, it's faster to manually compile uncrustify and cache the binary instead of using homebrew (the apt-get package is too old).
This commit is contained in:
parent
4c97e17d38
commit
045aacc384
31
.github/workflows/ci.yml
vendored
31
.github/workflows/ci.yml
vendored
@ -66,6 +66,32 @@ jobs:
|
||||
ninja-build \
|
||||
pkg-config
|
||||
|
||||
|
||||
- name: Cache uncrustify
|
||||
id: cache-uncrustify
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ env.CACHE_UNCRUSTIFY }}
|
||||
key: ${{ env.UNCRUSTIFY_VERSION }}
|
||||
|
||||
- name: Clone uncrustify
|
||||
if: steps.cache-uncrustify.outputs.cache-hit != 'true'
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: uncrustify/uncrustify
|
||||
ref: ${{ env.UNCRUSTIFY_VERSION }}
|
||||
path: uncrustify
|
||||
|
||||
- name: Install uncrustify
|
||||
if: steps.cache-uncrustify.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
source_dir=uncrustify
|
||||
build_dir=uncrustify/build
|
||||
cmake -S $source_dir -B $build_dir -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build $build_dir
|
||||
mkdir -p $HOME/.cache
|
||||
cp $build_dir/uncrustify ${{ env.CACHE_UNCRUSTIFY }}
|
||||
|
||||
- name: Cache artifacts
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
@ -91,6 +117,11 @@ jobs:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: --check runtime/
|
||||
|
||||
- if: "!cancelled()"
|
||||
name: uncrustify
|
||||
run: |
|
||||
${{ env.CACHE_UNCRUSTIFY }} -c ./src/uncrustify.cfg -q --check $(find ./src/nvim -name "*.[ch]") >/dev/null
|
||||
|
||||
- if: "!cancelled()"
|
||||
name: lualint
|
||||
run: ./ci/run_lint.sh lualint
|
||||
|
2
.github/workflows/env.sh
vendored
2
.github/workflows/env.sh
vendored
@ -19,6 +19,8 @@ NVIM_LOG_FILE=$GITHUB_WORKSPACE/build/.nvimlog
|
||||
VALGRIND_LOG=$GITHUB_WORKSPACE/build/log/valgrind-%p.log
|
||||
CACHE_NVIM_DEPS_DIR=$HOME/.cache/nvim-deps
|
||||
CACHE_MARKER=$HOME/.cache/nvim-deps/.ci_cache_marker
|
||||
CACHE_UNCRUSTIFY=$HOME/.cache/uncrustify
|
||||
UNCRUSTIFY_VERSION=uncrustify-0.75.0
|
||||
CCACHE_BASEDIR=$GITHUB_WORKSPACE
|
||||
CCACHE_COMPRESS=1
|
||||
CCACHE_SLOPPINESS=time_macros,file_macro
|
||||
|
@ -108,8 +108,6 @@
|
||||
# define STATIC_ASSERT_STATEMENT STATIC_ASSERT_EXPR
|
||||
#endif
|
||||
|
||||
// uncrustify:off
|
||||
|
||||
#define ASSERT_CONCAT_(a, b) a##b
|
||||
#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b)
|
||||
// These can't be used after statements in c89.
|
||||
@ -125,8 +123,6 @@
|
||||
((enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)), }) 0)
|
||||
#endif
|
||||
|
||||
// uncrustify:on
|
||||
|
||||
/// @def STRICT_ADD
|
||||
/// @brief Adds (a + b) and stores result in `c`. Aborts on overflow.
|
||||
///
|
||||
|
@ -90,11 +90,13 @@ typedef enum {
|
||||
# pragma function(floor)
|
||||
# endif
|
||||
|
||||
// uncrustify:off
|
||||
PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES
|
||||
PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH
|
||||
# include "funcs.generated.h"
|
||||
PRAGMA_DIAG_POP
|
||||
PRAGMA_DIAG_POP
|
||||
// uncrustify:on
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
#include "nvim/arabic.h"
|
||||
#include "nvim/grid.h"
|
||||
#include "nvim/highlight.h"
|
||||
#include "nvim/screen.h"
|
||||
#include "nvim/ui.h"
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/screen.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "grid.c.generated.h"
|
||||
|
@ -1,7 +1,9 @@
|
||||
// This is an open source non-commercial project. Dear PVS-Studio, please check
|
||||
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||
|
||||
// uncrustify:off
|
||||
#include <math.h>
|
||||
// uncrustify:on
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "nvim/eval/typval.h"
|
||||
#include "nvim/types.h"
|
||||
#include "nvim/lib/kvec.h"
|
||||
#include "nvim/types.h"
|
||||
|
||||
/// Append string to string and return pointer to the next byte
|
||||
///
|
||||
|
@ -2646,6 +2646,7 @@ viml_pexpr_parse_figure_brace_closing_error:
|
||||
kvi_push(pt_stack, kEPTLambdaArguments);
|
||||
lambda_node = cur_node;
|
||||
} else {
|
||||
// uncrustify:off
|
||||
ADD_IDENT(do {
|
||||
NEW_NODE_WITH_CUR_POS(cur_node,
|
||||
kExprNodeCurlyBracesIdentifier);
|
||||
@ -2660,6 +2661,7 @@ viml_pexpr_parse_figure_brace_closing_error:
|
||||
want_node = kENodeValue;
|
||||
} while (0),
|
||||
Curly);
|
||||
// uncrustify:on
|
||||
}
|
||||
if (pt_is_assignment(cur_pt)
|
||||
&& !pt_is_assignment(kv_last(pt_stack))) {
|
||||
@ -2737,6 +2739,7 @@ viml_pexpr_parse_figure_brace_closing_error:
|
||||
: HL(IdentifierName)));
|
||||
} else {
|
||||
if (scope == kExprVarScopeMissing) {
|
||||
// uncrustify:off
|
||||
ADD_IDENT(do {
|
||||
NEW_NODE_WITH_CUR_POS(cur_node, kExprNodePlainIdentifier);
|
||||
cur_node->data.var.scope = scope;
|
||||
@ -2745,6 +2748,7 @@ viml_pexpr_parse_figure_brace_closing_error:
|
||||
want_node = kENodeOperator;
|
||||
} while (0),
|
||||
IdentifierName);
|
||||
// uncrustify:on
|
||||
} else {
|
||||
OP_MISSING;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user