cienv

package
v0.0.0-...-bc1001e Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cienv provides utility for environment variable in CI services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasReadOnlyPermissionGitHubToken

func HasReadOnlyPermissionGitHubToken() bool

HasReadOnlyPermissionGitHubToken returns true if reviewdog is running in GitHub Actions and running for PullRequests from forked repository with read-only token. https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target

func IsInBitbucketPipe

func IsInBitbucketPipe() bool

IsInBitbucketPipe returns true if reviewdog is running in a Bitbucket Pipe.

func IsInBitbucketPipeline

func IsInBitbucketPipeline() bool

IsInBitbucketPipeline returns true if reviewdog is running in Bitbucket Pipelines.

func IsInGitHubAction

func IsInGitHubAction() bool

IsInGitHubAction returns true if reviewdog is running in GitHub Actions.

Types

type BuildInfo

type BuildInfo struct {
	Owner string
	Repo  string
	SHA   string

	// Optional.
	PullRequest int // MergeRequest for GitLab.

	// Optional.
	Branch string

	// Gerrit related params
	GerritChangeID   string
	GerritRevisionID string
}

BuildInfo represents build information about GitHub or GitLab project.

func GetBuildInfo

func GetBuildInfo() (prInfo *BuildInfo, isPR bool, err error)

GetBuildInfo returns BuildInfo from environment variables.

Supported CI services' documents: - Travis CI: https://docs.travis-ci.com/user/environment-variables/ - Circle CI: https://circleci.com/docs/environment-variables/ - Drone.io: http://docs.drone.io/environment-reference/ - GitLab CI: https://docs.gitlab.com/ee/ci/variables/#predefined-variables-environment-variables - GitLab CI doesn't export ID of Merge Request. https://gitlab.com/gitlab-org/gitlab-ce/issues/15280

func GetGerritBuildInfo

func GetGerritBuildInfo() (*BuildInfo, error)

GetGerritBuildInfo returns Gerrit specific build info

type GitHubEvent

type GitHubEvent struct {
	PullRequest GitHubPullRequest `json:"pull_request"`
	Repository  struct {
		Owner struct {
			Login string `json:"login"`
		} `json:"owner"`
		Name string `json:"name"`
	} `json:"repository"`
	CheckSuite struct {
		After        string              `json:"after"`
		PullRequests []GitHubPullRequest `json:"pull_requests"`
	} `json:"check_suite"`
	HeadCommit struct {
		ID string `json:"id"`
	} `json:"head_commit"`
	ActionName string `json:"-"` // this is defined as env GITHUB_EVENT_NAME
}

https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables

func LoadGitHubEvent

func LoadGitHubEvent() (*GitHubEvent, error)

LoadGitHubEvent loads GitHubEvent if it's running in GitHub Actions.

type GitHubPullRequest

type GitHubPullRequest struct {
	Number int `json:"number"`
	Head   struct {
		Sha  string     `json:"sha"`
		Ref  string     `json:"ref"`
		Repo GitHubRepo `json:"repo"`
	} `json:"head"`
	Base struct {
		Repo GitHubRepo `json:"repo"`
	} `json:"base"`
}

type GitHubRepo

type GitHubRepo struct {
	Owner struct {
		ID int64 `json:"id"`
	}
}

Jump to

Keyboard shortcuts

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