diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..89e29ed --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,44 @@ +name: run-go-tests + +env: + GO111MODULE: on + +on: + pull_request: + branches: + - "*" + push: + branches: + - "*" + schedule: + - cron: '* 22 * * *' + +jobs: + test: + strategy: + matrix: + go-version: [ 1.15.x ] + #go-version: [ 1.14.x, 1.15.x ] + os: [ ubuntu-latest ] + runs-on: ${{ matrix.os }} + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: | + ~/go/pkg/mod # Module download cache + ~/.cache/go-build # Build cache (Linux) + ~/Library/Caches/go-build # Build cache (Mac) + '%LocalAppData%\go-build' # Build cache (Windows) + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Run linter and tests + run: make test-ci + - name: Update code coverage + run: bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/.make/Makefile.go b/.make/Makefile.go index 333bd83..8a093b7 100644 --- a/.make/Makefile.go +++ b/.make/Makefile.go @@ -45,6 +45,8 @@ lint: ## Run the golangci-lint application (install if not found) @if [ "$(shell command -v golangci-lint)" = "" ] && [ $(TRAVIS) ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.33.0 && sudo cp ./bin/golangci-lint $(go env GOPATH)/bin/; fi; @#AWS CodePipeline @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(CODEBUILD_BUILD_ID)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.33.0; fi; + @#Github Actions + @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(GITHUB_WORKFLOW)" != "" ]; then curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b $(go env GOPATH)/bin v1.33.0; fi; @#Brew - MacOS @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(shell command -v brew)" != "" ]; then brew install golangci-lint; fi; @echo "running golangci-lint..." @@ -60,19 +62,19 @@ test-short: ## Runs vet, lint and tests (excludes integration tests) @echo "running tests (short)..." @go test ./... -v -test.short -test-travis: ## Runs all tests via Travis (also exports coverage) +test-ci: ## Runs all tests via CI (exports coverage) @$(MAKE) lint - @echo "running tests (travis)..." + @echo "running tests (CI)..." @go test ./... -race -coverprofile=coverage.txt -covermode=atomic -test-travis-no-race: ## Runs all tests (no race) (also exports coverage) +test-ci-no-race: ## Runs all tests via CI (no race) (exports coverage) @$(MAKE) lint - @echo "running tests (no race)..." + @echo "running tests (CI - no race)..." @go test ./... -coverprofile=coverage.txt -covermode=atomic -test-travis-short: ## Runs unit tests via Travis (also exports coverage) +test-ci-short: ## Runs unit tests via CI (exports coverage) @$(MAKE) lint - @echo "running tests (short & travis)..." + @echo "running tests (CI - unit tests only)..." @go test ./... -test.short -race -coverprofile=coverage.txt -covermode=atomic uninstall: ## Uninstall the application (and remove files) diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index abd6f1c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -# Fast runner (trick from @y0ssar1an) (out-dated) -sudo: false - -# Language of deployment -language: go - -# Version -go: - - 1.15.x - -# Environment variables -env: - - GO111MODULE=on - -# Only clone the most recent commit -git: - depth: 1 - -# Notifications off -notifications: - email: false - -# Run all scripts -script: - - make test-travis - -# After build success -after_success: - - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/README.md b/README.md index 5ba08c2..2d1bb21 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ # go-bitcoin - > A library for working with Bitcoin (BSV) transactions, addresses, keys, encryption, and more. [![Release](https://img.shields.io/github/release-pre/BitcoinSchema/go-bitcoin.svg?logo=github&style=flat&v=4)](https://github.com/BitcoinSchema/go-bitcoin/releases) -[![Build Status](https://travis-ci.com/BitcoinSchema/go-bitcoin.svg?branch=master&v=4)](https://travis-ci.com/BitcoinSchema/go-bitcoin) +[![Build Status](https://img.shields.io/github/workflow/status/BitcoinSchema/go-bitcoin/run-go-tests?logo=github&v=3)](https://github.com/BitcoinSchema/go-bitcoin/actions) [![Report](https://goreportcard.com/badge/github.com/BitcoinSchema/go-bitcoin?style=flat&v=4)](https://goreportcard.com/report/github.com/BitcoinSchema/go-bitcoin) [![codecov](https://codecov.io/gh/BitcoinSchema/go-bitcoin/branch/master/graph/badge.svg?v=4)](https://codecov.io/gh/BitcoinSchema/go-bitcoin) [![Go](https://img.shields.io/github/go-mod/go-version/BitcoinSchema/go-bitcoin?v=4)](https://golang.org/) @@ -119,29 +118,31 @@ make help List of all current commands: ```text -all Runs multiple commands -clean Remove previous builds and any test cache data -clean-mods Remove all the Go mod cache -coverage Shows the test coverage -godocs Sync the latest tag with GoDocs -help Show this help message -install Install the application -install-go Install the application (Using Native Go) -lint Run the Go lint application -release Full production release (creates release in Github) -release Runs common.release then runs godocs -release-snap Test the full release (build binaries) -release-test Full production test release (everything except deploy) -replace-version Replaces the version in HTML/JS (pre-deploy) -tag Generate a new tag and push (tag version=0.0.0) -tag-remove Remove a tag if found (tag-remove version=0.0.0) -tag-update Update an existing tag to current commit (tag-update version=0.0.0) -test Runs vet, lint and ALL tests -test-short Runs vet, lint and tests (excludes integration tests) -test-travis Runs all tests via Travis (also exports coverage) -test-travis-short Runs unit tests via Travis (also exports coverage) -uninstall Uninstall the application (and remove files) -vet Run the Go vet application +all Runs multiple commands +clean Remove previous builds and any test cache data +clean-mods Remove all the Go mod cache +coverage Shows the test coverage +godocs Sync the latest tag with GoDocs +help Show this help message +install Install the application +install-go Install the application (Using Native Go) +lint Run the golangci-lint application (install if not found) +release Full production release (creates release in Github) +release Runs common.release then runs godocs +release-snap Test the full release (build binaries) +release-test Full production test release (everything except deploy) +replace-version Replaces the version in HTML/JS (pre-deploy) +tag Generate a new tag and push (tag version=0.0.0) +tag-remove Remove a tag if found (tag-remove version=0.0.0) +tag-update Update an existing tag to current commit (tag-update version=0.0.0) +test Runs vet, lint and ALL tests +test-ci Runs all tests via CI (exports coverage) +test-ci-no-race Runs all tests via CI (no race) (exports coverage) +test-ci-short Runs unit tests via CI (exports coverage) +test-short Runs vet, lint and tests (excludes integration tests) +uninstall Uninstall the application (and remove files) +update-linter Update the golangci-lint package (macOS only) +vet Run the Go vet application ``` @@ -149,8 +150,8 @@ vet Run the Go vet application
## Examples & Tests - -All unit tests and [examples](examples) run via [Travis CI](https://travis-ci.com/bitcoinschema/go-bitcoin) and uses [Go version 1.15.x](https://golang.org/doc/go1.15). View the [deployment configuration file](.travis.yml). +All unit tests and [examples](examples) run via [Github Actions](https://github.com/tonicpow/go-bitcoin/actions) and +uses [Go version 1.15.x](https://golang.org/doc/go1.15). View the [configuration file](.github/workflows/run-tests.yml). Run all tests (including integration tests)