Skip to content

Commit

Permalink
Merge branch 'main' into hackathon/github_app
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Jun 13, 2024
2 parents 07418c7 + f69ce12 commit 9b9f1e2
Show file tree
Hide file tree
Showing 62 changed files with 1,140 additions and 789 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: install go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
# use version from go.mod file
go-version-file: 'go.mod'
Expand All @@ -47,7 +47,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
uses: github/codeql-action/init@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -58,7 +58,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
uses: github/codeql-action/autobuild@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -72,4 +72,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
uses: github/codeql-action/analyze@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8
4 changes: 3 additions & 1 deletion .github/workflows/pr-title-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ jobs:

steps:
- name: validate title
env:
TITLE: ${{ github.event.pull_request.title }}
run: |
echo "${{ github.event.pull_request.title }}" | grep -Eq '^(feat|fix|chore|refactor|enhance|test|docs)(\(.*\)|):\s.+$' && (echo "Pass"; exit 0) || (echo "Incorrect Format. Please see https://go-vela.github.io/docs/community/contributing_guidelines/#development-workflow"; exit 1)
echo "$TITLE" | grep -Eq '^(feat|fix|chore|refactor|enhance|test|docs)(\(.*\)|)!?:\s.+$' && (echo "Pass"; exit 0) || (echo "Incorrect Format. Please see https://go-vela.github.io/docs/community/contributing_guidelines/#development-workflow"; exit 1)
12 changes: 6 additions & 6 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ jobs:

steps:
- name: clone
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: install go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
# use version from go.mod file
go-version-file: 'go.mod'
cache: true
check-latest: true

- name: golangci-lint
uses: reviewdog/action-golangci-lint@8e1117c7d327bbfb1eb7ec8dc2d895d13e6e17c3 # v2.6.0
uses: reviewdog/action-golangci-lint@00311c26a97213f93f2fd3a3524d66762e956ae0 # v2.6.1
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--config=.golangci.yml"
Expand All @@ -36,18 +36,18 @@ jobs:

steps:
- name: clone
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: install go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
# use version from go.mod file
go-version-file: 'go.mod'
cache: true
check-latest: true

- name: golangci-lint
uses: reviewdog/action-golangci-lint@8e1117c7d327bbfb1eb7ec8dc2d895d13e6e17c3 # v2.6.0
uses: reviewdog/action-golangci-lint@00311c26a97213f93f2fd3a3524d66762e956ae0 # v2.6.1
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--config=.golangci.yml"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:

steps:
- name: clone
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: install go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
# use version from go.mod file
go-version-file: 'go.mod'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:

steps:
- name: clone
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: install go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
# use version from go.mod file
go-version-file: 'go.mod'
Expand All @@ -29,7 +29,7 @@ jobs:
go test -race -covermode=atomic -coverprofile=coverage.out ./...
- name: coverage
uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1
uses: codecov/codecov-action@125fc84a9a348dbcf27191600683ec096ec9021c # v4.4.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.out
9 changes: 6 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:

steps:
- name: clone
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: install go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
# use version from go.mod file
go-version-file: 'go.mod'
Expand All @@ -33,4 +33,7 @@ jobs:
# Check that go fmt ./... produces a zero diff; clean up any changes afterwards.
go fmt ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)
# Check that go fix ./... produces a zero diff; clean up any changes afterwards.
go fix ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)
#
# Renable this after https://github.com/golang/go/commit/7fd62ba821b1044e8e4077df052b0a1232672d57
# has been released.
# go fix ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)
89 changes: 49 additions & 40 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ linters-settings:
lines: 160
statements: 70

# https://github.com/daixiang0/gci
# ensure import order is consistent
# gci write --custom-order -s standard -s default -s blank -s dot -s "prefix(github.com/go-vela)" .
gci:
custom-order: true
sections:
- standard
- default
- blank
- dot
- prefix(github.com/go-vela)

# https://github.com/denis-tingaikin/go-header
goheader:
template: |-
Expand Down Expand Up @@ -60,45 +72,42 @@ linters:

# enable a specific set of linters to run
enable:
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- contextcheck # check the function whether use a non-inherited context
- deadcode # finds unused code
- dupl # code clone detection
- errcheck # checks for unchecked errors
- errorlint # find misuses of errors
- exportloopref # check for exported loop vars
- funlen # detects long functions
- goconst # finds repeated strings that could be replaced by a constant
- gocyclo # computes and checks the cyclomatic complexity of functions
- godot # checks if comments end in a period
- gofmt # checks whether code was gofmt-ed
- goheader # checks is file header matches to pattern
- goimports # fixes imports and formats code in same style as gofmt
- gomoddirectives # manage the use of 'replace', 'retract', and 'excludes' directives in go.mod
- goprintffuncname # checks that printf-like functions are named with f at the end
- gosec # inspects code for security problems
- gosimple # linter that specializes in simplifying a code
- govet # reports suspicious constructs, ex. Printf calls whose arguments don't align with the format string
- ineffassign # detects when assignments to existing variables aren't used
- makezero # finds slice declarations with non-zero initial length
- misspell # finds commonly misspelled English words in comments
- nakedret # finds naked returns in functions greater than a specified function length
- nilerr # finds the code that returns nil even if it checks that the error is not nil
- noctx # noctx finds sending http request without context.Context
- nolintlint # reports ill-formed or insufficient nolint directives
- revive # linter for go
- staticcheck # applies static analysis checks, go vet on steroids
- structcheck # finds unused struct fields
- stylecheck # replacement for golint
- tenv # analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
- typecheck # parses and type-checks go code, like the front-end of a go compiler
- unconvert # remove unnecessary type conversions
- unparam # reports unused function parameters
- unused # checks for unused constants, variables, functions and types
- varcheck # finds unused global variables and constants
- whitespace # detects leading and trailing whitespace
- wsl # forces code to use empty lines
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- contextcheck # check the function whether use a non-inherited context
- dupl # code clone detection
- errcheck # checks for unchecked errors
- errorlint # find misuses of errors
- exportloopref # check for exported loop vars
- funlen # detects long functions
- gci # consistent import ordering
- goconst # finds repeated strings that could be replaced by a constant
- gocyclo # computes and checks the cyclomatic complexity of functions
- godot # checks if comments end in a period
- gofmt # checks whether code was gofmt-ed
- goheader # checks is file header matches to pattern
- gomoddirectives # manage the use of 'replace', 'retract', and 'excludes' directives in go.mod
- goprintffuncname # checks that printf-like functions are named with f at the end
- gosec # inspects code for security problems
- gosimple # linter that specializes in simplifying a code
- govet # reports suspicious constructs, ex. Printf calls whose arguments don't align with the format string
- ineffassign # detects when assignments to existing variables aren't used
- makezero # finds slice declarations with non-zero initial length
- misspell # finds commonly misspelled English words in comments
- nakedret # finds naked returns in functions greater than a specified function length
- nilerr # finds the code that returns nil even if it checks that the error is not nil
- noctx # noctx finds sending http request without context.Context
- nolintlint # reports ill-formed or insufficient nolint directives
- revive # linter for go
- staticcheck # applies static analysis checks, go vet on steroids
- stylecheck # replacement for golint
- tenv # analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
- typecheck # parses and type-checks go code, like the front-end of a go compiler
- unconvert # remove unnecessary type conversions
- unparam # reports unused function parameters
- unused # checks for unused constants, variables, functions and types
- whitespace # detects leading and trailing whitespace
- wsl # forces code to use empty lines

