Skip to content

Commit

Permalink
[CI] Add GitHub Actions (#451)
Browse files Browse the repository at this point in the history
References <#443 (comment)>.

With fetch-depth: 0 is required for comparing to origin/master

Also see actions/runner#342 for notes on $TRAVIS_COMMIT_RANGE.
  • Loading branch information
Frenzie authored Aug 26, 2021
1 parent b20e771 commit a8c57ac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ done

file_list_jq=$(jq -r '.[].filename' "$search_dir/languages.json" | grep -v '@none' | grep -v '@algorithm' | grep -v '@softhyphens')

# Sort to ensure they're in exactly the same order.
file_list=$(echo "$file_list"|tr " " "\n"|sort -u|tr "\n" " ")
file_list_jq=$(echo "$file_list_jq"|tr " " "\n"|sort -u|tr "\n" " ")

if [ ! "$file_list" = "$file_list_jq" ]; then
echo "Warning, json should reflect hyphenation patterns. Diff:"
diff <(echo "$file_list") <(echo "$file_list_jq")
Expand All @@ -26,7 +30,7 @@ for pattern in "${pattern_files[@]}"; do
xmllint "$pattern" >/dev/null || SHELLSCRIPT_ERROR=1
done

changed_files="$(git diff --name-only "$TRAVIS_COMMIT_RANGE" | grep -E '\.([CcHh]|[ch]pp)$')"
changed_files="$(git diff --name-only origin/master HEAD | grep -E '\.([CcHh]|[ch]pp)$')"

if [ -n "${changed_files}" ]; then
echo "Running cppcheck on ${changed_files}"
Expand Down Expand Up @@ -58,7 +62,7 @@ if [ -n "${changed_files}" ]; then
# ignore header files in clang-tidy for now
# @TODO rename to *.hpp (or *.hxx)?
# see https://github.com/koreader/crengine/pull/130#issuecomment-373823848
changed_files="$(git diff --name-only "$TRAVIS_COMMIT_RANGE" | grep -E '\.([Cc]|[c]pp)$')"
changed_files="$(git diff --name-only origin/master HEAD | grep -E '\.([Cc]|[c]pp)$')"
# To check them all, uncomment this:
# changed_files="$(find crengine/src | grep -E '\.([Cc]|[c]pp)$')"
echo "Running clang-tidy on ${changed_files}"
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CI
on: push

jobs:
linux:
name: Static linting
runs-on: ubuntu-latest

steps:
- name: Install prerequisites
run: sudo apt-get install clang-tidy-10 cppcheck jq libxml2-utils

- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Lint
run: .ci/script.sh

0 comments on commit a8c57ac

Please sign in to comment.