From 10b3464bd20604e247d1f9374abff2aff9847b14 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Sun, 24 Oct 2021 20:52:21 +0100 Subject: [PATCH] Linting for yaml files (#872) * Add YAML file linting * Add cmake-linux.yml lint and address its concerns --- .circleci/config.yml | 3 +- .github/workflows/cmake-linux.yml | 61 +++++++++++++++++-------------- .travis.yml | 3 +- .yamllint.yml | 8 ++++ Makefile.in | 9 ++++- 5 files changed, 52 insertions(+), 32 deletions(-) create mode 100644 .yamllint.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index dde6512..ed1502f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,3 +1,4 @@ +--- version: 2.1 orbs: @@ -36,4 +37,4 @@ workflows: run-all: jobs: - linux-gcc - - windows-msvc \ No newline at end of file + - windows-msvc diff --git a/.github/workflows/cmake-linux.yml b/.github/workflows/cmake-linux.yml index 8122a36..84466ad 100644 --- a/.github/workflows/cmake-linux.yml +++ b/.github/workflows/cmake-linux.yml @@ -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 " - 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 " + 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 diff --git a/.travis.yml b/.travis.yml index 1f91ada..08d9211 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..b54dd76 --- /dev/null +++ b/.yamllint.yml @@ -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 diff --git a/Makefile.in b/Makefile.in index 3d87dc8..cea0a0f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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