# static list of linters we know golangci can run but we've
# chosen to leave disabled for now
Expand All @@ -112,13 +121,13 @@ linters:
# - exhaustivestruct - style preference
# - forbidigo - unused
# - forcetypeassert - unused
# - gci - use goimports
# - gochecknoinits - unused
# - gochecknoglobals - global variables allowed
# - gocognit - unused complexity metric
# - gocritic - style preference
# - godox - to be used in the future
# - goerr113 - to be used in the future
# - goimports - use gci
# - golint - archived, replaced with revive
# - gofumpt - use gofmt
# - gomnd - get too many false-positives
Expand Down
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,24 @@ schema:
@go get github.com/alecthomas/jsonschema
@go get github.com/iancoleman/orderedmap
@go run cmd/schema/main.go > schema.json

# The `lint` target is intended to lint the
# Go source code with golangci-lint.
#
# Usage: `make lint`
.PHONY: lint
lint:
@echo
@echo "### Linting Go Code"
@golangci-lint run ./...

# The `lintfix` target is intended to lint the
# Go source code with golangci-lint and apply
# any fixes that can be automatically applied.
#
# Usage: `make lintfix`
.PHONY: lintfix
lintfix:
@echo
@echo "### Fixing Go code with linter"
@golangci-lint run ./... --fix
11 changes: 10 additions & 1 deletion constants/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const (
// ActionOpened defines the action for opening pull requests.
ActionOpened = "opened"

// ActionCreated defines the action for creating issue comments.
// ActionCreated defines the action for creating deployments or issue comments.
ActionCreated = "created"

// ActionEdited defines the action for the editing of pull requests or issue comments.
Expand All @@ -22,6 +22,12 @@ const (
// ActionSynchronize defines the action for the synchronizing of pull requests.
ActionSynchronize = "synchronize"

// ActionLabeled defines the action for the labeling of pull requests.
ActionLabeled = "labeled"

// ActionUnlabeled defines the action for the unlabeling of pull requests.
ActionUnlabeled = "unlabeled"

// ActionTransferred defines the action for transferring repository ownership.
ActionTransferred = "transferred"

Expand All @@ -30,4 +36,7 @@ const (

// ActionTag defines the action for deleting a tag.
ActionTag = "tag"

// ActionRun defines the action for running a schedule.
ActionRun = "run"
)
3 changes: 2 additions & 1 deletion constants/allow_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const (
AllowPullSync
_ // AllowPullAssigned - Not Implemented
_ // AllowPullMilestoned - Not Implemented
_ // AllowPullLabel - Not Implemented
AllowPullLabel
_ // AllowPullLocked - Not Implemented
_ // AllowPullReady - Not Implemented
AllowPullReopen
Expand All @@ -23,4 +23,5 @@ const (
AllowSchedule
AllowPushDeleteBranch
AllowPushDeleteTag
AllowPullUnlabel
)
8 changes: 8 additions & 0 deletions constants/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ const (

// EventTag defines the event type for build and repo tag events.
EventTag = "tag"

// Alternates for common user inputs that do not match our set constants.

// EventPullAlternate defines the alternate event type for build and repo pull_request events.
EventPullAlternate = "pull"

// EventDeployAlternate defines the alternate event type for build and repo deployment events.
EventDeployAlternate = "deploy"
)
3 changes: 3 additions & 0 deletions constants/limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ const (

// DeployBuildsMaxSize defines the maximum size in characters for deployment builds.
DeployBuildsMaxSize = 500

// ReportStepStatusLimit defines the maximum number of steps in a pipeline that may report their status to the SCM.
ReportStepStatusLimit = 10
)
3 changes: 2 additions & 1 deletion database/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"errors"
"fmt"

"github.com/lib/pq"

"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
"github.com/go-vela/types/raw"
"github.com/lib/pq"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions database/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"database/sql"
"testing"

"github.com/go-vela/types/library"
"github.com/go-vela/types/raw"
"github.com/google/go-cmp/cmp"
"github.com/lib/pq"

"github.com/go-vela/types/library"
"github.com/go-vela/types/raw"
)

func TestDatabase_Deployment_Nullify(t *testing.T) {
Expand Down
Loading

0 comments on commit 9b9f1e2

Please sign in to comment.