github: create new action to hold common setup

This commit is contained in:
yyforyongyu 2022-12-15 16:23:13 +08:00
parent 601cf60070
commit 26613a2d46
No known key found for this signature in database
GPG key ID: 9BCD95C4FF296868
2 changed files with 61 additions and 154 deletions

28
.github/actions/setup-go/action.yml vendored Normal file
View file

@ -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 }}-

View file

@ -42,10 +42,9 @@ jobs:
- name: git checkout - name: git checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: setup go ${{ env.GO_VERSION }} - id: setup
uses: actions/setup-go@v3 name: Setup go env
with: uses: ./.github/actions/setup-go
go-version: '${{ env.GO_VERSION }}'
- name: fmt - name: fmt
run: make fmt-check run: make fmt-check
@ -60,21 +59,9 @@ jobs:
- name: git checkout - name: git checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: go cache - id: setup
uses: actions/cache@v1 name: Setup go env
with: uses: ./.github/actions/setup-go
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 }}'
- name: run check - name: run check
run: make rpc-check run: make rpc-check
@ -101,21 +88,9 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: go cache - id: setup
uses: actions/cache@v1 name: Setup go env
with: uses: ./.github/actions/setup-go
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 }}'
- name: fetch and rebase on ${{ github.base_ref }} - name: fetch and rebase on ${{ github.base_ref }}
run: | run: |
@ -141,21 +116,9 @@ jobs:
- name: Fetch all history for linter - name: Fetch all history for linter
run: git fetch --prune --unshallow run: git fetch --prune --unshallow
- name: go cache - id: setup
uses: actions/cache@v1 name: Setup go env
with: uses: ./.github/actions/setup-go
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 }}'
- name: lint - name: lint
run: GOGC=50 make lint run: GOGC=50 make lint
@ -170,21 +133,9 @@ jobs:
- name: git checkout - name: git checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: go cache - id: setup
uses: actions/cache@v1 name: Setup go env
with: uses: ./.github/actions/setup-go
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 }}'
- name: build release for all architectures - name: build release for all architectures
run: make release run: make release
@ -199,21 +150,9 @@ jobs:
- name: git checkout - name: git checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: go cache - id: setup
uses: actions/cache@v1 name: Setup go env
with: uses: ./.github/actions/setup-go
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 }}'
- name: check all command line flags exist in sample-lnd.conf file - name: check all command line flags exist in sample-lnd.conf file
run: make sample-conf-check run: make sample-conf-check
@ -237,21 +176,9 @@ jobs:
- name: git checkout - name: git checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: go cache - id: setup
uses: actions/cache@v1 name: Setup go env
with: uses: ./.github/actions/setup-go
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 }}'
- name: install bitcoind - name: install bitcoind
run: ./scripts/install_bitcoind.sh run: ./scripts/install_bitcoind.sh
@ -295,21 +222,9 @@ jobs:
- name: git checkout - name: git checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: go cache - id: setup
uses: actions/cache@v1 name: Setup go env
with: uses: ./.github/actions/setup-go
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 }}'
- name: install bitcoind - name: install bitcoind
run: ./scripts/install_bitcoind.sh run: ./scripts/install_bitcoind.sh
@ -343,21 +258,9 @@ jobs:
- name: git checkout - name: git checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: go cache - id: setup
uses: actions/cache@v1 name: Setup go env
with: uses: ./.github/actions/setup-go
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 }}'
- name: run itest - name: run itest
run: make itest-parallel windows=1 tranches=2 parallel=2 run: make itest-parallel windows=1 tranches=2 parallel=2
@ -403,21 +306,9 @@ jobs:
- name: git checkout - name: git checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: go cache - id: setup
uses: actions/cache@v1 name: Setup go env
with: uses: ./.github/actions/setup-go
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 }}'
- name: install bitcoind - name: install bitcoind
run: ./scripts/install_bitcoind.sh run: ./scripts/install_bitcoind.sh
@ -451,21 +342,9 @@ jobs:
- name: git checkout - name: git checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: go cache - id: setup
uses: actions/cache@v1 name: Setup go env
with: uses: ./.github/actions/setup-go
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 }}'
- name: run new itest - name: run new itest
run: make itest-parallel temptest=true windows=1 tranches=2 parallel=2 run: make itest-parallel temptest=true windows=1 tranches=2 parallel=2