Skip to content

Commit

Permalink
chore: add codacy test coverage reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxSuRen committed Feb 15, 2023
1 parent 2b6b9c5 commit 63dc760
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
make pre-commit
23 changes: 23 additions & 0 deletions .github/workflows/coverage-report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Coverage Report

on:
- push
- pull_request

jobs:
TestAndReport:
runs-on: ubuntu-20.04
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x
- uses: actions/checkout@v3.0.0
- name: Test
run: |
go test ./... -coverprofile coverage.out
- name: Report
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: |
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r coverage.out --force-coverage-parser go
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
release/
bin/
.idea/
coverage.out
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ build:
CGO_ENABLE=0 go build -ldflags "-w -s" -o bin/mde
copy: build
cp bin/mde /usr/local/bin

test:
go test ./...
cp-pre-commit:
cp .github/pre-commit .git/hooks/
pre-commit: test
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/5022a74d146f487581821fd1c3435437)](https://www.codacy.com/gh/LinuxSuRen/md-exec/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=LinuxSuRen/md-exec&amp;utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/5022a74d146f487581821fd1c3435437)](https://www.codacy.com/gh/LinuxSuRen/md-exec/dashboard?utm_source=github.com&utm_medium=referral&utm_content=LinuxSuRen/md-exec&utm_campaign=Badge_Coverage)

## Usage
`md-exec` could exec the commands in the Markdown files.
For instance, it will execute those commands which in Markdown block via `mde README.md`
Expand Down
2 changes: 2 additions & 0 deletions cli/root.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package cli provides all the commands
package cli

import (
Expand All @@ -17,6 +18,7 @@ import (
// should be inject during the build process
var version string

// NewRootCommand returns the instance of cobra.Command
func NewRootCommand() (cmd *cobra.Command) {
opt := &option{}
cmd = &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package main is the entrypoint of this CLI project
package main

import (
Expand Down

0 comments on commit 63dc760

Please sign in to comment.