Skip to content

Commit

Permalink
ci: Add clang-format check (google#132)
Browse files Browse the repository at this point in the history
* ci: Add Clang-format check

* ci: Only check file(s) in the commit list
  • Loading branch information
Mizux authored Sep 23, 2020
1 parent 0d47deb commit 38f2a02
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/_/alpine
FROM alpine:edge
# Install system build dependencies
RUN apk add --no-cache git clang
24 changes: 24 additions & 0 deletions .github/workflows/clang_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: clang-format Check

on: [push, pull_request]

jobs:
# Building using the github runner environement directly.
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Fetch origin/master
run: git fetch origin master
- name: List of changed file(s)
run: git diff --name-only FETCH_HEAD

- name: Build clang-format docker
run: cd .github/workflows && docker build --tag=linter .
- name: Check clang-format
run: docker run --rm --init -v $(pwd):/repo linter:latest clang-format --version
- name: clang-format help
run: docker run --rm --init -v $(pwd):/repo linter:latest clang-format --help

- name: Check current commit
run: docker run --rm --init -v $(pwd):/repo -w /repo linter:latest sh -c "git diff --name-only FETCH_HEAD | grep '\.c$\|\.h$\|\.cc$' | xargs clang-format --style=file --dry-run --Werror "

0 comments on commit 38f2a02

Please sign in to comment.