-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from elisasre/update-readme
Update readme
- Loading branch information
Showing
1 changed file
with
61 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |