Skip to content

Commit

Permalink
feat: add clang-format-lint action
Browse files Browse the repository at this point in the history
  • Loading branch information
DoozyX committed Oct 19, 2019
1 parent 9845055 commit ca373b6
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
# clang-format-lint-action
# 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'
```
26 changes: 26 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 4 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh -l

cd "$GITHUB_WORKSPACE"
/run-clang-format.py -r --exclude ${INPUT_EXCLUDE} --extensions ${INPUT_EXTENSIONS} ${INPUT_SOURCE}

0 comments on commit ca373b6

Please sign in to comment.