From fcb6b0b7b7449dd26515adc1a6976631024e3669 Mon Sep 17 00:00:00 2001 From: Artur Harasimiuk Date: Tue, 4 Feb 2020 13:53:14 +0100 Subject: [PATCH] add lint workflow Related-To: NEO-6259 Closes: intel/compute-runtime#459 Signed-off-by: Artur Harasimiuk --- .github/actions/neo-lint/Dockerfile | 14 ++++++++++++++ .github/actions/neo-lint/action.yml | 17 +++++++++++++++++ .github/actions/neo-lint/lint.sh | 26 ++++++++++++++++++++++++++ .github/workflows/verify.yml | 21 +++++++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 .github/actions/neo-lint/Dockerfile create mode 100644 .github/actions/neo-lint/action.yml create mode 100755 .github/actions/neo-lint/lint.sh create mode 100644 .github/workflows/verify.yml diff --git a/.github/actions/neo-lint/Dockerfile b/.github/actions/neo-lint/Dockerfile new file mode 100644 index 0000000000..7756a2f86f --- /dev/null +++ b/.github/actions/neo-lint/Dockerfile @@ -0,0 +1,14 @@ +# +# Copyright (C) 2021 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +FROM docker.io/ubuntu:20.04 + +RUN apt-get -y update ; apt-get install -y --no-install-recommends gpg software-properties-common +RUN apt-get -y update ; apt-get install -y --no-install-recommends clang-format-11 git + +COPY lint.sh /lint.sh + +ENTRYPOINT ["/lint.sh"] diff --git a/.github/actions/neo-lint/action.yml b/.github/actions/neo-lint/action.yml new file mode 100644 index 0000000000..2468bf0e32 --- /dev/null +++ b/.github/actions/neo-lint/action.yml @@ -0,0 +1,17 @@ +# action.yml +# +# Copyright (C) 2021 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +name: 'Neo lint' +description: 'check coding style' +inputs: + path: + description: 'Relative path under $GITHUB_WORKSPACE to place the repository' + iregex: + description: 'iregex to pass to clang-format' +runs: + using: 'docker' + image: 'Dockerfile' diff --git a/.github/actions/neo-lint/lint.sh b/.github/actions/neo-lint/lint.sh new file mode 100755 index 0000000000..f99cda5c40 --- /dev/null +++ b/.github/actions/neo-lint/lint.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Copyright (C) 2021 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +set -e + +clang-format-11 --version + +INPUT_PATH="${INPUT_PATH:-.}" +INPUT_IREGEX="${INPUT_IREGEX:-.*\.(cpp|h|inl)}" + +( + cd ${INPUT_PATH} + git fetch origin ${GITHUB_BASE_REF} + set -x + git diff -U0 --no-color origin/master..HEAD | clang-format-diff-11 -p1 -i -v -iregex ${INPUT_IREGEX} + set +x +) + +if [ -n "$(git -C ${INPUT_PATH} status --porcelain)" ]; then + git -C ${INPUT_PATH} diff + exit 1 +fi diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000000..aec81730d0 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,21 @@ +# +# Copyright (C) 2021 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +name: verify +on: + - pull_request + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + path: neo + - name: lint + uses: ./neo/.github/actions/neo-lint + with: + path: neo