Skip to content

Commit

Permalink
Add CI using goyek
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared committed Apr 12, 2024
1 parent bf8aa2d commit 5cabf36
Show file tree
Hide file tree
Showing 25 changed files with 1,800 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ on:
workflow_dispatch:

jobs:
goyek:
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
go-version: '1.22'
check-latest: true
- run: ./goyek.sh -v ci
# TODO: Uncomment after making the repository public.
# - uses: codecov/[email protected]
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# fail_ci_if_error: true
# file: ./coverage.out

check-links:
runs-on: ubuntu-22.04
steps:
Expand Down
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Tools binaries
.tools/

# Testing results
test-results/

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace files
go.work
go.work.sum

# IDEs
.idea/
.vscode/

# VIM
[._]*.s[a-v][a-z]
!*.svg
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# macOS
.DS_Store
60 changes: 60 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
run:
timeout: 5m

linters-settings:
depguard:
rules:
non-tests:
files:
- "!$test"
- "!**/*test/*.go"
deny:
- pkg: "testing"
- pkg: "github.com/stretchr/testify"
govet:
disable:
- composites
gosec:
excludes:
- G404

linters:
disable-all: true
enable:
- asciicheck
- depguard
- dupl
- durationcheck
- errorlint
- errname
- exportloopref
- forbidigo
- gci
- goconst
- gofmt
- gofumpt
- goheader
- goimports
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- makezero
- misspell
- nakedret
- nilerr
- noctx
- prealloc
- predeclared
- revive
- staticcheck
- stylecheck
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- wastedassign
- whitespace
10 changes: 10 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Default state for all rules
default: true

# allow hard-tabs
MD010: false

# allow long lines for tables and code blocks
MD013:
code_blocks: false
tables: false
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

<!-- markdownlint-configure-file
{
"MD024": {
"siblings_only": true
}
}
-->
29 changes: 29 additions & 0 deletions build/all.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright Splunk Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import "github.com/goyek/goyek/v2"

var all = goyek.Define(goyek.Task{
Name: "all",
Usage: "build pipeline",
Deps: goyek.Deps{
mod,
spell,
mdlint,
golint,
test,
},
})
26 changes: 26 additions & 0 deletions build/ci.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright Splunk Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import "github.com/goyek/goyek/v2"

var _ = goyek.Define(goyek.Task{
Name: "ci",
Usage: "build pipeline used by CI server",
Deps: goyek.Deps{
all,
diff,
},
})
28 changes: 28 additions & 0 deletions build/clean.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright Splunk Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"github.com/goyek/goyek/v2"
"github.com/goyek/x/cmd"
)

var _ = goyek.Define(goyek.Task{
Name: "clean",
Usage: "remove git ignored files",
Action: func(a *goyek.A) {
cmd.Exec(a, "git clean -fXd")
},
})
38 changes: 38 additions & 0 deletions build/diff.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright Splunk Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"io"
"strings"

"github.com/goyek/goyek/v2"
"github.com/goyek/x/cmd"
)

var diff = goyek.Define(goyek.Task{
Name: "diff",
Usage: "git diff",
Action: func(a *goyek.A) {
cmd.Exec(a, "git diff --exit-code")

sb := &strings.Builder{}
out := io.MultiWriter(a.Output(), sb)
cmd.Exec(a, "git status --porcelain", cmd.Stdout(out), cmd.Stderr(out))
if sb.Len() > 0 {
a.Error("git status --porcelain returned output")
}
},
})
Loading

0 comments on commit 5cabf36

Please sign in to comment.