Linting for yaml files (#872)

* Add YAML file linting

* Add cmake-linux.yml lint and address its concerns
This commit is contained in:
Hamish Coleman 2021-10-24 20:52:21 +01:00 committed by GitHub
parent e727304681
commit 10b3464bd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 32 deletions

View File

@ -1,3 +1,4 @@
---
version: 2.1
orbs:
@ -36,4 +37,4 @@ workflows:
run-all:
jobs:
- linux-gcc
- windows-msvc
- windows-msvc

View File

@ -1,3 +1,4 @@
---
name: CMake
on: [push]
@ -8,9 +9,9 @@ env:
jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# The CMake configure and build commands are platform agnostic and should
# work equally well on Windows or Mac. You can convert this to a matrix
# build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ${{ matrix.os }}
strategy:
@ -21,32 +22,36 @@ jobs:
- os: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate
# build directory. We'll use this as our working directory for all
# subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment
# variable access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to
# specify source and build directories, but this is only available
# with CMake 3.13 and higher. The CMake binaries on the Github Actions
# machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target
# with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE
- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more
# detail
run: ctest -C $BUILD_TYPE

View File

@ -1,3 +1,4 @@
---
language: c++
dist: xenial
@ -5,7 +6,7 @@ compiler:
- clang
- gcc
install:
install:
- sudo apt-get update || true
- sudo apt-get install build-essential

8
.yamllint.yml Normal file
View File

@ -0,0 +1,8 @@
---
extends: default
rules:
# 80 chars should be enough, but don't fail if a line is longer
line-length:
max: 80
level: warning

View File

@ -140,6 +140,7 @@ BUILD_DEP:=\
libzstd-dev \
shellcheck \
uncrustify \
yamllint \
SUBDIRS+=tools
@ -147,7 +148,7 @@ COVERAGEDIR?=coverage
.PHONY: $(SUBDIRS)
.PHONY: steps build push all clean distclean install test cover gcov build-dep
.PHONY: lint lint.python lint.ccode lint.shell
.PHONY: lint lint.python lint.ccode lint.shell lint.yaml
all: $(APPS) $(DOCS) $(SUBDIRS)
@ -184,7 +185,7 @@ win32/n2n_win32.a: win32
test: tools
scripts/test_harness.sh
lint: lint.python lint.ccode lint.shell
lint: lint.python lint.ccode lint.shell lint.yaml
lint.python:
flake8 scripts/n2n-ctl scripts/n2n-httpd
@ -195,6 +196,10 @@ lint.ccode:
lint.shell:
shellcheck scripts/*.sh
lint.yaml:
yamllint .circleci/config.yml .travis.yml .yamllint.yml \
.github/workflows/cmake-linux.yml
# To generate coverage information, run configure with
# CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS="--coverage"
# and run the desired tests. Ensure that package gcovr is installed