diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 893debbf7..d678e3ebb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -104,34 +104,6 @@ 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: 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 ######################## diff --git a/docs/code_contribution_guidelines.md b/docs/code_contribution_guidelines.md index 980d021fc..23565164d 100644 --- a/docs/code_contribution_guidelines.md +++ b/docs/code_contribution_guidelines.md @@ -12,6 +12,7 @@ 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. [Use of Log Levels](#use-of-log-levels) + 1. [Use of Golang submodules](#use-of-golang-submodules) 5. [Code Approval Process](#code-approval-process) 1. [Code Review](#code-review) 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, 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 This section describes the code approval process that is used for code diff --git a/go.mod b/go.mod index 8fd87bef2..d5f74e088 100644 --- a/go.mod +++ b/go.mod @@ -66,10 +66,7 @@ require ( ) // TODO(guggero): Remove these after merging #6350 and pushing the new tag! -replace ( - github.com/lightningnetwork/lnd/healthcheck => ./healthcheck - github.com/lightningnetwork/lnd/tor => ./tor -) +replace github.com/lightningnetwork/lnd/healthcheck => ./healthcheck // This replace is for https://github.com/advisories/GHSA-w73w-5m7g-f7qc replace github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt v3.2.1+incompatible diff --git a/go.sum b/go.sum index b2aaf3ad6..476d04ee9 100644 --- a/go.sum +++ b/go.sum @@ -477,6 +477,8 @@ github.com/lightningnetwork/lnd/ticker v1.1.0 h1:ShoBiRP3pIxZHaETndfQ5kEe+S4NdAY github.com/lightningnetwork/lnd/ticker v1.1.0/go.mod h1:ubqbSVCn6RlE0LazXuBr7/Zi6QT0uQo++OgIRBxQUrk= github.com/lightningnetwork/lnd/tlv v1.0.2 h1:LG7H3Uw/mHYGnEeHRPg+STavAH+UsFvuBflD0PzcYFQ= github.com/lightningnetwork/lnd/tlv v1.0.2/go.mod h1:fICAfsqk1IOsC1J7G9IdsWX1EqWRMqEDCNxZJSKr9C4= +github.com/lightningnetwork/lnd/tor v1.0.0 h1:wvEc7I+Y7IOtPglVP3cVBbYhiVhc7uTd7cMF9gQRzwA= +github.com/lightningnetwork/lnd/tor v1.0.0/go.mod h1:RDtaAdwfAm+ONuPYwUhNIH1RAvKPv+75lHPOegUcz64= github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 h1:sjOGyegMIhvgfq5oaue6Td+hxZuf3tDC8lAPrFldqFw= github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796/go.mod h1:3p7ZTf9V1sNPI5H8P3NkTFF4LuwMdPl2DodF60qAKqY= github.com/ltcsuite/ltcutil v0.0.0-20181217130922-17f3b04680b6/go.mod h1:8Vg/LTOO0KYa/vlHWJ6XZAevPQThGH5sufO0Hrou/lA= diff --git a/healthcheck/go.mod b/healthcheck/go.mod index e928c311c..c0caa8177 100644 --- a/healthcheck/go.mod +++ b/healthcheck/go.mod @@ -9,6 +9,3 @@ require ( github.com/stretchr/testify v1.7.0 golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e ) - -// TODO(guggero): Remove these after merging #6350 and pushing the new tag! -replace github.com/lightningnetwork/lnd/tor => ../tor diff --git a/healthcheck/go.sum b/healthcheck/go.sum index ad928ca8f..cb5f1ad9a 100644 --- a/healthcheck/go.sum +++ b/healthcheck/go.sum @@ -42,6 +42,8 @@ github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlT github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/lightningnetwork/lnd/ticker v1.1.0 h1:ShoBiRP3pIxZHaETndfQ5kEe+S4NdAY1hiX7YbZ4QE4= github.com/lightningnetwork/lnd/ticker v1.1.0/go.mod h1:ubqbSVCn6RlE0LazXuBr7/Zi6QT0uQo++OgIRBxQUrk= +github.com/lightningnetwork/lnd/tor v1.0.0 h1:wvEc7I+Y7IOtPglVP3cVBbYhiVhc7uTd7cMF9gQRzwA= +github.com/lightningnetwork/lnd/tor v1.0.0/go.mod h1:RDtaAdwfAm+ONuPYwUhNIH1RAvKPv+75lHPOegUcz64= github.com/miekg/dns v1.1.43 h1:JKfpVSCB84vrAmHzyrsxB5NAr5kLoMXZArPSw7Qlgyg= github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= diff --git a/scripts/check-submodule-version.sh b/scripts/check-submodule-version.sh deleted file mode 100755 index f3685356e..000000000 --- a/scripts/check-submodule-version.sh +++ /dev/null @@ -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