Skip to content

Commit

Permalink
Merge pull request #46 from elisasre/update-readme
Browse files Browse the repository at this point in the history
Update readme
  • Loading branch information
heppu authored Nov 20, 2023
2 parents ccb5e7e + 59b67ee commit 3c827c2
Showing 1 changed file with 61 additions and 5 deletions.
66 changes: 61 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,68 @@
# mageutil

[![Go Reference](https://pkg.go.dev/badge/github.com/elisasre/mageutil.svg)](https://pkg.go.dev/github.com/elisasre/mageutil) ![build](https://github.com/elisasre/mageutil/actions/workflows/main.yml/badge.svg)

Mageutil provides ready made targets and helper functions for [Magefile](<https://magefile.org/>). For usage please refer to [documentation](<https://magefile.org/importing/>) provided by Magefile. For autocompletions see [completions](<https://github.com/elisasre/mageutil/tree/main/completions>).

### Example

Example magefile:
```go
import "github.com/elisasre/mageutil"
```
//go:build mage

package mageutil provides util functions for [Magefile](<https://magefile.org/>). For usage please refer to [documentation](<https://magefile.org/importing/>) provided by Magefile. For autocompletions see [completions](<https://github.com/elisasre/mageutil/tree/main/completions>).
package main

import (
"os"

"github.com/magefile/mage/mg"

//mage:import
_ "github.com/elisasre/mageutil/git/target"
//mage:import
_ "github.com/elisasre/mageutil/golangcilint/target"
//mage:import
_ "github.com/elisasre/mageutil/govulncheck/target"
//mage:import
_ "github.com/elisasre/mageutil/golicenses/target"
//mage:import
docker "github.com/elisasre/mageutil/docker/target"
//mage:import
golang "github.com/elisasre/mageutil/golang/target"
)

// Configure imported targets
func init() {
os.Setenv(mg.VerboseEnv, "1")
os.Setenv("CGO_ENABLED", "0")

golang.BuildTarget = "./cmd/myapp"
golang.RunArgs = []string{"--loglevel", "0", "--development", "true"}
golang.IntegrationTestRunArgs = []string{"--loglevel", "0", "--development", "true"}
docker.ImageName = "docker.io/myorg/myapp"
docker.ProjectUrl = "https://github.com/myorg/myapp"
}
```
go get github.com/elisasre/mageutil@main
```

Output with example magefile:
```sh
$ mage

Targets:
docker:build builds docker image
docker:push pushes all tags for image
git:clean removes all untracked files from workspace
go:build build binary and calculate sha sum for it
go:coverProfile convert binary coverage into text format
go:crossBuild build binary for build matrix
go:integrationTest run integration tests
go:licenses reports licenses used by dependencies
go:lint runs golangci-lint for all go files.
go:run build binary and execute it
go:test run unit and integration tests
go:tidy run go mod tidy
go:tidyAndVerify verify that go.mod matches imports
go:unitTest run all unit tests
go:viewCoverage open test coverage in browser
go:vulnCheck runs golang.org/x/vuln/scan for all packages
```

0 comments on commit 3c827c2

Please sign in to comment.