Skip to content

Commit

Permalink
Merge pull request #709 from polamjag/github-actions-env
Browse files Browse the repository at this point in the history
Check for GITHUB_ACTIONS instead of GITHUB_ACTION
  • Loading branch information
haya14busa committed Aug 4, 2020
2 parents 31a1260 + 4c002f4 commit d8cbe31
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cienv/cienv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func setupEnvs() (cleanup func()) {
"TRAVIS_PULL_REQUEST_BRANCH",
"TRAVIS_PULL_REQUEST_SHA",
"TRAVIS_REPO_SLUG",
"GITHUB_ACTION",
"GITHUB_ACTIONS",
"GERRIT_CHANGE_ID",
"GERRIT_REVISION_ID",
"GERRIT_BRANCH",
Expand Down
4 changes: 2 additions & 2 deletions cienv/github_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ func getBuildInfoFromGitHubActionEventPath(eventPath string) (*BuildInfo, bool,

// IsInGitHubAction returns true if reviewdog is running in GitHub Actions.
func IsInGitHubAction() bool {
// https://help.github.com/en/articles/virtual-environments-for-github-actions#default-environment-variables
return os.Getenv("GITHUB_ACTION") != ""
// https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
return os.Getenv("GITHUB_ACTIONS") != ""
}

// IsGitHubPRFromForkedRepo returns true if reviewdog is running in GitHub
Expand Down
14 changes: 7 additions & 7 deletions cmd/reviewdog/doghouse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func setupEnvs(testEnvs map[string]string) (cleanup func()) {
func TestNewDoghouseCli_returnGitHubClient(t *testing.T) {
cleanup := setupEnvs(map[string]string{
"REVIEWDOG_TOKEN": "",
"GITHUB_ACTION": "xxx",
"GITHUB_ACTIONS": "xxx",
"REVIEWDOG_GITHUB_API_TOKEN": "xxx",
})
defer cleanup()
Expand All @@ -59,7 +59,7 @@ func TestNewDoghouseCli_returnGitHubClient(t *testing.T) {
func TestNewDoghouseCli_returnErrorForGitHubClient(t *testing.T) {
cleanup := setupEnvs(map[string]string{
"REVIEWDOG_TOKEN": "",
"GITHUB_ACTION": "xxx",
"GITHUB_ACTIONS": "true",
"REVIEWDOG_GITHUB_API_TOKEN": "", // missing
})
defer cleanup()
Expand All @@ -71,7 +71,7 @@ func TestNewDoghouseCli_returnErrorForGitHubClient(t *testing.T) {
func TestNewDoghouseCli_returnDogHouseClientWithReviewdogToken(t *testing.T) {
cleanup := setupEnvs(map[string]string{
"REVIEWDOG_TOKEN": "xxx",
"GITHUB_ACTION": "xxx",
"GITHUB_ACTIONS": "true",
"REVIEWDOG_GITHUB_API_TOKEN": "xxx",
})
defer cleanup()
Expand All @@ -87,7 +87,7 @@ func TestNewDoghouseCli_returnDogHouseClientWithReviewdogToken(t *testing.T) {
func TestNewDoghouseCli_returnDogHouseClient(t *testing.T) {
cleanup := setupEnvs(map[string]string{
"REVIEWDOG_TOKEN": "",
"GITHUB_ACTION": "",
"GITHUB_ACTIONS": "",
"REVIEWDOG_GITHUB_API_TOKEN": "",
})
defer cleanup()
Expand Down Expand Up @@ -422,7 +422,7 @@ func TestPostResultSet_withEmptyResponse(t *testing.T) {

func TestReportResults(t *testing.T) {
cleanup := setupEnvs(map[string]string{
"GITHUB_ACTION": "",
"GITHUB_ACTIONS": "",
"GITHUB_EVENT_PATH": "",
})
defer cleanup()
Expand Down Expand Up @@ -471,7 +471,7 @@ reviewdog: No results found for "name2". 1 results found outside diff.

func TestReportResults_inGitHubAction(t *testing.T) {
cleanup := setupEnvs(map[string]string{
"GITHUB_ACTION": "xxx",
"GITHUB_ACTIONS": "true",
"GITHUB_EVENT_PATH": "",
})
defer cleanup()
Expand All @@ -497,7 +497,7 @@ func TestReportResults_inGitHubAction(t *testing.T) {

func TestReportResults_noResultsShouldReport(t *testing.T) {
cleanup := setupEnvs(map[string]string{
"GITHUB_ACTION": "",
"GITHUB_ACTIONS": "",
"GITHUB_EVENT_PATH": "",
})
defer cleanup()
Expand Down
2 changes: 1 addition & 1 deletion service/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func setupGitHubClient() *github.Client {

func setupEnvs() (cleanup func()) {
var cleanEnvs = []string{
"GITHUB_ACTION",
"GITHUB_ACTIONS",
}
saveEnvs := make(map[string]string)
for _, key := range cleanEnvs {
Expand Down

0 comments on commit d8cbe31

Please sign in to comment.