Skip to content

Commit a6feed2

Browse files
Merge pull request #5457 from thomasspriggs/tas/gha_ancillaries
Port ancillary jobs from Travis to github actions
2 parents b76314b + f34e22a commit a6feed2

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
clang-format-7 --version
11+
12+
# The checkout action leaves us in detatched head state. The following line
13+
# names the checked out commit, for simpler reference later.
14+
git checkout -b ${MERGE_BRANCH}
15+
16+
# Build list of files to ignore
17+
while read file ; do EXCLUDES+="':(top,exclude)$file' " ; done < .clang-format-ignore
18+
19+
# Make sure we can refer to ${BASE_BRANCH} by name
20+
git checkout ${BASE_BRANCH}
21+
git checkout ${MERGE_BRANCH}
22+
23+
# Find the commit on which the PR is based.
24+
MERGE_BASE=$(git merge-base ${BASE_BRANCH} ${MERGE_BRANCH})
25+
echo "Checking for formatting errors introduced since $MERGE_BASE"
26+
27+
# Do the checking. "eval" is used so that quotes (as inserted into $EXCLUDES
28+
# above) are not interpreted as parts of file names.
29+
eval git-clang-format-7 --binary clang-format-7 $MERGE_BASE -- $EXCLUDES
30+
git diff > formatted.diff
31+
if [[ -s formatted.diff ]] ; then
32+
echo 'Formatting error! The following diff shows the required changes'
33+
echo 'Use the raw log to get a version of the diff that preserves spacing'
34+
cat formatted.diff
35+
exit 1
36+
fi
37+
echo 'No formatting errors found'
38+
exit 0
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
./scripts/run_diff.sh CPPLINT $MERGE_BASE

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,50 @@ jobs:
129129

130130
- name: Build cbmc
131131
run: "%SCRIPT_DIR%\\build-cbmc.bat"
132+
133+
check-clang-format:
134+
runs-on: ubuntu-20.04
135+
steps:
136+
- uses: actions/checkout@v2
137+
with:
138+
submodules: true
139+
fetch-depth: 0
140+
- name: Fetch dependencies
141+
env:
142+
# This is needed in addition to -yq to prevent apt-get from asking for
143+
# user input
144+
DEBIAN_FRONTEND: noninteractive
145+
run: |
146+
sudo apt-get install -yq clang-format-7
147+
- name: Check updated lines of code match clang-format-7 style
148+
env:
149+
BASE_BRANCH: ${{ github.base_ref }}
150+
MERGE_BRANCH: ${{ github.ref }}
151+
run: ./.github/workflows/pull-request-check-clang-format.sh
152+
153+
check-cpplint:
154+
runs-on: ubuntu-20.04
155+
steps:
156+
- uses: actions/checkout@v2
157+
with:
158+
submodules: true
159+
fetch-depth: 0
160+
- name: Fetch dependencies
161+
env:
162+
# This is needed in addition to -yq to prevent apt-get from asking for
163+
# user input
164+
DEBIAN_FRONTEND: noninteractive
165+
run: |
166+
pip install unidiff
167+
- name: Check updated lines of code meet linting standards
168+
env:
169+
BASE_BRANCH: ${{ github.base_ref }}
170+
MERGE_BRANCH: ${{ github.ref }}
171+
run: ./.github/workflows/pull-request-check-cpplint.sh
172+
173+
check-string-table:
174+
runs-on: ubuntu-20.04
175+
steps:
176+
- uses: actions/checkout@v2
177+
- name: Check for unused irep ids
178+
run: ./scripts/string_table_check.sh

0 commit comments

Comments
 (0)