From ca373b65104ada70ddc28884bbbd3b5357d174d0 Mon Sep 17 00:00:00 2001 From: Doozy Date: Sat, 19 Oct 2019 15:21:42 +0200 Subject: [PATCH] feat: add clang-format-lint action --- Dockerfile | 8 ++++++++ README.md | 38 +++++++++++++++++++++++++++++++++++++- action.yml | 26 ++++++++++++++++++++++++++ entrypoint.sh | 4 ++++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 action.yml create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bbf048d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM unibeautify/clang-format:latest as clang-format-bin +FROM python:3-alpine + +COPY --from=clang-format-bin /usr/bin/clang-format /usr/bin/ +COPY run-clang-format/run-clang-format.py /run-clang-format.py +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 590a1a4..49469d4 100644 --- a/README.md +++ b/README.md @@ -1 +1,37 @@ -# clang-format-lint-action \ No newline at end of file +# clang-format lint action + +This action check if the source code matches the .clang-format file. + +## Inputs + +### `source` + +**Required** Where the soruce files are located. + +### `exclude` + +What folder should be exlcuded from format checking. + +### `extensions` + +What extensions should be used from format checking. + +## Example usage + +```yml +name: test-clang-format + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - uses: ./.github/actions/test-clang-format + with: + source: '.' + exclude: './src' + extensions: 'cpp' +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..40a7840 --- /dev/null +++ b/action.yml @@ -0,0 +1,26 @@ +name: 'clang-format lint' +author: 'DoozyX' +description: 'Github Action that check if code is formatted correctly using clang-format' +branding: + icon: 'align-left' + color: 'green' +inputs: + source: + description: 'Source folder to check formatting' + required: false + default: '.' + exclude: + description: 'Folder to exclude from formatting check' + required: false + default: '' + extensions: + description: 'List of extensions to check' + required: false + default: 'c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx' +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.source }} + - ${{ inputs.exclude }} + - ${{ inputs.extensions }} \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..1e494c2 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh -l + +cd "$GITHUB_WORKSPACE" +/run-clang-format.py -r --exclude ${INPUT_EXCLUDE} --extensions ${INPUT_EXTENSIONS} ${INPUT_SOURCE}