From 90ae17f38a5e22746297d03fd10dbe5383906850 Mon Sep 17 00:00:00 2001 From: Alawode Oluwandabira <24304808+RogueElement@users.noreply.github.com> Date: Thu, 16 Jan 2020 11:48:26 +0200 Subject: [PATCH] Cache github build action (#88) * Change Go action to build and add cache * Add dependency download step * Rearrange steps * Remove docker build * Change build tag * Enable Build on pull_request * Add linter checking * Add linter cache * Correct spelling * Change lint cache path * Cache go/bin instead * Add go bin to path * Correct command syntax * Test linter * Change cache step id * Change cache search pattern * Remove linter cache --- .github/workflows/build.yml | 45 +++++++++++++++++++++--------------- .github/workflows/docker.yml | 11 --------- README.md | 7 +++--- run_tests.sh | 2 -- 4 files changed, 31 insertions(+), 34 deletions(-) delete mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fd96f551..3e2f572c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,27 +1,36 @@ -name: Go -on: [push] +name: Build +on: [push, pull_request] jobs: - build: name: Build runs-on: ubuntu-latest steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go - - name: Set up Go 1.13 - uses: actions/setup-go@v1 - with: - go-version: 1.13 - id: go + - name: Cache (dependencies) + uses: actions/cache@v1 + id: cache + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - - name: Check out code into the Go module directory - uses: actions/checkout@v1 - + - name: Install linter + run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.22.2" - - name: Build, run tests and vet - run: | - go build - go test - go vet - env: - GO111MODULE: "on" + - name: Install dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: go mod download + - name: Lint + run: | + export PATH=$PATH:~/go/bin + ./run_tests.sh lint diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 0b0d371a..00000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Docker Build -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: Build the Docker image - run: ./run_docker.sh setup diff --git a/README.md b/README.md index 808170cd..0881d911 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,23 @@ # dcrlibwallet -[![Build Status](https://img.shields.io/github/workflow/status/raedahgroup/dcrlibwallet/Go)](https://github.com/raedahgroup/dcrlibwallet/actions) +[![Build Status](https://github.com/raedahgroup/dcrlibwallet/workflows/Build/badge.svg)](https://github.com/raedahgroup/dcrlibwallet/actions) A Decred wallet library written in golang for [dcrwallet](https://github.com/decred/dcrwallet) ## Build Dependencies [Go( >= 1.11 )](http://golang.org/doc/install) -[Gomobile](https://github.com/golang/go/wiki/Mobile#tools) (correctly init'd with gomobile init) +[Gomobile](https://github.com/golang/go/wiki/Mobile#tools) (correctly init'd with gomobile init) ## Build Instructions using Gomobile -To build this libary, clone the project +To build this libary, clone the project ```bash go get -t github.com/raedahgroup/dcrlibwallet cd $GOPATH/src/github.com/raedahgroup/dcrlibwallet/ ``` + and run the following commands in dcrlibwallet directory. ```bash diff --git a/run_tests.sh b/run_tests.sh index cb363897..535e1fc7 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -35,5 +35,3 @@ elif [[ "$option" = "all" ]]; then else echo "Usage: ./run_tests.sh [all | build | lint]" fi - -