[github-actions] add pretty check (#385)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..643ff77
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,50 @@
+#
+## Copyright (c) 2020, The OpenThread Authors.
+## All rights reserved.
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted provided that the following conditions are met:
+## 1. Redistributions of source code must retain the above copyright
+## notice, this list of conditions and the following disclaimer.
+## 2. Redistributions in binary form must reproduce the above copyright
+## notice, this list of conditions and the following disclaimer in the
+## documentation and/or other materials provided with the distribution.
+## 3. Neither the name of the copyright holder nor the
+## names of its contributors may be used to endorse or promote products
+## derived from this software without specific prior written permission.
+##
+## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+## POSSIBILITY OF SUCH DAMAGE.
+##
+
+name: Build
+
+on: [push, pull_request]
+
+jobs:
+
+ cancel-previous-runs:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: rokroskar/workflow-run-cleanup-action@master
+ env:
+ GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
+ if: "github.ref != 'refs/heads/master'"
+
+ pretty:
+ runs-on: ubuntu-18.04
+ steps:
+ - uses: actions/checkout@v2
+ - name: Bootstrap
+ run: sudo BUILD_TARGET=pretty-check tests/scripts/bootstrap.sh
+ - name: Check
+ run: script/make-pretty check
diff --git a/.travis.yml b/.travis.yml
index ddcab91..f5a8a30 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,7 @@
directories:
- $HOME/.cache/tools
-before_install: .travis/before_install.sh
+before_install: ./tests/scripts/bootstrap.sh
script: .travis/script.sh
after_success:
- .travis/after_success.sh
diff --git a/.travis/before_install.sh b/tests/scripts/bootstrap.sh
similarity index 96%
rename from .travis/before_install.sh
rename to tests/scripts/bootstrap.sh
index 0918e76..71580b4 100755
--- a/.travis/before_install.sh
+++ b/tests/scripts/bootstrap.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# Copyright (c) 2017, The OpenThread Authors.
# All rights reserved.
@@ -73,8 +73,8 @@
echo 1 | sudo tee /proc/sys/net/ipv4/conf/all/forwarding
}
-case $TRAVIS_OS_NAME in
-linux)
+case "$(uname)" in
+"Linux")
sudo apt-get update
[ $BUILD_TARGET != script-check ] && [ $BUILD_TARGET != docker-check ] || {
install_openthread_binraries
@@ -108,6 +108,8 @@
[ $BUILD_TARGET != scan-build ] || sudo apt-get install -y clang
+ [ $BUILD_TARGET != pretty-check ] || sudo apt-get install -y clang-format-6.0
+
[ $BUILD_TARGET != check ] && [ $BUILD_TARGET != distcheck ] && [ $BUILD_TARGET != meshcop ] || {
sudo apt-get install -y \
avahi-daemon \
@@ -154,11 +156,12 @@
}
;;
-osx)
+"Darwin")
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
;;
*)
+ echo "Unknown os type"
die
;;
esac