ci: replace superlinter with megalinter (#923)
* ci: replace superlinter with megalinter Signed-off-by: hackercat <me@hackerc.at> * fix: apply lint recommendations Signed-off-by: hackercat <me@hackerc.at>
This commit is contained in:
parent
adabf2a202
commit
9be6a58c0e
15 changed files with 58 additions and 56 deletions
|
@ -8,14 +8,10 @@ trim_trailing_whitespace = true
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
|
|
||||||
[*.sh]
|
[{Dockerfile,*.md,*_test.go,install.sh,act-cli.nuspec}]
|
||||||
indent_style = space
|
|
||||||
indent_size = 2
|
|
||||||
|
|
||||||
[{Dockerfile,*.md,*_test.go}]
|
|
||||||
indent_style = unset
|
indent_style = unset
|
||||||
indent_size = unset
|
indent_size = unset
|
||||||
|
|
||||||
[*.{yml,yaml,json}]
|
[*.{yml,yaml,js{,on}}]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
12
.github/dependabot.yml
vendored
12
.github/dependabot.yml
vendored
|
@ -5,11 +5,11 @@
|
||||||
|
|
||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
- package-ecosystem: "github-actions"
|
- package-ecosystem: 'github-actions'
|
||||||
directory: "/"
|
directory: '/'
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: 'weekly'
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: 'gomod'
|
||||||
directory: "/"
|
directory: '/'
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: 'weekly'
|
||||||
|
|
1
.github/linters/.golangci.yml
vendored
1
.github/linters/.golangci.yml
vendored
|
@ -1 +0,0 @@
|
||||||
../../.golangci.yml
|
|
1
.github/linters/.markdown-lint.yml
vendored
1
.github/linters/.markdown-lint.yml
vendored
|
@ -1 +0,0 @@
|
||||||
../../.markdownlint.yml
|
|
16
.github/workflows/checks.yml
vendored
16
.github/workflows/checks.yml
vendored
|
@ -5,6 +5,7 @@ env:
|
||||||
ACT_OWNER: ${{ github.repository_owner }}
|
ACT_OWNER: ${{ github.repository_owner }}
|
||||||
ACT_REPOSITORY: ${{ github.repository }}
|
ACT_REPOSITORY: ${{ github.repository }}
|
||||||
GO_VERSION: 1.17
|
GO_VERSION: 1.17
|
||||||
|
CGO_ENABLED: 0
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
|
@ -18,22 +19,15 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- uses: golangci/golangci-lint-action@v2
|
- uses: golangci/golangci-lint-action@v2
|
||||||
env:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
- uses: github/super-linter@v3
|
- uses: megalinter/megalinter/flavors/go@v5
|
||||||
env:
|
env:
|
||||||
DEFAULT_BRANCH: master
|
DEFAULT_BRANCH: master
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
FILTER_REGEX_EXCLUDE: .*testdata/*
|
|
||||||
VALIDATE_ALL_CODEBASE: false
|
VALIDATE_ALL_CODEBASE: false
|
||||||
VALIDATE_BASH: false
|
GITHUB_STATUS_REPORTER: ${{ !env.ACT }}
|
||||||
VALIDATE_DOCKERFILE: false
|
GITHUB_COMMENT_REPORTER: ${{ !env.ACT }}
|
||||||
VALIDATE_DOCKERFILE_HADOLINT: false
|
|
||||||
VALIDATE_GO: false # it's broken, see commit message
|
|
||||||
VALIDATE_JSCPD: false
|
|
||||||
VALIDATE_SHELL_SHFMT: false
|
|
||||||
|
|
||||||
test-linux:
|
test-linux:
|
||||||
name: test-linux
|
name: test-linux
|
||||||
|
@ -55,8 +49,6 @@ jobs:
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-go-
|
${{ runner.os }}-go-
|
||||||
- run: go test -v -cover -coverprofile=coverage.txt -covermode=atomic ./...
|
- run: go test -v -cover -coverprofile=coverage.txt -covermode=atomic ./...
|
||||||
env:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
- name: Upload Codecov report
|
- name: Upload Codecov report
|
||||||
uses: codecov/codecov-action@v2.1.0
|
uses: codecov/codecov-action@v2.1.0
|
||||||
with:
|
with:
|
||||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -29,5 +29,5 @@ coverage.txt
|
||||||
.env
|
.env
|
||||||
.secrets
|
.secrets
|
||||||
|
|
||||||
# ignore docker registry from .github/workflows/checks.yml
|
# megalinter
|
||||||
docker-registry/
|
report/
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
run:
|
run:
|
||||||
timeout: 3m
|
timeout: 3m
|
||||||
|
|
||||||
|
skip-dirs:
|
||||||
|
- report # megalinter results+fixes
|
||||||
|
|
||||||
linters-settings:
|
linters-settings:
|
||||||
gocyclo:
|
gocyclo:
|
||||||
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
||||||
|
@ -43,3 +46,6 @@ linters:
|
||||||
- misspell
|
- misspell
|
||||||
- depguard
|
- depguard
|
||||||
- importas
|
- importas
|
||||||
|
- contextcheck
|
||||||
|
- nolintlint
|
||||||
|
- revive
|
||||||
|
|
|
@ -10,15 +10,15 @@ builds:
|
||||||
- windows
|
- windows
|
||||||
goarch:
|
goarch:
|
||||||
- amd64
|
- amd64
|
||||||
- 386
|
- '386'
|
||||||
- arm64
|
- arm64
|
||||||
- arm
|
- arm
|
||||||
goarm:
|
goarm:
|
||||||
- 6
|
- '6'
|
||||||
- 7
|
- '7'
|
||||||
ignore:
|
ignore:
|
||||||
- goos: windows
|
- goos: windows
|
||||||
goarm: 6
|
goarm: '6'
|
||||||
checksum:
|
checksum:
|
||||||
name_template: 'checksums.txt'
|
name_template: 'checksums.txt'
|
||||||
archives:
|
archives:
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
default: true
|
default: true
|
||||||
|
|
||||||
# MD013/line-length - Line length
|
# MD013/line-length - Line length
|
||||||
MD013: false
|
MD013:
|
||||||
|
line_length: 1024
|
||||||
|
|
||||||
# MD033/no-inline-html - Inline HTML
|
# MD033/no-inline-html - Inline HTML
|
||||||
MD033: false
|
MD033: false
|
||||||
|
|
17
.mega-linter.yml
Normal file
17
.mega-linter.yml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
APPLY_FIXES: none
|
||||||
|
DISABLE:
|
||||||
|
- ACTION
|
||||||
|
- BASH
|
||||||
|
- COPYPASTE
|
||||||
|
- DOCKERFILE
|
||||||
|
- GO
|
||||||
|
- JAVASCRIPT
|
||||||
|
- SPELL
|
||||||
|
DISABLE_LINTERS:
|
||||||
|
- YAML_YAMLLINT
|
||||||
|
- MARKDOWN_MARKDOWN_TABLE_FORMATTER
|
||||||
|
FILTER_REGEX_EXCLUDE: .*testdata/*
|
||||||
|
MARKDOWN_MARKDOWNLINT_CONFIG_FILE: .markdownlint.yml
|
||||||
|
PARALLEL: false
|
||||||
|
PRINT_ALPACA: false
|
12
Makefile
12
Makefile
|
@ -54,16 +54,10 @@ lint-md:
|
||||||
.PHONY: lint-rest
|
.PHONY: lint-rest
|
||||||
lint-rest:
|
lint-rest:
|
||||||
docker run --rm -it \
|
docker run --rm -it \
|
||||||
-e 'RUN_LOCAL=true' \
|
|
||||||
-e 'FILTER_REGEX_EXCLUDE=.*testdata/*' \
|
|
||||||
-e 'VALIDATE_BASH=false' \
|
|
||||||
-e 'VALIDATE_DOCKERFILE=false' \
|
|
||||||
-e 'VALIDATE_DOCKERFILE_HADOLINT=false' \
|
|
||||||
-e 'VALIDATE_GO=false' \
|
|
||||||
-e 'VALIDATE_JSCPD=false' \
|
|
||||||
-e 'VALIDATE_SHELL_SHFMT=false' \
|
|
||||||
-v $(PWD):/tmp/lint \
|
-v $(PWD):/tmp/lint \
|
||||||
github/super-linter
|
-e GITHUB_STATUS_REPORTER=false \
|
||||||
|
-e GITHUB_COMMENT_REPORTER=false \
|
||||||
|
megalinter/megalinter-go:v5
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint: lint-go lint-rest
|
lint: lint-go lint-rest
|
||||||
|
|
|
@ -88,8 +88,7 @@ func NewContainer(input *NewContainerInput) Container {
|
||||||
|
|
||||||
// supportsContainerImagePlatform returns true if the underlying Docker server
|
// supportsContainerImagePlatform returns true if the underlying Docker server
|
||||||
// API version is 1.41 and beyond
|
// API version is 1.41 and beyond
|
||||||
func supportsContainerImagePlatform(cli *client.Client) bool {
|
func supportsContainerImagePlatform(ctx context.Context, cli *client.Client) bool {
|
||||||
ctx := context.TODO()
|
|
||||||
logger := common.Logger(ctx)
|
logger := common.Logger(ctx)
|
||||||
ver, err := cli.ServerVersion(ctx)
|
ver, err := cli.ServerVersion(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -290,7 +289,7 @@ func (cr *containerReference) remove() common.Executor {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger := common.Logger(ctx)
|
logger := common.Logger(ctx)
|
||||||
err := cr.cli.ContainerRemove(context.Background(), cr.id, types.ContainerRemoveOptions{
|
err := cr.cli.ContainerRemove(ctx, cr.id, types.ContainerRemoveOptions{
|
||||||
RemoveVolumes: true,
|
RemoveVolumes: true,
|
||||||
Force: true,
|
Force: true,
|
||||||
})
|
})
|
||||||
|
@ -333,7 +332,7 @@ func (cr *containerReference) create(capAdd []string, capDrop []string) common.E
|
||||||
}
|
}
|
||||||
|
|
||||||
var platSpecs *specs.Platform
|
var platSpecs *specs.Platform
|
||||||
if supportsContainerImagePlatform(cr.cli) && cr.input.Platform != "" {
|
if supportsContainerImagePlatform(ctx, cr.cli) && cr.input.Platform != "" {
|
||||||
desiredPlatform := strings.SplitN(cr.input.Platform, `/`, 2)
|
desiredPlatform := strings.SplitN(cr.input.Platform, `/`, 2)
|
||||||
|
|
||||||
if len(desiredPlatform) != 2 {
|
if len(desiredPlatform) != 2 {
|
||||||
|
|
|
@ -158,24 +158,24 @@ func (*expressionEvaluator) advString(w *strings.Builder, r *strings.Reader) err
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if c != '\'' {
|
if c != '\'' {
|
||||||
w.WriteRune(c) //nolint
|
w.WriteRune(c)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handles a escaped string: ex. 'It''s ok'
|
// Handles a escaped string: ex. 'It''s ok'
|
||||||
c, _, err = r.ReadRune()
|
c, _, err = r.ReadRune()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteString("'") //nolint
|
w.WriteString("'")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if c != '\'' {
|
if c != '\'' {
|
||||||
w.WriteString("'") //nolint
|
w.WriteString("'")
|
||||||
if err := r.UnreadRune(); err != nil {
|
if err := r.UnreadRune(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
w.WriteString(`\'`) //nolint
|
w.WriteString(`\'`)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ func (*expressionEvaluator) advPropertyName(w *strings.Builder, r *strings.Reade
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
w.WriteRune(c) //nolint
|
w.WriteRune(c)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,7 +342,7 @@ func (rc *RunContext) newStepExecutor(step *model.Step) common.Executor {
|
||||||
rc.ExprEval = exprEval
|
rc.ExprEval = exprEval
|
||||||
|
|
||||||
common.Logger(ctx).Infof("\u2B50 Run %s", sc.Step)
|
common.Logger(ctx).Infof("\u2B50 Run %s", sc.Step)
|
||||||
err = sc.Executor()(ctx)
|
err = sc.Executor(ctx)(ctx)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
common.Logger(ctx).Infof(" \u2705 Success - %s", sc.Step)
|
common.Logger(ctx).Infof(" \u2705 Success - %s", sc.Step)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (e formatError) Error() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Executor for a step context
|
// Executor for a step context
|
||||||
func (sc *StepContext) Executor() common.Executor {
|
func (sc *StepContext) Executor(ctx context.Context) common.Executor {
|
||||||
rc := sc.RunContext
|
rc := sc.RunContext
|
||||||
step := sc.Step
|
step := sc.Step
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ func (sc *StepContext) Executor() common.Executor {
|
||||||
Token: github.Token,
|
Token: github.Token,
|
||||||
})
|
})
|
||||||
var ntErr common.Executor
|
var ntErr common.Executor
|
||||||
if err := gitClone(context.TODO()); err != nil {
|
if err := gitClone(ctx); err != nil {
|
||||||
if err.Error() == "short SHA references are not supported" {
|
if err.Error() == "short SHA references are not supported" {
|
||||||
err = errors.Cause(err)
|
err = errors.Cause(err)
|
||||||
return common.NewErrorExecutor(fmt.Errorf("Unable to resolve action `%s`, the provided ref `%s` is the shortened version of a commit SHA, which is not supported. Please use the full commit SHA `%s` instead", step.Uses, remoteAction.Ref, err.Error()))
|
return common.NewErrorExecutor(fmt.Errorf("Unable to resolve action `%s`, the provided ref `%s` is the shortened version of a commit SHA, which is not supported. Please use the full commit SHA `%s` instead", step.Uses, remoteAction.Ref, err.Error()))
|
||||||
|
@ -482,7 +482,6 @@ func (sc *StepContext) getContainerActionPaths(step *model.Step, actionDir strin
|
||||||
return actionName, containerActionDir
|
return actionName, containerActionDir
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint: gocyclo
|
|
||||||
func (sc *StepContext) runAction(actionDir string, actionPath string, localAction bool) common.Executor {
|
func (sc *StepContext) runAction(actionDir string, actionPath string, localAction bool) common.Executor {
|
||||||
rc := sc.RunContext
|
rc := sc.RunContext
|
||||||
step := sc.Step
|
step := sc.Step
|
||||||
|
@ -704,7 +703,7 @@ func (sc *StepContext) execAsComposite(ctx context.Context, step *model.Step, _
|
||||||
|
|
||||||
stepContext.Step = &stepClone
|
stepContext.Step = &stepClone
|
||||||
|
|
||||||
executors = append(executors, stepContext.Executor())
|
executors = append(executors, stepContext.Executor(ctx))
|
||||||
}
|
}
|
||||||
return common.NewPipelineExecutor(executors...)(ctx)
|
return common.NewPipelineExecutor(executors...)(ctx)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue