From 84ef20a4aeab921ea62e3ce164e8266f3ad6085c Mon Sep 17 00:00:00 2001 From: Stanley Nguyen Date: Fri, 1 May 2020 10:14:57 +0800 Subject: [PATCH] ci(Github Actions) Add actions for unit tests and linting --- .github/workflows/lint.yml | 25 +++++++++++++++++++++++++ .github/workflows/test.yml | 25 +++++++++++++++++++++++++ .gitignore | 1 + Makefile | 8 ++++++++ README.md | 5 +++++ 5 files changed, 64 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml create mode 100644 Makefile diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..bf67944 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +name: "lint" + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + name: Lint codebase + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup node + uses: actions/setup-go@v1 + with: + go-version: "1.13" + - run: go mod download + - run: go vet ./... + - run: make lint-prepare + - run: ./bin/golangci-lint run diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..6df53de --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: "test" + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: [1.13.x] + name: Test with Go version ${{ matrix.go-version }} + steps: + - name: Setup go + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout + uses: actions/checkout@v2 + - run: go test ./... diff --git a/.gitignore b/.gitignore index 66fd13c..57c413f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ # Dependency directories (remove the comment below to include it) # vendor/ +bin/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..650ce07 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +# Install tools for development +.PHONY: init +init: lint-prepare + +.PHONY: lint-prepare +lint-prepare: + @echo "Preparing Linter" + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s latest diff --git a/README.md b/README.md index baf897f..9186856 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,7 @@ # is-thirteen + +[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c)](https://pkg.go.dev/github.com/stanleynguyen/is-thirteen) +![](https://github.com/stanleynguyen/is-thirteen/workflows/test/badge.svg) +![](https://github.com/stanleynguyen/is-thirteen/workflows/lint/badge.svg) + Check if a number is equal to 13.