From c5fd20040a76a41a353fe0340a64280775d005bd Mon Sep 17 00:00:00 2001 From: Dean Jackson Date: Thu, 6 Aug 2020 20:15:50 +0200 Subject: [PATCH] Add GitHub Action for tests & coverage --- .githooks/pre-commit | 4 ++ .github/workflows/continuous-integration.yml | 55 ++++++++++++++++++++ .gitignore | 5 +- README.md | 1 + modd.conf | 31 +++++++++++ 5 files changed, 95 insertions(+), 1 deletion(-) create mode 100755 .githooks/pre-commit create mode 100644 .github/workflows/continuous-integration.yml create mode 100644 modd.conf diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..3039f0f --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,4 @@ +#!/bin/zsh -e + +golint -set_exit_status ./... +go mod tidy -v diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..f682a2c --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,55 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.14.x + + - name: Check out code + uses: actions/checkout@v2 + + - name: Install golint + run: go get golang.org/x/lint/golint + + - name: Lint Go source code + run: golint -set_exit_status ./... + + test: + name: Unit tests + strategy: + matrix: + go-version: [1.12.x, 1.13.x, 1.14.x] + platform: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Check out code + uses: actions/checkout@v2 + + - name: Fetch dependencies + run: | + go get -v -t -d ./... + + - name: Run unit tests + run: go test ./... + + # - name: Codecov + # if: ${{ matrix.go-version == '1.14.x' && matrix.platform == 'ubuntu-latest' }} + # uses: codecov/codecov-action@v1 + # with: + # file: coverage.out diff --git a/.gitignore b/.gitignore index 5bd2f33..813db7d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,7 @@ /shiori* # Exclude development data -/dev-data \ No newline at end of file +/dev-data + +# Coverage data +/coverage.out diff --git a/README.md b/README.md index c1ae581..620c3d0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Shiori +[![CI](https://github.com/go-shiori/shiori/workflows/CI/badge.svg)](https://github.com/go-shiori/shiori/actions?query=workflow%3ACI) [![Go Report Card](https://goreportcard.com/badge/github.com/go-shiori/shiori)](https://goreportcard.com/report/github.com/go-shiori/shiori) [![Docker Image](https://img.shields.io/static/v1?label=image&message=Docker&color=1488C6&logo=docker)](https://hub.docker.com/r/radhifadlillah/shiori) [![Deploy Heroku](https://img.shields.io/static/v1?label=deploy&message=Heroku&color=430098&logo=heroku)](https://heroku.com/deploy) diff --git a/modd.conf b/modd.conf new file mode 100644 index 0000000..0305df0 --- /dev/null +++ b/modd.conf @@ -0,0 +1,31 @@ +modd.conf +**/*.go { + prep: " + # run tests + go test -cover @dirmods + " +} + +modd.conf +**/*.go +!**/*_test.go { + prep: " + # build + go build -v -tags dev + " +} + +modd.conf +internal/view/** { + prep: " + # compile static assets + go generate ./... + " +} + +modd.conf +**/*.html +**/*.js +shiori { + daemon: ./shiori serve -p 5061 +}