From ed89bd29601d2f55e9e6a35a96d19099ac6cb75c Mon Sep 17 00:00:00 2001 From: Onur Cinar Date: Sun, 18 Aug 2024 10:51:18 -0700 Subject: [PATCH] Moving to Task based build system. (#122) # Describe Request Moving to Task based build system. # Change Type Code maintenance. --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++++++++++ .github/workflows/go.yml | 48 ---------------------------------------- go.mod | 2 +- taskfile.yml | 28 +++++++++++++++++++++++ 4 files changed, 65 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/go.yml create mode 100644 taskfile.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f979936 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,36 @@ +name: Build + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: ./go.mod + + - name: Setup cache + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Run task + run: go run github.com/go-task/task/v3/cmd/task@v3.38.0 + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.5.0 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index 27f7582..0000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,48 +0,0 @@ -# This workflow will build a golang project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go - -name: Build - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.20.5 - - - name: Go vet - run: go vet ./... - - - name: Run Gosec - uses: securego/gosec@master - with: - args: ./... - - - name: Run Revive - uses: docker://morphy/revive-action:v2 - - - name: Go fix - run: go fix ./... - - - name: Go build - run: go build -v ./... - - - name: Go test - run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./... - - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - diff --git a/go.mod b/go.mod index 0516d26..37bb71b 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/cinar/checker -go 1.20 +go 1.22 diff --git a/taskfile.yml b/taskfile.yml new file mode 100644 index 0000000..eb18359 --- /dev/null +++ b/taskfile.yml @@ -0,0 +1,28 @@ +version: '3' +output: 'prefixed' + +tasks: + default: + cmds: + - task: fmt + - task: lint + - task: test + + action: + deps: [lint, test] + + fmt: + cmds: + - go fix ./... + + lint: + cmds: + - go vet ./... + - go run github.com/securego/gosec/v2/cmd/gosec@v2.20.0 ./... + - go run honnef.co/go/tools/cmd/staticcheck@v0.5.1 ./... + - go run github.com/mgechev/revive@v1.3.4 -config=revive.toml ./... + + test: + cmds: + - go test -cover -coverprofile=coverage.out ./... +