WIP: Feature/6/jeffreypicard/dockerize for deployment #7
9 changed files with 351 additions and 130 deletions
|
@ -3,26 +3,23 @@ on: [push, pull_request]
|
|||
jobs:
|
||||
build:
|
||||
name: Go CI
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: self-hosted
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.14, 1.15]
|
||||
go: [1.16]
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
|
||||
- name: Check out source
|
||||
uses: actions/checkout@v2
|
||||
- name: Install Linters
|
||||
run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.26.0"
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
GO111MODULE: "on"
|
||||
run: go build ./...
|
||||
|
||||
- name: Test
|
||||
env:
|
||||
GO111MODULE: "on"
|
||||
run: |
|
||||
sh ./goclean.sh
|
||||
|
58
.github/workflows/create-release.yml
vendored
Normal file
58
.github/workflows/create-release.yml
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
name: Create release
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
note:
|
||||
description: 'Note'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.16]
|
||||
os: [linux, darwin, windows]
|
||||
ar: [amd64, arm64]
|
||||
exclude:
|
||||
- go: 1.16
|
||||
os: windows
|
||||
ar: arm64
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v2
|
||||
- name: Build executables
|
||||
env:
|
||||
GOOS: ${{ matrix.os }}
|
||||
GOARCH: ${{ matrix.ar }}
|
||||
CGO_ENABLED: 0
|
||||
run: |
|
||||
go build -trimpath -ldflags="-s -w -buildid=" -v -o artifacts/ .
|
||||
go build -trimpath -ldflags="-s -w -buildid=" -v -o artifacts/ ./cmd/lbcctl/
|
||||
- name: SHA256 sum
|
||||
run: sha256sum -b artifacts/* > artifacts/lbcd.sha256
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: lbcd-${{ matrix.os }}-${{ matrix.ar }}
|
||||
path: artifacts/*
|
||||
|
||||
|
||||
# for releases see https://trstringer.com/github-actions-create-release-upload-artifacts/
|
||||
|
||||
# AWS S3 support:
|
||||
# - name: Upload to Amazon S3
|
||||
# uses: ItsKarma/aws-cli@v1.70.0
|
||||
# with:
|
||||
# args: s3 sync .release s3://my-bucket-name
|
||||
# env:
|
||||
# # Make sure to add the secrets in the repo settings page
|
||||
# # AWS_REGION is set to us-east-1 by default
|
||||
# AWS_ACCESS_KEY_ID: $
|
||||
# AWS_SECRET_ACCESS_KEY: $
|
||||
# AWS_REGION: us-east-1
|
35
.github/workflows/full-sync-part-1.yml
vendored
Normal file
35
.github/workflows/full-sync-part-1.yml
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
name: Full Sync From 0
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
note:
|
||||
description: 'Note'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Go CI
|
||||
runs-on: self-hosted
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.16]
|
||||
steps:
|
||||
- run: |
|
||||
echo "Note ${{ github.event.inputs.note }}!"
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v2
|
||||
- name: Build lbcd
|
||||
run: go build .
|
||||
- name: Create datadir
|
||||
run: echo "TEMP_DATA_DIR=$(mktemp -d)" >> $GITHUB_ENV
|
||||
- name: Run lbcd
|
||||
run: ./lbcd --datadir=${{env.TEMP_DATA_DIR}}/data --logdir=${{env.TEMP_DATA_DIR}}/logs --connect=127.0.0.1 --norpc
|
||||
- name: Remove datadir
|
||||
if: always()
|
||||
run: rm -rf ${{env.TEMP_DATA_DIR}}
|
37
.github/workflows/full-sync-part-2.yml
vendored
Normal file
37
.github/workflows/full-sync-part-2.yml
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
name: Full Sync From 814k
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
note:
|
||||
description: 'Note'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Go CI
|
||||
runs-on: self-hosted
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.16]
|
||||
steps:
|
||||
- run: |
|
||||
echo "Note ${{ github.event.inputs.note }}!"
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v2
|
||||
- name: Build lbcd
|
||||
run: go build .
|
||||
- name: Create datadir
|
||||
run: echo "TEMP_DATA_DIR=$(mktemp -d)" >> $GITHUB_ENV
|
||||
- name: Copy initial data
|
||||
run: cp -r /home/lbry/lbcd_814k/* ${{env.TEMP_DATA_DIR}}
|
||||
- name: Run lbcd
|
||||
run: ./lbcd --datadir=${{env.TEMP_DATA_DIR}}/data --logdir=${{env.TEMP_DATA_DIR}}/logs --connect=127.0.0.1 --norpc
|
||||
- name: Remove datadir
|
||||
if: always()
|
||||
run: rm -rf ${{env.TEMP_DATA_DIR}}
|
57
.github/workflows/golangci-lint.yml
vendored
Normal file
57
.github/workflows/golangci-lint.yml
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
name: golangci-lint
|
||||
|
||||
env:
|
||||
# go needs absolute directories, using the $HOME variable doesn't work here.
|
||||
GOCACHE: /home/runner/work/go/pkg/build
|
||||
GOPATH: /home/runner/work/go
|
||||
GO_VERSION: '^1.17.0'
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
branches:
|
||||
- "*"
|
||||
pull_request:
|
||||
branches:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
golangci:
|
||||
name: lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: setup go ${{ env.GO_VERSION }}
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '${{ env.GO_VERSION }}'
|
||||
|
||||
- name: checkout source
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: compile code
|
||||
run: go install -v ./...
|
||||
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
|
||||
version: latest
|
||||
|
||||
# Optional: working directory, useful for monorepos
|
||||
# working-directory: somedir
|
||||
|
||||
# Optional: golangci-lint command line arguments.
|
||||
# args: --issues-exit-code=0
|
||||
|
||||
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
||||
# only-new-issues: true
|
||||
|
||||
# Optional: if set to true then the action will use pre-installed Go.
|
||||
skip-go-installation: true
|
||||
|
||||
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
|
||||
# skip-pkg-cache: true
|
||||
|
||||
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
|
||||
# skip-build-cache: true
|
152
.golangci.yml
Normal file
152
.golangci.yml
Normal file
|
@ -0,0 +1,152 @@
|
|||
linters-settings:
|
||||
depguard:
|
||||
list-type: blacklist
|
||||
packages:
|
||||
# logging is allowed only by logutils.Log, logrus
|
||||
# is allowed to use only in logutils package
|
||||
- github.com/sirupsen/logrus
|
||||
packages-with-error-message:
|
||||
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
|
||||
dupl:
|
||||
threshold: 100
|
||||
funlen:
|
||||
lines: 100
|
||||
statements: 50
|
||||
gci:
|
||||
local-prefixes: github.com/golangci/golangci-lint
|
||||
goconst:
|
||||
min-len: 2
|
||||
min-occurrences: 2
|
||||
gocritic:
|
||||
enabled-tags:
|
||||
- diagnostic
|
||||
- experimental
|
||||
- opinionated
|
||||
- performance
|
||||
- style
|
||||
disabled-checks:
|
||||
- dupImport # https://github.com/go-critic/go-critic/issues/845
|
||||
- ifElseChain
|
||||
- octalLiteral
|
||||
- whyNoLint
|
||||
- wrapperFunc
|
||||
gocyclo:
|
||||
min-complexity: 15
|
||||
goimports:
|
||||
local-prefixes: github.com/golangci/golangci-lint
|
||||
gomnd:
|
||||
settings:
|
||||
mnd:
|
||||
# don't include the "operation" and "assign"
|
||||
checks:
|
||||
- argument
|
||||
- case
|
||||
- condition
|
||||
- return
|
||||
govet:
|
||||
check-shadowing: true
|
||||
settings:
|
||||
printf:
|
||||
funcs:
|
||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
|
||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
|
||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
|
||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
|
||||
lll:
|
||||
line-length: 140
|
||||
maligned:
|
||||
suggest-new: true
|
||||
misspell:
|
||||
locale: US
|
||||
nolintlint:
|
||||
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
|
||||
allow-unused: false # report any unused nolint directives
|
||||
require-explanation: false # don't require an explanation for nolint directives
|
||||
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- asciicheck
|
||||
- bodyclose
|
||||
# - deadcode
|
||||
- depguard
|
||||
# - dogsled
|
||||
# - dupl
|
||||
# - errcheck
|
||||
# - exhaustive
|
||||
- exportloopref
|
||||
# - funlen
|
||||
# - gochecknoglobals
|
||||
# - gochecknoinits
|
||||
# - gocognit
|
||||
# - goconst
|
||||
# - gocritic
|
||||
# - gocyclo
|
||||
# - godot
|
||||
# - godox
|
||||
# - goerr113
|
||||
- gofmt
|
||||
- goimports
|
||||
# - gomnd
|
||||
- goprintffuncname
|
||||
# - gosec
|
||||
# - gosimple
|
||||
# - govet
|
||||
# - ineffassign
|
||||
# - interfacer
|
||||
# - lll
|
||||
# - maligned
|
||||
# - misspell
|
||||
- nakedret
|
||||
# - nestif
|
||||
# - noctx
|
||||
# - nolintlint
|
||||
# - prealloc
|
||||
- rowserrcheck
|
||||
# - revive
|
||||
# - scopelint
|
||||
# - staticcheck
|
||||
# - structcheck
|
||||
# - stylecheck
|
||||
# - testpackage
|
||||
# - typecheck
|
||||
- unconvert
|
||||
# - unparam
|
||||
# - unused
|
||||
# - varcheck
|
||||
# - whitespace
|
||||
# - wsl
|
||||
|
||||
issues:
|
||||
# Excluding configuration per-path, per-linter, per-text and per-source
|
||||
exclude-rules:
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- gomnd
|
||||
|
||||
- path: pkg/golinters/errcheck.go
|
||||
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
|
||||
- path: pkg/commands/run.go
|
||||
text: "SA1019: lsc.Errcheck.Exclude is deprecated: use ExcludeFunctions instead"
|
||||
|
||||
# TODO must be removed after the release of the next version (v1.41.0)
|
||||
- path: pkg/commands/run.go
|
||||
linters:
|
||||
- gomnd
|
||||
# TODO must be removed after the release of the next version (v1.41.0)
|
||||
- path: pkg/golinters/nolintlint/nolintlint.go
|
||||
linters:
|
||||
- gomnd
|
||||
# TODO must be removed after the release of the next version (v1.41.0)
|
||||
- path: pkg/printers/tab.go
|
||||
linters:
|
||||
- gomnd
|
||||
|
||||
|
||||
run:
|
||||
skip-dirs:
|
||||
- test/testdata_etc
|
||||
- internal/cache
|
||||
- internal/renameio
|
||||
- internal/robustio
|
13
Dockerfile
13
Dockerfile
|
@ -9,14 +9,14 @@
|
|||
# docker build . -t yourregistry/btcd --build-arg ARCH=arm64v8
|
||||
#
|
||||
# For more information how to use this docker image visit:
|
||||
# https://github.com/btcsuite/btcd/tree/master/docs
|
||||
# https://github.com/lbryio/lbcd/tree/master/docs
|
||||
#
|
||||
# 8333 Mainnet Bitcoin peer-to-peer port
|
||||
# 8334 Mainet RPC port
|
||||
|
||||
ARG ARCH=amd64
|
||||
|
||||
FROM golang:1.14-alpine3.12 AS build-container
|
||||
FROM golang:1.16-alpine3.14 AS build-container
|
||||
|
||||
ARG ARCH
|
||||
ENV GO111MODULE=on
|
||||
|
@ -25,17 +25,16 @@ ADD . /app
|
|||
WORKDIR /app
|
||||
RUN set -ex \
|
||||
&& if [ "${ARCH}" = "amd64" ]; then export GOARCH=amd64; fi \
|
||||
&& if [ "${ARCH}" = "arm32v7" ]; then export GOARCH=arm; fi \
|
||||
&& if [ "${ARCH}" = "arm64v8" ]; then export GOARCH=arm64; fi \
|
||||
&& echo "Compiling for $GOARCH" \
|
||||
&& go install -v . ./cmd/...
|
||||
|
||||
FROM $ARCH/alpine:3.12
|
||||
FROM $ARCH/alpine:3.14
|
||||
|
||||
COPY --from=build-container /go/bin /bin
|
||||
|
||||
VOLUME ["/root/.btcd"]
|
||||
VOLUME ["/root/.lbcd"]
|
||||
|
||||
EXPOSE 8333 8334
|
||||
EXPOSE 9245 9246
|
||||
|
||||
ENTRYPOINT ["btcd"]
|
||||
ENTRYPOINT ["lbcd"]
|
||||
|
|
|
@ -10,10 +10,4 @@
|
|||
set -ex
|
||||
|
||||
env GORACE="halt_on_error=1" go test -race -tags="rpctest" -covermode atomic -coverprofile=profile.cov ./...
|
||||
|
||||
# Automatic checks
|
||||
golangci-lint run --deadline=10m --disable-all \
|
||||
--enable=gofmt \
|
||||
--enable=vet \
|
||||
--enable=gosimple \
|
||||
--enable=unconvert
|
||||
go test -bench=. -benchtime=4000x ./claimtrie/
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (c) 2016 Company 0, LLC.
|
||||
# Copyright (c) 2016-2020 The btcsuite developers
|
||||
# Use of this source code is governed by an ISC
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
# Simple bash script to build basic btcd tools for all the platforms we support
|
||||
# with the golang cross-compiler.
|
||||
|
||||
set -e
|
||||
|
||||
# If no tag specified, use date + version otherwise use tag.
|
||||
if [[ $1x = x ]]; then
|
||||
DATE=`date +%Y%m%d`
|
||||
VERSION="01"
|
||||
TAG=$DATE-$VERSION
|
||||
else
|
||||
TAG=$1
|
||||
fi
|
||||
|
||||
go mod vendor
|
||||
tar -cvzf vendor.tar.gz vendor
|
||||
|
||||
PACKAGE=btcd
|
||||
MAINDIR=$PACKAGE-$TAG
|
||||
mkdir -p $MAINDIR
|
||||
|
||||
cp vendor.tar.gz $MAINDIR/
|
||||
rm vendor.tar.gz
|
||||
rm -r vendor
|
||||
|
||||
PACKAGESRC="$MAINDIR/$PACKAGE-source-$TAG.tar"
|
||||
git archive -o $PACKAGESRC HEAD
|
||||
gzip -f $PACKAGESRC > "$PACKAGESRC.gz"
|
||||
|
||||
cd $MAINDIR
|
||||
|
||||
# If BTCDBUILDSYS is set the default list is ignored. Useful to release
|
||||
# for a subset of systems/architectures.
|
||||
SYS=${BTCDBUILDSYS:-"
|
||||
darwin-amd64
|
||||
dragonfly-amd64
|
||||
freebsd-386
|
||||
freebsd-amd64
|
||||
freebsd-arm
|
||||
illumos-amd64
|
||||
linux-386
|
||||
linux-amd64
|
||||
linux-armv6
|
||||
linux-armv7
|
||||
linux-arm64
|
||||
linux-ppc64
|
||||
linux-ppc64le
|
||||
linux-mips
|
||||
linux-mipsle
|
||||
linux-mips64
|
||||
linux-mips64le
|
||||
linux-s390x
|
||||
netbsd-386
|
||||
netbsd-amd64
|
||||
netbsd-arm
|
||||
netbsd-arm64
|
||||
openbsd-386
|
||||
openbsd-amd64
|
||||
openbsd-arm
|
||||
openbsd-arm64
|
||||
solaris-amd64
|
||||
windows-386
|
||||
windows-amd64
|
||||
"}
|
||||
|
||||
# Use the first element of $GOPATH in the case where GOPATH is a list
|
||||
# (something that is totally allowed).
|
||||
PKG="github.com/btcsuite/btcd"
|
||||
COMMIT=$(git describe --abbrev=40 --dirty)
|
||||
|
||||
for i in $SYS; do
|
||||
OS=$(echo $i | cut -f1 -d-)
|
||||
ARCH=$(echo $i | cut -f2 -d-)
|
||||
ARM=
|
||||
|
||||
if [[ $ARCH = "armv6" ]]; then
|
||||
ARCH=arm
|
||||
ARM=6
|
||||
elif [[ $ARCH = "armv7" ]]; then
|
||||
ARCH=arm
|
||||
ARM=7
|
||||
fi
|
||||
|
||||
mkdir $PACKAGE-$i-$TAG
|
||||
cd $PACKAGE-$i-$TAG
|
||||
|
||||
echo "Building:" $OS $ARCH $ARM
|
||||
env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -trimpath -ldflags="-s -w -buildid=" github.com/btcsuite/btcd
|
||||
env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -trimpath -ldflags="-s -w -buildid=" github.com/btcsuite/btcd/cmd/btcctl
|
||||
cd ..
|
||||
|
||||
if [[ $OS = "windows" ]]; then
|
||||
zip -r $PACKAGE-$i-$TAG.zip $PACKAGE-$i-$TAG
|
||||
else
|
||||
tar -cvzf $PACKAGE-$i-$TAG.tar.gz $PACKAGE-$i-$TAG
|
||||
fi
|
||||
|
||||
rm -r $PACKAGE-$i-$TAG
|
||||
done
|
||||
|
||||
shasum -a 256 * > manifest-$TAG.txt
|
Loading…
Reference in a new issue