reviewdog

package module
v0.17.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

README

Woodpecker CI Reviewdog plugin library

Library to build Woodpecker CI plugins that integrate Reviewdog with specific tools.

Builtin settings

Settings Name Environment variable Default Description
token - none Forge API token
tool-name - none Custom tool name to report
debug - false Enable debug mode
log_level - info Sets log level (panic, fatal, error, warn, info, debug, trace)
skip_verify - false Skip verification of TLS certificate
SOCKS_PROXY none SOCKS5 proxy to use for connections
SOCKS_PROXY_OFF none Do not use SOCKS5 proxy

Creating a plugin

package main

import (
	"context"
	"io"

	plugin "codeberg.org/woodpecker-plugins/go-plugin-reviewdog"
	"github.com/reviewdog/reviewdog/parser"
	"github.com/urfave/cli/v2"
)

type Plugin struct {
	*plugin.Plugin
}

func (p *Plugin) Name() string {
	return "golint"
}

func (p *Plugin) Flags() []cli.Flag {
	return nil
}

func (p *Plugin) Parser() (parser.Parser, error) {
	return p.CustomFormat("%f:%l:%c: %m")
}

func (p *Plugin) Exec(ctx context.Context) (io.Reader, func(), error) {
	return p.ExecCommand(ctx, "golint", "./...")
}

func main() {
	p := &Plugin{}
	p.Plugin = plugin.New("plugin-reviewdog-golint", version, p)
	p.Run()
}

Contributors

Special thanks goes to all contributors. If you would like to contribute, please see the instructions.

License

This project is licensed under the Apache-2.0 License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Plugin

type Plugin struct {
	*plugin.Plugin
	Settings Settings
	// contains filtered or unexported fields
}

Plugin implements provide the plugin implementation.

func New

func New(name, version string, tool Tool) *Plugin

New initializes a plugin from the given Settings, Pipeline, and Network.

func (*Plugin) CommandOutput added in v0.4.0

func (p *Plugin) CommandOutput(ctx context.Context, name string, args ...string) ([]byte, error)

CommandOutput executes the given command and returns output.

func (*Plugin) CustomFormat

func (p *Plugin) CustomFormat(format ...string) (parser.Parser, error)

CustomFormat returns a parser for the given format(s).

func (*Plugin) ExecCommand

func (p *Plugin) ExecCommand(ctx context.Context, name string, args ...string) (io.Reader, func(), error)

ExecCommand executes the given command and returns output stream.

func (*Plugin) Execute

func (p *Plugin) Execute(ctx context.Context) error

Execute provides the implementation of the plugin.

func (*Plugin) Flags

func (p *Plugin) Flags() []cli.Flag

func (*Plugin) NamedFormat

func (p *Plugin) NamedFormat(name string) (parser.Parser, error)

NamedFormat returns a parser for the given format name.

func (*Plugin) ToolName added in v0.4.0

func (p *Plugin) ToolName() string

ToolName returns the name of the tool to report.

func (*Plugin) Validate

func (p *Plugin) Validate() error

Validate handles the settings validation of the plugin settings.

type Settings

type Settings struct {
	Token    string
	Debug    bool
	ToolName string
}

Settings for the plugin.

type Tool

type Tool interface {
	// Name returns the name of the tool.
	Name() string

	// Flags returns the flags for the tool.
	Flags() []cli.Flag

	// Parser to be used by reviewdog.
	Parser() (parser.Parser, error)

	// Exec executes the tool.
	Exec(ctx context.Context) (io.Reader, func(), error)
}

Tool to be used by the reviewdog.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL