From dc517d89c4eb0bd070c7d160b664720f54ecca37 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 18 Nov 2021 12:42:32 +0100 Subject: [PATCH 1/2] mod: bump version of kvdb submodule PR #5992 was merged without a bump in the kvdb version which results in an error when trying to pull in lnd 0.14.0-beta as a library in other projects. We'll need to push the kvdb/v1.2.1 tag _after_ merging this PR. --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 25fdb5975..0299527c4 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( github.com/lightningnetwork/lnd/cert v1.1.0 github.com/lightningnetwork/lnd/clock v1.1.0 github.com/lightningnetwork/lnd/healthcheck v1.2.0 - github.com/lightningnetwork/lnd/kvdb v1.2.0 + github.com/lightningnetwork/lnd/kvdb v1.2.1 github.com/lightningnetwork/lnd/queue v1.1.0 github.com/lightningnetwork/lnd/ticker v1.1.0 github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 From 55edd1b260605760679fa6d78de4ede676a018bb Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 18 Nov 2021 12:55:31 +0100 Subject: [PATCH 2/2] scripts+GitHub: check submodule version bump --- .github/workflows/main.yml | 23 ++++++++++++++++++++ scripts/check-submodule-version.sh | 34 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100755 scripts/check-submodule-version.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d9e7a5934..1505a4d19 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -104,6 +104,29 @@ jobs: - name: check commits run: scripts/check-each-commit.sh upstream/master + ######################## + # check submodules + ######################## + check-submodules: + name: check submodules + runs-on: ubuntu-latest + steps: + - name: git checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - 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 submodules + run: scripts/check-submodule-version.sh upstream/master + ######################## # lint code ######################## diff --git a/scripts/check-submodule-version.sh b/scripts/check-submodule-version.sh new file mode 100755 index 000000000..f3685356e --- /dev/null +++ b/scripts/check-submodule-version.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +ROOT_MODULE="github.com/lightningnetwork/lnd" + +# The command 'go list -m all' returns all imports in the following format: +# github.com/lightningnetwork/lnd/cert v1.1.0 => ./cert +# The two cut then first split by spaces and then by slashes to extract the +# submodule names. +SUBMODULES="$(go list -m all | grep $ROOT_MODULE/ | cut -d' ' -f1 | cut -d'/' -f4-)" +BRANCH=$1 + +for m in $SUBMODULES; do + has_changes=0 + git diff --stat $BRANCH.. | grep -q " $m/" && has_changes=1 + + if [[ $has_changes -eq 1 ]]; then + has_bump=0 + git diff $BRANCH.. -- go.mod | \ + grep -q "^\+[[:space:]]*$ROOT_MODULE/$m " && has_bump=1 + + if [[ $has_bump -eq 0 ]]; then + echo "Submodule '$m' has changes but no version bump in go.mod was found" + echo "If you update code in a submodule, you must bump its version in " + echo "go.mod to the _next_ version so a tag for that version can be" + echo "pushed after merging the PR." + exit 1 + else + echo "Submodule '$m' has changes but go.mod bumps it to: " + git diff $BRANCH.. -- go.mod | grep $m + fi + else + echo "Submodule '$m' has no changes, skipping" + fi +done