Skip to content

Commit a631cf2

Browse files
committed
Add basic repo setup, base command
1 parent 39dcc71 commit a631cf2

File tree

10 files changed

+203
-0
lines changed

10 files changed

+203
-0
lines changed

.github/dependabot.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: 2
2+
updates:
3+
4+
# Maintain dependencies for GitHub Actions
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "daily"
9+
labels:
10+
- "github_actions"
11+
12+
# Maintain dependencies for top level Go modules
13+
- package-ecosystem: gomod
14+
directory: /
15+
target-branch: "main"
16+
schedule:
17+
interval: weekly
18+
labels:
19+
- "dependencies"
20+
open-pull-requests-limit: 10
21+
pull-request-branch-name:
22+
separator: "-"
23+
reviewers:
24+
- "zivkovicmilos"

.github/workflows/lint.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on:
2+
workflow_call:
3+
workflow_dispatch:
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Install Go
10+
uses: actions/setup-go@v3
11+
with:
12+
go-version: 1.19.x
13+
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Lint
18+
uses: golangci/golangci-lint-action@v3

.github/workflows/main.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
pull_request:
6+
7+
jobs:
8+
lint:
9+
name: Go Linter
10+
uses: ./.github/workflows/lint.yaml
11+
12+
test:
13+
name: Go Test
14+
uses: ./.github/workflows/test.yaml

.github/workflows/test.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
on:
2+
workflow_call:
3+
workflow_dispatch:
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Install Go
10+
uses: actions/setup-go@v3
11+
with:
12+
go-version: 1.19.x
13+
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Go test
18+
run: go test -shuffle=on -coverprofile coverage.out -timeout 5m ./...
19+
20+
test-with-race:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Install Go
24+
uses: actions/setup-go@v3
25+
with:
26+
go-version: 1.19.x
27+
28+
- name: Checkout code
29+
uses: actions/checkout@v3
30+
31+
- name: Go race test
32+
run: go test -race -shuffle=on -timeout 5m ./...

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# MacOS Leftovers
2+
.DS_Store
3+
4+
# Editor Leftovers
5+
.vscode
6+
.idea
7+
8+
# Build Leftovers
9+
build/*

.golangci.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
run:
2+
timeout: 5m
3+
tests: true
4+
skip-dirs-use-default: true
5+
6+
service:
7+
golangci-lint-version: latest
8+
9+
linters:
10+
disable-all: true
11+
enable:
12+
- whitespace # Tool for detection of leading and trailing whitespace
13+
- wsl # Forces you to use empty lines
14+
- unconvert # Unnecessary type conversions
15+
- tparallel # Detects inappropriate usage of t.Parallel() method in your Go test codes
16+
- thelper # Detects golang test helpers without t.Helper() call and checks the consistency of test helpers
17+
- stylecheck # Stylecheck is a replacement for golint
18+
- prealloc # Finds slice declarations that could potentially be pre-allocated
19+
- predeclared # Finds code that shadows one of Go's predeclared identifiers
20+
- nolintlint # Ill-formed or insufficient nolint directives
21+
- nlreturn # Checks for a new line before return and branch statements to increase code clarity
22+
- misspell # Misspelled English words in comments
23+
- makezero # Finds slice declarations with non-zero initial length
24+
- lll # Long lines
25+
- importas # Enforces consistent import aliases
26+
- gosec # Security problems
27+
- gofmt # Whether the code was gofmt-ed
28+
- goimports # Unused imports
29+
- goconst # Repeated strings that could be replaced by a constant
30+
- forcetypeassert # Finds forced type assertions
31+
- dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
32+
- dupl # Code clone detection
33+
- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
34+
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13
35+
- unused # Checks Go code for unused constants, variables, functions and types
36+
37+
linters-settings:
38+
gofmt:
39+
simplify: true
40+
goconst:
41+
min-len: 3
42+
min-occurrences: 3

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
all: build
2+
3+
.PHONY: build
4+
build:
5+
@echo "Building supernova binary"
6+
go build -o build/supernova ./cmd
7+
8+
.PHONY: lint
9+
lint:
10+
golangci-lint run --config .golangci.yaml

cmd/root.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"flag"
6+
"fmt"
7+
"os"
8+
9+
"github.com/peterbourgon/ff/v3/ffcli"
10+
)
11+
12+
// mainCfg is the main runtime configuration
13+
type mainCfg struct {
14+
}
15+
16+
// registerFlags registers the main configuration flags
17+
func (c *mainCfg) registerFlags(fs *flag.FlagSet) {
18+
// TODO register flags
19+
}
20+
21+
func main() {
22+
cfg := &mainCfg{}
23+
fs := flag.NewFlagSet("", flag.ExitOnError)
24+
25+
cfg.registerFlags(fs)
26+
27+
cmd := &ffcli.Command{
28+
ShortUsage: "[flags] [<arg>...]",
29+
LongHelp: "Starts the stress testing suite against a TM2 cluster",
30+
FlagSet: fs,
31+
Exec: func(ctx context.Context, _ []string) error {
32+
return execMain(ctx, cfg)
33+
},
34+
}
35+
36+
if err := cmd.ParseAndRun(context.Background(), os.Args[1:]); err != nil {
37+
_, _ = fmt.Fprintf(os.Stderr, "%+v", err)
38+
39+
os.Exit(1)
40+
}
41+
}
42+
43+
// execMain starts the stress test workflow (runs the pipeline)
44+
func execMain(ctx context.Context, cfg *mainCfg) error {
45+
// TODO start the test workflow
46+
return nil
47+
}

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/gnolang/supernova
2+
3+
go 1.19
4+
5+
require github.com/peterbourgon/ff/v3 v3.3.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/peterbourgon/ff/v3 v3.3.0 h1:PaKe7GW8orVFh8Unb5jNHS+JZBwWUMa2se0HM6/BI24=
2+
github.com/peterbourgon/ff/v3 v3.3.0/go.mod h1:zjJVUhx+twciwfDl0zBcFzl4dW8axCRyXE/eKY9RztQ=

0 commit comments

Comments
 (0)