diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c31ddad7..2460c517 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,14 +63,16 @@ jobs: run: make rpc-check ######################## - # compile unit tests + # check commits ######################## - unit-compile: - name: compile unit tests + check-commits: + name: check commits runs-on: ubuntu-latest steps: - name: git checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: go cache uses: actions/cache@v1 @@ -88,8 +90,16 @@ jobs: with: go-version: '~${{ env.GO_VERSION }}' - - name: compile - run: make unit pkg=... case=_NONE_ + - name: fetch and rebase on master + run: | + git remote add upstream https://github.com/lightningnetwork/lnd + git fetch upstream + export GIT_COMMITTER_EMAIL="lnd-ci@example.com" + export GIT_COMMITTER_NAME="LND CI" + git rebase upstream/master + + - name: check commits + run: scripts/check-each-commit.sh upstream/master ######################## # lint code diff --git a/scripts/check-commit.sh b/scripts/check-commit.sh new file mode 100755 index 00000000..79c79639 --- /dev/null +++ b/scripts/check-commit.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +set -x +echo Testing $(git log -1 --oneline) +make unit pkg=... case=_NONE_ diff --git a/scripts/check-each-commit.sh b/scripts/check-each-commit.sh new file mode 100755 index 00000000..6ae614ff --- /dev/null +++ b/scripts/check-each-commit.sh @@ -0,0 +1,15 @@ +#!/bin/bash +if [[ "$1" = "" ]]; then + echo "USAGE: $0 remote/head_branch" + echo "eg $0 upstream/master" + exit 1 +fi + +set -e +set -x + +if [[ "$(git log --pretty="%H %D" | grep "^[0-9a-f]*.* $1")" = "" ]]; then + echo "It seems like the current checked-out commit is not based on $1" + exit 1 +fi +git rebase --exec scripts/check-commit.sh $1