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 version: 2.1
orbs: orbs:

View File

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

View File

@ -1,3 +1,4 @@
---
language: c++ language: c++
dist: xenial dist: xenial

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