mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-03 17:26:57 +01:00
docs+github+scripts: remove submodule update check
Because we want to avoid local replace directives (as they make it easy to screw up things for external applications that use lnd as a library without us noticing), we're going to switch over to a new process. See section "Use of Golang submodules" in the code contribution guideline.
This commit is contained in:
parent
2b34c1e7ed
commit
bdda2aa059
3 changed files with 19 additions and 62 deletions
28
.github/workflows/main.yml
vendored
28
.github/workflows/main.yml
vendored
|
@ -104,34 +104,6 @@ jobs:
|
||||||
- name: check commits
|
- name: check commits
|
||||||
run: scripts/check-each-commit.sh upstream/master
|
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: setup go ${{ env.GO_VERSION }}
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: '${{ env.GO_VERSION }}'
|
|
||||||
|
|
||||||
- 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
|
# lint code
|
||||||
########################
|
########################
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
1. [Code Spacing and formatting](#code-spacing-and-formatting)
|
1. [Code Spacing and formatting](#code-spacing-and-formatting)
|
||||||
1. [Pointing to Remote Dependent Branches in Go Modules](#pointing-to-remote-dependent-branches-in-go-modules)
|
1. [Pointing to Remote Dependent Branches in Go Modules](#pointing-to-remote-dependent-branches-in-go-modules)
|
||||||
1. [Use of Log Levels](#use-of-log-levels)
|
1. [Use of Log Levels](#use-of-log-levels)
|
||||||
|
1. [Use of Golang submodules](#use-of-golang-submodules)
|
||||||
5. [Code Approval Process](#code-approval-process)
|
5. [Code Approval Process](#code-approval-process)
|
||||||
1. [Code Review](#code-review)
|
1. [Code Review](#code-review)
|
||||||
1. [Rework Code (if needed)](#rework-code-if-needed)
|
1. [Rework Code (if needed)](#rework-code-if-needed)
|
||||||
|
@ -640,6 +641,24 @@ Only use `error` for internal errors that are never expected to happen during
|
||||||
normal operation. No event triggered by external sources (rpc, chain backend,
|
normal operation. No event triggered by external sources (rpc, chain backend,
|
||||||
etc) should lead to an `error` log.
|
etc) should lead to an `error` log.
|
||||||
|
|
||||||
|
## Use of Golang submodules
|
||||||
|
|
||||||
|
Changes to packages that are their own submodules (e.g. they contain a `go.mod`
|
||||||
|
and `go.sum` file, for example `tor/go.mod`) require a specific process.
|
||||||
|
We want to avoid the use of local replace directives in the root `go.mod`,
|
||||||
|
therefore changes to a submodule are a bit involved.
|
||||||
|
|
||||||
|
The main process for updating and then using code in a submodule is as follows:
|
||||||
|
- Create a PR for the changes to the submodule itself (e.g. edit something in
|
||||||
|
the `tor` package)
|
||||||
|
- Wait for the PR to be merged and a new tag (for example `tor/v1.0.x`) to be
|
||||||
|
pushed.
|
||||||
|
- Create a second PR that bumps the updated submodule in the root `go.mod` and
|
||||||
|
uses the new functionality in the main module.
|
||||||
|
|
||||||
|
Of course the two PRs can be opened at the same time and be built on top of each
|
||||||
|
other. But the merge and tag push order should always be maintained.
|
||||||
|
|
||||||
# Code Approval Process
|
# Code Approval Process
|
||||||
|
|
||||||
This section describes the code approval process that is used for code
|
This section describes the code approval process that is used for code
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
#!/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
|
|
Loading…
Add table
Reference in a new issue