[lbry] ci: add github workflows

This commit is contained in:
Roy Lee 2022-05-24 10:08:49 -07:00
parent 57e8d9cdd2
commit 3671cd0c05
3 changed files with 138 additions and 16 deletions

57
.github/workflows/golangci-lint.yml vendored Normal file
View 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.18.2'
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

View file

@ -1,7 +1,16 @@
name: CI name: CI
on: on:
workflow_dispatch:
inputs:
note:
description: 'Note'
required: false
default: ''
push: push:
tags:
- '*'
branches: branches:
- "master" - "master"
pull_request: pull_request:
@ -16,34 +25,33 @@ env:
# go needs absolute directories, using the $HOME variable doesn't work here. # go needs absolute directories, using the $HOME variable doesn't work here.
GOCACHE: /home/runner/work/go/pkg/build GOCACHE: /home/runner/work/go/pkg/build
GOPATH: /home/runner/work/go GOPATH: /home/runner/work/go
GO111MODULE: on
GO_VERSION: '^1.17.0' GO_VERSION: '^1.18.2'
jobs: jobs:
######################## ########################
# Format, compileation and lint check # Format, compileation and lint check
######################## ########################
lint-check: golangci:
name: Format, compilation and lint check name: lint
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: git checkout
uses: actions/checkout@v2
- name: setup go ${{ env.GO_VERSION }} - name: setup go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: '${{ env.GO_VERSION }}' go-version: '${{ env.GO_VERSION }}'
- name: run format - name: checkout source
run: make fmt uses: actions/checkout@v2
- name: compile code - name: compile code
run: go install -v ./... run: go install -v ./...
- name: run lint - name: golangci-lint
run: make lint uses: golangci/golangci-lint-action@v2
with:
version: latest
skip-go-installation: true
######################## ########################
# run unit tests # run unit tests
@ -66,12 +74,12 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: /home/runner/work/go path: /home/runner/work/go
key: btcwallet-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} key: lbcwallet-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
restore-keys: | restore-keys: |
btcwallet-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} lbcwallet-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
btcwallet-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}- lbcwallet-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-
btcwallet-${{ runner.os }}-go-${{ env.GO_VERSION }}- lbcwallet-${{ runner.os }}-go-${{ env.GO_VERSION }}-
btcwallet-${{ runner.os }}-go- lbcwallet-${{ runner.os }}-go-
- name: setup go ${{ env.GO_VERSION }} - name: setup go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2 uses: actions/setup-go@v2

57
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,57 @@
name: goreleaser
on:
workflow_dispatch:
inputs:
note:
description: 'Note'
required: false
default: ''
pull_request:
push:
tags:
- '*'
permissions:
contents: write
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18.2
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry docker.io
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: lbcwallet-${{ github.sha }}
path: |
dist/checksums.txt
dist/*.tar.gz