From 10c91431632118a40dc814a6ba2eb9babe946b36 Mon Sep 17 00:00:00 2001 From: Branislav Lazic Date: Wed, 25 Sep 2024 22:25:34 +0200 Subject: [PATCH] Add gocover and dependabot --- .github/dependabot.yml | 6 ++++ .github/workflows/gocover.yml | 54 +++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/gocover.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..20e1ef1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "daily" \ No newline at end of file diff --git a/.github/workflows/gocover.yml b/.github/workflows/gocover.yml new file mode 100644 index 0000000..cd96ccf --- /dev/null +++ b/.github/workflows/gocover.yml @@ -0,0 +1,54 @@ +name: Go coverage badge + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, windows-latest ] + go: [ 1.23 ] + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go }} + + - name: Build + run: go install + + - name: Test + run: | + go test -v -cover ./... -coverprofile coverage.out -coverpkg ./... + go tool cover -func coverage.out -o coverage.out # Replaces coverage.out with the analysis of coverage.out + + - name: Go Coverage Badge + uses: tj-actions/coverage-badge-go@v2 + if: ${{ runner.os == 'Linux' && matrix.go == '1.23' }} + with: + green: 80 + filename: coverage.out + link: https://github.com/codeengio/idi/actions/workflows/gocover.yaml + + - uses: stefanzweifel/git-auto-commit-action@v5 + id: auto-commit-action + with: + commit_message: Apply Code Coverage Badge + skip_fetch: true + skip_checkout: true + file_pattern: ./README.md + + - name: Push Changes + if: steps.auto-commit-action.outputs.changes_detected == 'true' + uses: ad-m/github-push-action@master + with: + github_token: ${{ github.token }} + branch: ${{ github.ref }} \ No newline at end of file