Skip to content

Commit

Permalink
fix: add reviewdog pipeline (#36)
Browse files Browse the repository at this point in the history
* fix: add reviewdog pipeline

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo
  • Loading branch information
isindir authored Dec 7, 2024
1 parent 52fa868 commit 47ac440
Show file tree
Hide file tree
Showing 10 changed files with 339 additions and 125 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/reviewdog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: reviewdog
on: [pull_request]

jobs:
reviewdog:
name: linters
runs-on: ubuntu-latest
steps:
# UPDATE_HERE
# https://github.com/actions/checkout/releases
- name: check out code into the go module directory
uses: actions/checkout@v4


# UPDATE_HERE
# https://github.com/reviewdog/action-golangci-lint/releases
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
# with:
# golangci_lint_flags: "--timeout=15m"

# UPDATE_HERE
# https://github.com/reviewdog/action-actionlint/releases
- name: action-lint
uses: reviewdog/action-actionlint@v1
98 changes: 98 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
run:
concurrency: 6
deadline: 5m
issues:
exclude-rules:
# counterfeiter fakes are usually named 'fake_<something>.go'
- path: fake_.*\.go
linters:
- gocritic
- golint
- dupl
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true

enable:
- asciicheck
- bodyclose
- errcheck
- goconst
- gocritic
- gofmt
- gofumpt
- goimports
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- prealloc
- unconvert
- unconvert
- whitespace
- unused
- ineffassign
# - unparam
# - revive
# - stylecheck
# - lll
# - gomnd
# - goprintffuncname
# - interfacer
# - staticcheck
# - structcheck
# - typecheck
# - goerr113
# - noctx

linters-settings:
gosec:
excludes:
- G401
- G505
gocritic:
enabled-checks:
# Diagnostic
- commentedOutCode
- nilValReturn
- sloppyReassign
- weakCond
- octalLiteral

# Performance
- appendCombine
- equalFold
- hugeParam
- indexAlloc
- rangeExprCopy
# - rangeValCopy

# Style
- boolExprSimplify
- commentedOutImport
- docStub
- emptyFallthrough
- emptyStringTest
- hexLiteral
- methodExprCall
- stringXbytes
- typeAssertChain
- unlabelStmt
- yodaStyleExpr
# - ifElseChain

# Opinionated
- builtinShadow
- importShadow
- initClause
- nestingReduce
- paramTypeCombine
- ptrToRefParam
- typeUnparen
- unnamedResult
- unnecessaryBlock
8 changes: 2 additions & 6 deletions bitbucket/bitbucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ func GenerateProjectKey(projectName string) string {
}

// RepositoryExists - checks if bitbucket repository exists
func RepositoryExists(repoSha string, owner string, repository string) bool {
func RepositoryExists(repoSha, owner, repository string) bool {
git := bitbucketAuth(repoSha)

repoOptions := &bitbucket.RepositoryOptions{
Owner: owner,
RepoSlug: repository,
}
repo, err := git.Repositories.Repository.Get(repoOptions)

if err != nil {
log.Debugf("%s: Error fetching repository '%s/%s': %+v", repoSha, owner, repository, err)
return false
Expand All @@ -77,15 +76,14 @@ func RepositoryExists(repoSha string, owner string, repository string) bool {
}

// ProjectExists - checks if bitbucket project exists
func ProjectExists(git *bitbucket.Client, repoSha string, workspace string, project string) bool {
func ProjectExists(git *bitbucket.Client, repoSha, workspace, project string) bool {
opt := &bitbucket.ProjectOptions{
Owner: workspace,
Name: project,
}
log.Debugf("%s: Parameter ProjectOptions '%+v'", repoSha, opt)

prj, err := git.Workspaces.GetProject(opt)

if err != nil {
log.Debugf("%s: Error fetching project '%s' in workspace '%s': %+v\n", repoSha, project, workspace, err)
return false
Expand Down Expand Up @@ -125,7 +123,6 @@ func CreateRepository(repoSha, repository, mirrorVisibilityMode, sourceURL, proj
log.Debugf("%s: Creating repository with parameters: '%+v'", repoSha, repoOptions)

resultingRepository, err := git.Repositories.Repository.Create(repoOptions)

if err != nil {
log.Fatalf("%s: Error - while trying to create github repository '%s': '%s'", repoSha, repository, err)
os.Exit(1)
Expand Down Expand Up @@ -156,7 +153,6 @@ func FetchOwnerRepos(repoSha, owner, bitbucketRole string) []bitbucket.Repositor
reposToReutrn = repos.Items
} else {
log.Errorf("%s: Can't fetch repository list for '%s' '%+v'", repoSha, owner, err)

}

for i := 0; repos != nil && i < len(repos.Items) && err == nil; i++ {
Expand Down
2 changes: 1 addition & 1 deletion cmd/config_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ git-get config-gen -f Gitfile -p "github" -u "[email protected]:AcmeOrg" -t AcmeOrg
gitCloudProviderRootURL,
gitCloudProvider,
targetClonePath,
configGenParams,
&configGenParams,
)
},
}
Expand Down
36 changes: 20 additions & 16 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,28 @@ import (

var configGenParams gitget.ConfigGenParamsStruct

var cfgFile string
var cfgFiles []string
var ignoreFiles []string
var logLevel string
var stayOnRef bool
var shallow bool
var concurrencyLevel int
var pushMirror bool
var dryRun bool
var gitCloudProviderRootURL string
var targetClonePath string
var defaultMainBranch string
var status bool
var gitCloudProvider string
var (
cfgFile string
cfgFiles []string
ignoreFiles []string
logLevel string
stayOnRef bool
shallow bool
concurrencyLevel int
pushMirror bool
dryRun bool
gitCloudProviderRootURL string
targetClonePath string
defaultMainBranch string
status bool
gitCloudProvider string
)

// Mirroring specific vars
var mirrorVisibilityMode string
var mirrorBitbucketProjectName string
var (
mirrorVisibilityMode string
mirrorBitbucketProjectName string
)

var levels = map[string]log.Level{
"panic": log.PanicLevel,
Expand Down
5 changes: 2 additions & 3 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ var versionCmd = &cobra.Command{
Use: "version",
Short: "Prints version information",
Run: func(cmd *cobra.Command, args []string) {
printLongVersion, _ := cmd.Flags().GetBool("long")

long, _ := cmd.Flags().GetBool("long")

if long == true {
if printLongVersion {
fmt.Printf(
"%s %s %s %s %s/%s\n",
filepath.Base(os.Args[0]),
Expand Down
Loading

0 comments on commit 47ac440

Please sign in to comment.