From 769938ad99bbbceb6c47e70a3be01ef2df003588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6tz=20G=C3=B6risch?= <47734341+GoetzGoerisch@users.noreply.github.com> Date: Tue, 15 Feb 2022 14:27:51 +0000 Subject: [PATCH] fix(lint): Linting workflows --- .github/CMakeLists.txt | 10 ++--- .github/linters/.yaml-lint.yml | 59 +++++++++++++++++++++++++++ .github/workflows/build.yml | 19 ++++++--- .github/workflows/codeql-analysis.yml | 54 ++++++++++++------------ .github/workflows/delete-images.yml | 7 +++- .github/workflows/linter.yml | 20 ++++----- .github/workflows/rebase.yml | 5 ++- .gitpod.yml | 13 ++++-- CMakeLists.txt | 7 ++-- UmatiServerLib/Instantiation.hpp | 1 + 10 files changed, 138 insertions(+), 57 deletions(-) create mode 100644 .github/linters/.yaml-lint.yml diff --git a/.github/CMakeLists.txt b/.github/CMakeLists.txt index c1b1b103..90ebe0e8 100644 --- a/.github/CMakeLists.txt +++ b/.github/CMakeLists.txt @@ -1,16 +1,16 @@ # MIT License -# +# # Copyright 2020-2021 (c) Christian von Arnim, ISW University of Stuttgart (for umati and VDW e.V.) # Copyright 2021 (c) Götz Görisch, VDW - Verein Deutscher Werkzeugmaschinenfabriken e.V. # Copyright 2021 (c) Dennis Hezel, 3Yourmind GmbH -# +# # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # @@ -61,8 +61,8 @@ externalproject_add( open62541External SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../deps/open62541 CMAKE_ARGS -DUA_ENABLE_SUBSCRIPTIONS_ALARMS_CONDITIONS:BOOL=ON -DUA_ENABLE_SUBSCRIPTIONS_EVENTS:BOOL=ON - -DUA_NAMESPACE_ZERO:STRING=FULL -DUA_ENABLE_ENCRYPTION:STRING=LIBRESSL -DLIBRESSL_ROOT_DIR:PATH=${CMAKE_INSTALL_PREFIX} - -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} + -DUA_NAMESPACE_ZERO:STRING=FULL -DUA_ENABLE_ENCRYPTION:STRING=LIBRESSL + -DLIBRESSL_ROOT_DIR:PATH=${CMAKE_INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" DEPENDS libreSSLExternal ) diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml new file mode 100644 index 00000000..8db852fe --- /dev/null +++ b/.github/linters/.yaml-lint.yml @@ -0,0 +1,59 @@ +--- +########################################### +# These are the rules used for # +# linting all the yaml files in the stack # +# NOTE: # +# You can disable line with: # +# # yamllint disable-line # +########################################### +rules: + braces: + level: warning + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 1 + max-spaces-inside-empty: 5 + brackets: + level: warning + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 1 + max-spaces-inside-empty: 5 + colons: + level: warning + max-spaces-before: 0 + max-spaces-after: 1 + commas: + level: warning + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 + comments: disable + comments-indentation: disable + document-end: disable + document-start: + level: warning + present: true + empty-lines: + level: warning + max: 2 + max-start: 0 + max-end: 0 + hyphens: + level: warning + max-spaces-after: 1 + indentation: + level: warning + spaces: consistent + indent-sequences: true + check-multi-line-strings: false + key-duplicates: enable + line-length: + level: warning + max: 80 + allow-non-breakable-words: true + allow-non-breakable-inline-mappings: true + new-line-at-end-of-file: disable + new-lines: + type: unix + trailing-spaces: disable \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 09c18b11..2a3143f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,12 @@ -name: Build +--- +# Automatic building in CI -on: [push, pull_request] +name: "Matrix Build" + +on: + push: + pull_request: + branches: [main, develop] jobs: build: @@ -43,13 +49,14 @@ jobs: - name: Test Sample-Server run: | cd build/SampleServer-build/ - ctest --output-on-failure ${{env.ARG_CTEST}} + ctest --output-on-failure ${{ env.ARG_CTEST }} docker: runs-on: ubuntu-20.04 env: - # Check if this is not a pull request and GITHUB_TOKEN is set - # As all env variables are strings, you need to compaire against "== 'true'" (not "== true") + # Check if this is not a pull request andGITHUB_TOKEN is set + # As all env variables are strings, you need to compare + # against "== 'true'" (not "== true") IS_NOT_PR: "${{ !github.head_ref && true }}" steps: - name: Checkout Sample-Server @@ -62,7 +69,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1.6.0 - name: PrepareReg Names - run: | + run: | echo IMAGE_REPOSITORY="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV" echo IMAGE_TAG="$(echo "${{ github.ref }}" | tr '[:upper:]' '[:lower:]' | awk '{sub(/([^\/]*\/){2}/,""); gsub(/\/|_/, "-")}1')" >> "$GITHUB_ENV" echo IS_NOT_PR="${{ env.IS_NOT_PR }})" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index b5beca5d..41978878 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,3 +1,4 @@ +--- # For most projects, this workflow file will not need changing; you simply need # to commit it to your repository. # @@ -13,10 +14,10 @@ name: "CodeQL" on: push: - branches: [ main, develop ] + branches: [main, develop] pull_request: # The branches below must be a subset of the branches above - branches: [ develop ] + branches: [develop] schedule: - cron: '0 3 * * 1' @@ -30,32 +31,35 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'cpp', 'python' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + language: ['cpp', 'python'] + # CodeQL supports ['cpp','csharp','go','java','javascript','python'] # Learn more: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed steps: - - name: Checkout Sample-Server - uses: actions/checkout@v3 - with: - submodules: recursive + - name: Checkout Sample-Server + uses: actions/checkout@v3 + with: + submodules: recursive - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or + # in a config file. By default, queries listed here will override + # any specified in a config file. + # Prefix the list here with "+" to use these queries and those in + # the config file. queries: ./path/to/local/query, + # your-org/your-repo/queries@main - - name: Build server with dependencies - run: | - mkdir -p build - cd build - cmake ../.github/ -DCMAKE_INSTALL_PREFIX:PATH="${{ env.CMAKE_INSTALL_PREFIX }}" - cmake --build . - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + - name: Build server with dependencies + run: | + mkdir -p build + cd build + cmake ../.github/ \ + -DCMAKE_INSTALL_PREFIX:PATH="${{ env.CMAKE_INSTALL_PREFIX }}" + cmake --build . + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/delete-images.yml b/.github/workflows/delete-images.yml index d9adb5a5..d47815fb 100644 --- a/.github/workflows/delete-images.yml +++ b/.github/workflows/delete-images.yml @@ -1,13 +1,14 @@ +--- name: Clean up docker images on: workflow_dispatch: schedule: # * is a special character in YAML so you have to quote this string - - cron: '0 0 1 * *' + - cron: '0 0 1 * *' jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/github-script@v6 @@ -18,12 +19,14 @@ jobs: with: github-token: ${{ secrets.DELETE_PACKAGES_TOKEN }} script: | + # yamllint disable-line const response = await github.request("GET /orgs/${{ github.repository_owner }}/packages/container/${{ env.PACKAGE_NAME }}/versions", { per_page: ${{ env.PER_PAGE }} }); for(version of response.data) { if (version.metadata.container.tags.length == 0) { console.log("delete " + version.id) + # yamllint disable-line const deleteResponse = await github.request("DELETE /orgs/${{ github.repository_owner }}/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { }); console.log("status " + deleteResponse.status) } diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 3dfb4fb8..36137926 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -16,7 +16,6 @@ name: Lint Code Base ############################# on: push: - branches-ignore: [] pull_request: branches: [main, develop] @@ -28,7 +27,7 @@ jobs: # Name the Job name: Lint Code Base (super-linter) # Set the agent to run on - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 ################## # Load all steps # @@ -40,7 +39,8 @@ jobs: - name: Checkout Code uses: actions/checkout@v3 with: - # Full git history is needed to get a proper list of changed files within `super-linter` + # Full git history is needed to get a proper list + # of changed files within `super-linter` fetch-depth: 0 ################################ @@ -57,11 +57,11 @@ jobs: # CMake Format cmake-format-linter: name: Lint Code Base (cmake-format-lint) - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 - - name: Format CMake files - id: cmake-format - uses: PuneetMatharu/cmake-format-lint-action@v1.0.1 - with: - args: --config-files cmake-format.yaml + - uses: actions/checkout@v3 + - name: Format CMake files + id: cmake-format + uses: PuneetMatharu/cmake-format-lint-action@v1.0.1 + with: + args: --config-files cmake-format.yaml diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml index 74f32e23..73d5387f 100644 --- a/.github/workflows/rebase.yml +++ b/.github/workflows/rebase.yml @@ -1,3 +1,4 @@ +--- name: Automatic Rebase on: issue_comment: @@ -5,7 +6,9 @@ on: jobs: rebase: name: Rebase - if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') && github.event.comment.author_association == 'MEMBER' + if: github.event.issue.pull_request != '' && + contains(github.event.comment.body, '/rebase') && + github.event.comment.author_association == 'MEMBER' runs-on: ubuntu-latest steps: - name: Checkout the latest code diff --git a/.gitpod.yml b/.gitpod.yml index f00d6871..0215d5d1 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,3 +1,4 @@ +--- # MIT License # # Copyright 2018 (c) TypeFox GmbH @@ -26,7 +27,8 @@ image: tasks: - init: bash ./initialbuild.sh - + command: npm install opcua-commander -g + github: prebuilds: # enable for the master/default branch (defaults to true) @@ -39,9 +41,12 @@ github: pullRequestsFromForks: true # add a check to pull requests (defaults to true) addCheck: true - # add a "Review in Gitpod" button as a comment to pull requests (defaults to false) + # add a "Review in Gitpod" button as a comment to pull requests + # (defaults to false) addComment: true - # add a "Review in Gitpod" button to the pull request's description (defaults to false) + # add a "Review in Gitpod" button to the pull request's description + # (defaults to false) addBadge: false - # add a label once the prebuild is ready to pull requests (defaults to false) + # add a label once the prebuild is ready to pull requests + # (defaults to false) addLabel: false \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 19f3b690..89eb33b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,17 @@ # MIT License -# +# # Copyright 2020-2021 (c) Christian von Arnim, ISW University of Stuttgart (for umati and VDW e.V.) # Copyright 2021 (c) Götz Görisch, VDW - Verein Deutscher Werkzeugmaschinenfabriken e.V. # Copyright 2021 (c) Dennis Hezel, 3Yourmind GmbH # Copyright 2021 (c) Hermann Leinweber, basysKom GmbH -# +# # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # @@ -23,7 +23,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. - cmake_minimum_required(VERSION 3.15) project(SampleServer VERSION 0.3) diff --git a/UmatiServerLib/Instantiation.hpp b/UmatiServerLib/Instantiation.hpp index 7639ffb0..54f0c3e0 100644 --- a/UmatiServerLib/Instantiation.hpp +++ b/UmatiServerLib/Instantiation.hpp @@ -62,6 +62,7 @@ void InstantiateOptional(BINDABLEMEMBER_T &memberPar, UA_Server *pServer, Nod if (member.ParentNodeId.NodeId == nullptr || UA_NodeId_isNull(member.MemberInTypeNodeId.NodeId)) { throw std::runtime_error("Parent not bind."); } + // Initialize nodeid, so memory is allocated and the resulting nodeid can be written into it. member.NodeId = open62541Cpp::UA_NodeId((UA_UInt16)0, 0); auto browseName = readBrowseName(pServer, member.MemberInTypeNodeId);