From 601cf60070de6e509bcf4d0006d7b5305ccf6b80 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 15 Dec 2022 16:03:55 +0800 Subject: [PATCH 1/4] tools: fix docker version --- docs/release-notes/release-notes-0.16.0.md | 3 +++ tools/Dockerfile | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/release-notes-0.16.0.md b/docs/release-notes/release-notes-0.16.0.md index 991e07e20..3952878e7 100644 --- a/docs/release-notes/release-notes-0.16.0.md +++ b/docs/release-notes/release-notes-0.16.0.md @@ -294,6 +294,9 @@ certain large transactions](https://github.com/lightningnetwork/lnd/pull/7100). check](https://github.com/lightningnetwork/lnd/pull/7114) for all non-PR events. +* Fixed docker image version used in + [`tools`](https://github.com/lightningnetwork/lnd/pull/7254). + ### Integration test The `lntest` has been diff --git a/tools/Dockerfile b/tools/Dockerfile index 2707e0f67..4da8390c4 100644 --- a/tools/Dockerfile +++ b/tools/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19.2-buster +FROM golang:1.19 RUN apt-get update && apt-get install -y git ENV GOCACHE=/tmp/build/.cache From 26613a2d46b64e8e531730d0c057272a65ea16d0 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 15 Dec 2022 16:23:13 +0800 Subject: [PATCH 2/4] github: create new action to hold common setup --- .github/actions/setup-go/action.yml | 28 +++++ .github/workflows/main.yml | 187 +++++----------------------- 2 files changed, 61 insertions(+), 154 deletions(-) create mode 100644 .github/actions/setup-go/action.yml diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml new file mode 100644 index 000000000..1db347509 --- /dev/null +++ b/.github/actions/setup-go/action.yml @@ -0,0 +1,28 @@ +# A resuable workflow that's used to setup the go enviroment and cache. +name: Setup go enviroment + +runs: + using: "composite" + + steps: + - name: setup go ${{ env.GO_VERSION }} + uses: actions/setup-go@v3 + with: + go-version: '${{ env.GO_VERSION }}' + + - name: go cache + uses: actions/cache@v3 + with: + # In order: + # * Module download cache + # * Build cache (Linux) + # * Build cache (Mac) + # * Build cache (Windows) + path: | + ~/go/pkg/mod + ~/.cache/go-build + ~/Library/Caches/go-build + ~\AppData\Local\go-build + key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-${{ env.GO_VERSION }}- diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3c3009d04..0aca948a3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,10 +42,9 @@ jobs: - name: git checkout uses: actions/checkout@v3 - - name: setup go ${{ env.GO_VERSION }} - uses: actions/setup-go@v3 - with: - go-version: '${{ env.GO_VERSION }}' + - id: setup + name: Setup go env + uses: ./.github/actions/setup-go - name: fmt run: make fmt-check @@ -60,21 +59,9 @@ jobs: - name: git checkout uses: actions/checkout@v2 - - name: go cache - uses: actions/cache@v1 - with: - path: /home/runner/work/go - key: lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}- - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}- - lnd-${{ runner.os }}-go- - - - name: setup go ${{ env.GO_VERSION }} - uses: actions/setup-go@v2 - with: - go-version: '${{ env.GO_VERSION }}' + - id: setup + name: Setup go env + uses: ./.github/actions/setup-go - name: run check run: make rpc-check @@ -101,21 +88,9 @@ jobs: with: fetch-depth: 0 - - name: go cache - uses: actions/cache@v1 - with: - path: /home/runner/work/go - key: lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}- - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}- - lnd-${{ runner.os }}-go- - - - name: setup go ${{ env.GO_VERSION }} - uses: actions/setup-go@v2 - with: - go-version: '${{ env.GO_VERSION }}' + - id: setup + name: Setup go env + uses: ./.github/actions/setup-go - name: fetch and rebase on ${{ github.base_ref }} run: | @@ -141,21 +116,9 @@ jobs: - name: Fetch all history for linter run: git fetch --prune --unshallow - - name: go cache - uses: actions/cache@v1 - with: - path: /home/runner/work/go - key: lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}- - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}- - lnd-${{ runner.os }}-go- - - - name: setup go ${{ env.GO_VERSION }} - uses: actions/setup-go@v2 - with: - go-version: '${{ env.GO_VERSION }}' + - id: setup + name: Setup go env + uses: ./.github/actions/setup-go - name: lint run: GOGC=50 make lint @@ -170,21 +133,9 @@ jobs: - name: git checkout uses: actions/checkout@v2 - - name: go cache - uses: actions/cache@v1 - with: - path: /home/runner/work/go - key: lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}- - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}- - lnd-${{ runner.os }}-go- - - - name: setup go ${{ env.GO_VERSION }} - uses: actions/setup-go@v2 - with: - go-version: '${{ env.GO_VERSION }}' + - id: setup + name: Setup go env + uses: ./.github/actions/setup-go - name: build release for all architectures run: make release @@ -199,21 +150,9 @@ jobs: - name: git checkout uses: actions/checkout@v2 - - name: go cache - uses: actions/cache@v1 - with: - path: /home/runner/work/go - key: lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}- - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}- - lnd-${{ runner.os }}-go- - - - name: setup go ${{ env.GO_VERSION }} - uses: actions/setup-go@v2 - with: - go-version: '${{ env.GO_VERSION }}' + - id: setup + name: Setup go env + uses: ./.github/actions/setup-go - name: check all command line flags exist in sample-lnd.conf file run: make sample-conf-check @@ -237,21 +176,9 @@ jobs: - name: git checkout uses: actions/checkout@v2 - - name: go cache - uses: actions/cache@v1 - with: - path: /home/runner/work/go - key: lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}- - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}- - lnd-${{ runner.os }}-go- - - - name: setup go ${{ env.GO_VERSION }} - uses: actions/setup-go@v2 - with: - go-version: '${{ env.GO_VERSION }}' + - id: setup + name: Setup go env + uses: ./.github/actions/setup-go - name: install bitcoind run: ./scripts/install_bitcoind.sh @@ -295,21 +222,9 @@ jobs: - name: git checkout uses: actions/checkout@v2 - - name: go cache - uses: actions/cache@v1 - with: - path: /home/runner/work/go - key: lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}- - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}- - lnd-${{ runner.os }}-go- - - - name: setup go ${{ env.GO_VERSION }} - uses: actions/setup-go@v2 - with: - go-version: '${{ env.GO_VERSION }}' + - id: setup + name: Setup go env + uses: ./.github/actions/setup-go - name: install bitcoind run: ./scripts/install_bitcoind.sh @@ -343,21 +258,9 @@ jobs: - name: git checkout uses: actions/checkout@v2 - - name: go cache - uses: actions/cache@v1 - with: - path: ${{ env.GOPATH }} - key: lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}- - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}- - lnd-${{ runner.os }}-go- - - - name: setup go ${{ env.GO_VERSION }} - uses: actions/setup-go@v2 - with: - go-version: '${{ env.GO_VERSION }}' + - id: setup + name: Setup go env + uses: ./.github/actions/setup-go - name: run itest run: make itest-parallel windows=1 tranches=2 parallel=2 @@ -403,21 +306,9 @@ jobs: - name: git checkout uses: actions/checkout@v3 - - name: go cache - uses: actions/cache@v1 - with: - path: /home/runner/work/go - key: lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}- - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}- - lnd-${{ runner.os }}-go- - - - name: setup go ${{ env.GO_VERSION }} - uses: actions/setup-go@v3 - with: - go-version: '${{ env.GO_VERSION }}' + - id: setup + name: Setup go env + uses: ./.github/actions/setup-go - name: install bitcoind run: ./scripts/install_bitcoind.sh @@ -451,21 +342,9 @@ jobs: - name: git checkout uses: actions/checkout@v3 - - name: go cache - uses: actions/cache@v1 - with: - path: ${{ env.GOPATH }} - key: lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - restore-keys: | - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}- - lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}- - lnd-${{ runner.os }}-go- - - - name: setup go ${{ env.GO_VERSION }} - uses: actions/setup-go@v3 - with: - go-version: '${{ env.GO_VERSION }}' + - id: setup + name: Setup go env + uses: ./.github/actions/setup-go - name: run new itest run: make itest-parallel temptest=true windows=1 tranches=2 parallel=2 From 26110beb531f686e696696414e01065694ba429e Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 15 Dec 2022 16:32:45 +0800 Subject: [PATCH 3/4] github: upgrade `actions/checkout` to `v3` --- .github/workflows/main.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0aca948a3..75ef60991 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,7 +57,7 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - id: setup name: Setup go env @@ -84,7 +84,7 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 @@ -111,10 +111,9 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v2 - - - name: Fetch all history for linter - run: git fetch --prune --unshallow + uses: actions/checkout@v3 + with: + fetch-depth: 0 - id: setup name: Setup go env @@ -131,7 +130,7 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - id: setup name: Setup go env @@ -148,7 +147,7 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - id: setup name: Setup go env @@ -174,7 +173,7 @@ jobs: - btcd unit-race steps: - name: git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - id: setup name: Setup go env @@ -220,7 +219,7 @@ jobs: args: backend=neutrino steps: - name: git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - id: setup name: Setup go env @@ -256,7 +255,7 @@ jobs: GOPATH: ${{ github.workspace }}/go steps: - name: git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - id: setup name: Setup go env @@ -379,7 +378,7 @@ jobs: steps: - name: git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ensure dependences at correct version run: if ! grep -q "${{ matrix.pinned_dep }}" go.mod; then echo dependency ${{ matrix.pinned_dep }} should not be altered ; exit 1 ; fi @@ -392,7 +391,7 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: release notes check run: scripts/check-release-notes.sh From 3ca7e3019938063cc1499dd5e9007c5f2bc99272 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 15 Dec 2022 16:56:06 +0800 Subject: [PATCH 4/4] github: move `fmt-check` into `lint` --- .github/workflows/main.yml | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 75ef60991..5614a387a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,23 +32,6 @@ env: GO_VERSION: 1.19.2 jobs: - ######################## - # format code - ######################## - fmt-check: - name: check code format - runs-on: ubuntu-latest - steps: - - name: git checkout - uses: actions/checkout@v3 - - - id: setup - name: Setup go env - uses: ./.github/actions/setup-go - - - name: fmt - run: make fmt-check - ######################## # RPC and mobile compilation check ######################## @@ -119,6 +102,9 @@ jobs: name: Setup go env uses: ./.github/actions/setup-go + - name: check code format + run: make fmt-check + - name: lint run: GOGC=50 make lint