Skip to content

Commit

Permalink
Updated Taskfile
Browse files Browse the repository at this point in the history
  • Loading branch information
mymmrac committed Jan 11, 2023
1 parent cf76304 commit 9931dbe
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 62 deletions.
58 changes: 29 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,8 @@ jobs:
name: code-coverage-report
path: bin

sonar-cloud:
name: SonarCloud Scan
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
needs: [ test ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download code coverage results
uses: actions/download-artifact@v3
with:
name: code-coverage-report
path: bin

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

build-examples:
name: Build Examples
race:
name: Race Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -106,11 +85,11 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Build examples
run: task build-examples
- name: Run race tests
run: task test:race

race:
name: Race Tests
build-examples:
name: Build Examples
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -129,8 +108,29 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Run race tests
run: task race
- name: Build examples
run: task build:examples

sonar-cloud:
name: SonarCloud Scan
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
needs: [ test ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download code coverage results
uses: actions/download-artifact@v3
with:
name: code-coverage-report
path: bin

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

analyze:
name: CodeQL Analyze
Expand Down
69 changes: 36 additions & 33 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@ tasks:
default:
desc: "Show available tasks"
cmds:
- task --list
- task --list-all

pre-commit:
desc: "Run tests, linter and build examples"
cmds:
- go mod tidy
- task: lint
- task: test
- task: build:examples

lint:
desc: "Run golangci-lint"
deps: [lint-install]
deps: [ install:lint ]
cmds:
- golangci-lint run

lint-install:
desc: "Install golangci-lint"
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
status:
- command -v golangci-lint

lint-list:
lint:list:
desc: "Run golangci-lint linters (print enabled & disabled linters)"
deps: [lint-install]
deps: [ install:lint ]
cmds:
- golangci-lint linters

Expand All @@ -33,67 +34,69 @@ tasks:
- mkdir -p bin
- |
go test -coverprofile bin/cover.out \
$(go list ./... | grep -v /examples/ | grep -v /test | grep -v /internal/ | grep -v /mock)
$(go list ./... | grep -v /examples/ | grep -v /internal/ | grep -v /mock)
sources:
- ./**/*.go
- go.mod
- go.sum
generates:
- bin/cover.out

cover:
test:cover:
desc: "Run tests & show coverage"
deps:
- test
cmds:
- go tool cover -func bin/cover.out

race:
test:race:
desc: "Run tests with race flag"
cmds:
- go test -race -count=1 ./...

bench:
test:bench:
desc: "Run benchmarks"
cmds:
- go test -bench=. -benchtime=10s -benchmem

build-examples:
desc: "Build examples into bin folder"
build:examples:
desc: "Build examples"
cmds:
- go build -o bin/ ./examples/*

pre-commit:
desc: "Run tests, linter and build examples"
cmds:
- task: test
- task: lint
- task: build-examples

generate:
desc: "Generate (used for mock generation)"
deps: [ install:mock ]
cmds:
- go generate ./...

mock-install:
desc: "Install mockgen"
cmds:
- go install github.com/golang/mock/mockgen@latest
status:
- command -v mockgen

generator:
desc: "Run specific generation"
cmds:
- go run ./internal/generator {{.CLI_ARGS}}

generator-all:
generator:all:
desc: "Run all generators"
cmds:
- task: generator
vars:
CLI_ARGS: types types-tests types-setters types-setters-tests methods methods-tests methods-setters methods-setters-tests

generator-clean-up:
generator:clean-up:
desc: "Remove generated files"
cmds:
- rm *.generated

install:lint:
desc: "Install golangci-lint"
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
status:
- command -v golangci-lint

install:mock:
desc: "Install mockgen"
cmds:
- go install github.com/golang/mock/mockgen@latest
status:
- command -v mockgen

0 comments on commit 9931dbe

Please sign in to comment.