This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Auto-install golangci-lint * Use knative/client-pkg#164
- Loading branch information
Showing
32 changed files
with
857 additions
and
3,196 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 |
---|---|---|
|
@@ -6,24 +6,30 @@ on: | |
branches: | ||
- master | ||
pull_request: | ||
|
||
env: | ||
FORCE_COLOR: true | ||
|
||
jobs: | ||
golangci: | ||
name: Golangci | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v2 | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21' | ||
cache: false | ||
- uses: golangci/golangci-lint-action@v4 | ||
with: | ||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. | ||
version: v1.46.2 | ||
version: v1.55.2 | ||
editorconfig: | ||
name: EditorConfig | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: ECLint | ||
uses: snow-actions/[email protected] | ||
- uses: actions/checkout@v4 | ||
- uses: snow-actions/[email protected] | ||
with: | ||
args: check | ||
|
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
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
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 |
---|---|---|
|
@@ -31,6 +31,7 @@ linters: | |
- ireturn | ||
- varnamelen | ||
- exhaustruct | ||
- depguard | ||
|
||
issues: | ||
exclude-rules: | ||
|
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,3 +1,3 @@ | ||
= A general purpuse, reusable Mage tasks | ||
= A general purpose, reusable Mage tasks | ||
|
||
This repo holds a list of reusable Mage tasks to be used in other projects. |
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
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,20 +1,22 @@ | ||
package magetasks | ||
|
||
import ( | ||
"github.com/magefile/mage/mg" | ||
"context" | ||
|
||
"github.com/wavesoftware/go-magetasks/config" | ||
"github.com/wavesoftware/go-magetasks/pkg/deps" | ||
"github.com/wavesoftware/go-magetasks/pkg/targets" | ||
"github.com/wavesoftware/go-magetasks/pkg/tasks" | ||
) | ||
|
||
// Check will run all lints checks. | ||
func Check() { | ||
mg.Deps(deps.Install) | ||
func Check(ctx context.Context) { | ||
targets.Deps(ctx, deps.Install) | ||
t := tasks.Start("🔍", "Checking", len(config.Actual().Checks) > 0) | ||
for _, check := range config.Actual().Checks { | ||
p := t.Part(check.Name) | ||
pp := p.Starting() | ||
pp.Done(check.Operation(pp)) | ||
} | ||
t.End(nil) | ||
t.End() | ||
} |
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package config | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/cardil/ghet/pkg/ghet/download" | ||
"github.com/cardil/ghet/pkg/ghet/install" | ||
"github.com/wavesoftware/go-magetasks/pkg/tasks" | ||
) | ||
|
||
type Binaries interface { | ||
Configurator | ||
Install(ctx context.Context, t *tasks.Task, destination string) error | ||
Count() int | ||
|
||
merge(b *binaries) | ||
} | ||
|
||
func NewBinaries(bins ...string) Binaries { | ||
return &binaries{ | ||
bins: bins, | ||
} | ||
} | ||
|
||
type binaries struct { | ||
bins []string | ||
} | ||
|
||
func (b *binaries) Count() int { | ||
return len(b.bins) | ||
} | ||
|
||
func (b *binaries) Install(ctx context.Context, t *tasks.Task, destination string) error { | ||
for _, binSpec := range b.bins { | ||
p := t.Part(fmt.Sprintf("Pre-built binary %q", binSpec)) | ||
pp := p.Starting() | ||
args := download.Args{ | ||
Args: install.Parse(binSpec), | ||
Destination: destination, | ||
} | ||
bin := args.Asset.FileName.ToString() | ||
path := fmt.Sprintf("%s/%s", destination, bin) | ||
if fileExist(path) { | ||
log.Println("Skipping installation of", binSpec, | ||
"because it already exists:", path) | ||
p.Skip("already installed") | ||
continue | ||
} | ||
if err := download.Action(ctx, args); err != nil { | ||
pp.Done(err) | ||
return err | ||
} | ||
pp.Notify("installed") | ||
} | ||
return nil | ||
} | ||
|
||
func (b *binaries) Configure(cfg Configurable) { | ||
cfg.Config().Dependencies.Binaries.merge(b) | ||
} | ||
|
||
func (b *binaries) merge(b2 *binaries) { | ||
b.bins = append(b.bins, b2.bins...) | ||
} | ||
|
||
func fileExist(path string) bool { | ||
_, err := os.Stat(path) | ||
return err == nil | ||
} |
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
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
Oops, something went wrong.