Skip to content

Commit 8293ae5

Browse files
committed
Add github actions linting check
This was formerly a Travis CI job. Setting it up using Github actions gives us a user interface which integrates into the rest of github better. This is a step towards having all jobs seup in Github actions and removing Travis.
1 parent 9b9c48f commit 8293ae5

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Stop on errors
4+
set -e
5+
6+
# Log information about the run of this check.
7+
echo "Pull request's base branch is: ${BASE_BRANCH}"
8+
echo "Pull request's merge branch is: ${MERGE_BRANCH}"
9+
echo "Pull request's source branch is: ${GITHUB_HEAD_REF}"
10+
11+
# The checkout action leaves us in detatched head state. The following line
12+
# names the checked out commit, for simpler reference later.
13+
git checkout -b ${MERGE_BRANCH}
14+
15+
# Make sure we can refer to ${BASE_BRANCH} by name
16+
git checkout ${BASE_BRANCH}
17+
git checkout ${MERGE_BRANCH}
18+
19+
# Find the commit on which the PR is based.
20+
MERGE_BASE=$(git merge-base ${BASE_BRANCH} ${MERGE_BRANCH})
21+
echo "Checking standards of code touched since $MERGE_BASE"
22+
23+
# Do the checking.
24+
script_folder='./scripts'
25+
$script_folder/run_diff.sh CPPLINT $MERGE_BASE

.github/workflows/pull-request-checks.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,24 @@ jobs:
144144
BASE_BRANCH: ${{ github.base_ref }}
145145
MERGE_BRANCH: ${{ github.ref }}
146146
run: ./.github/workflows/pull-request-check-clang-format.sh
147+
148+
check-cpplint:
149+
runs-on: ubuntu-20.04
150+
steps:
151+
- uses: actions/checkout@v2
152+
with:
153+
submodules: true
154+
fetch-depth: 0
155+
- name: Fetch dependencies
156+
env:
157+
# This is needed in addition to -yq to prevent apt-get from asking for
158+
# user input
159+
DEBIAN_FRONTEND: noninteractive
160+
run: |
161+
sudo apt-get install -yq pip
162+
pip install unidiff
163+
- name: Check updated lines of code match clang-format-7 style
164+
env:
165+
BASE_BRANCH: ${{ github.base_ref }}
166+
MERGE_BRANCH: ${{ github.ref }}
167+
run: ./.github/workflows/pull-request-check-cpplint.sh

0 commit comments

Comments
 (0)