From ea0fdfe522352ce0c69c592378e87a2687965d1f Mon Sep 17 00:00:00 2001 From: Christoph Petrausch Date: Wed, 24 Jun 2020 13:46:22 +0200 Subject: [PATCH 1/8] Add golangci linting --- .github/workflows/go.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 1fe8b85..15aa5e2 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,8 +14,11 @@ jobs: go-version: 1.15 id: go - - name: Check out code into the Go module directory + - name: Check out code uses: actions/checkout@v1 - name: Build run: make all + + - name: Run golangci-lint + uses: actions-contrib/golangci-lint@v1 \ No newline at end of file From 84f0661381c05c7e2d351b50d99707b9c9976ae7 Mon Sep 17 00:00:00 2001 From: Christoph Petrausch Date: Wed, 24 Jun 2020 13:46:57 +0200 Subject: [PATCH 2/8] Remove unused global variable --- main.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index c422599..4598f85 100644 --- a/main.go +++ b/main.go @@ -16,10 +16,9 @@ import ( ) var ( - resultChan = make(chan Result) - stopWaitLoop = false - tearDownInProgress = false - randomSource = rand.New(rand.NewSource(time.Now().UnixNano())) + resultChan = make(chan Result) + stopWaitLoop = false + randomSource = rand.New(rand.NewSource(time.Now().UnixNano())) subscriberClientIdTemplate = "mqtt-stresser-sub-%s-worker%d-%d" publisherClientIdTemplate = "mqtt-stresser-pub-%s-worker%d-%d" From a3855fb999e725c5b1382e750351934fc603613c Mon Sep 17 00:00:00 2001 From: Christoph Petrausch Date: Wed, 24 Jun 2020 13:49:00 +0200 Subject: [PATCH 3/8] Implement suggestions made by gosimple --- main.go | 2 +- report.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 4598f85..c33b67c 100644 --- a/main.go +++ b/main.go @@ -268,7 +268,7 @@ func main() { errorLogger.Println(msg) } - if *argHideProgress == false { + if !*argHideProgress { if msg.Event == CompletedEvent { fmt.Print(".") } diff --git a/report.go b/report.go index 6657177..be7fb16 100644 --- a/report.go +++ b/report.go @@ -195,7 +195,7 @@ func buildHistogram(series []float64, total int) map[float64]float64 { keys = append(keys, k) } - sort.Sort(sort.Float64Slice(keys)) + sort.Float64s(keys) histogram := make(map[float64]float64) prev := 0.0 From 1bf2ddb61d28025306a2bc939947b370864be020 Mon Sep 17 00:00:00 2001 From: Christoph Petrausch Date: Wed, 8 Jul 2020 12:03:43 +0200 Subject: [PATCH 4/8] run vet and lint before build --- .github/workflows/go.yml | 9 +++++++-- main.go | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 15aa5e2..be14c4a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -17,8 +17,13 @@ jobs: - name: Check out code uses: actions/checkout@v1 + - name: Go vet + run: go vet + + - name: Run golangci-lint + uses: actions-contrib/golangci-lint@v1 + + - name: Build run: make all - - name: Run golangci-lint - uses: actions-contrib/golangci-lint@v1 \ No newline at end of file diff --git a/main.go b/main.go index c33b67c..524584c 100644 --- a/main.go +++ b/main.go @@ -133,7 +133,7 @@ func main() { actionTimeout, err := time.ParseDuration(*argTimeout) if err != nil { - fmt.Fprintln(os.Stderr, "Could not parse '--timeout': '%s' is not a valid duration string. See https://golang.org/pkg/time/#ParseDuration for valid duration strings\n", *argGlobalTimeout) + fmt.Fprintf(os.Stderr, "Could not parse '--timeout': '%s' is not a valid duration string. See https://golang.org/pkg/time/#ParseDuration for valid duration strings\n", *argGlobalTimeout) os.Exit(1) } From baa9c75d9ce70876ba9cdc86b38be45dc0c6cb5f Mon Sep 17 00:00:00 2001 From: Christoph Petrausch Date: Wed, 8 Jul 2020 12:06:43 +0200 Subject: [PATCH 5/8] use latest stable release --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index be14c4a..5f91886 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,7 +11,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v1 with: - go-version: 1.15 + go-version: 1.14 id: go - name: Check out code From 4c44474214055b8e9f75a279e906e1e79813a9e7 Mon Sep 17 00:00:00 2001 From: Christoph Petrausch Date: Wed, 8 Jul 2020 12:14:01 +0200 Subject: [PATCH 6/8] Run linting in seperate action --- .github/workflows/go.yml | 6 +----- .github/workflows/linting.yml | 13 +++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/linting.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5f91886..bf69277 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -15,15 +15,11 @@ jobs: id: go - name: Check out code - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: Go vet run: go vet - - name: Run golangci-lint - uses: actions-contrib/golangci-lint@v1 - - - name: Build run: make all diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..915cfe2 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,13 @@ +on: + push: + branches: ["master"] + pull_request: +name: Golang linting +jobs: + linting: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Run golangci-lint + uses: actions-contrib/golangci-lint@v1 From 4c195b9a5d0e6dc71041adab82b210ebaa693d83 Mon Sep 17 00:00:00 2001 From: Christoph Petrausch Date: Wed, 8 Jul 2020 12:16:02 +0200 Subject: [PATCH 7/8] Move linting job into build workflow --- .github/workflows/go.yml | 7 +++++++ .github/workflows/linting.yml | 13 ------------- 2 files changed, 7 insertions(+), 13 deletions(-) delete mode 100644 .github/workflows/linting.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index bf69277..b414bbe 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -23,3 +23,10 @@ jobs: - name: Build run: make all + linting: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Run golangci-lint + uses: actions-contrib/golangci-lint@v1 diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml deleted file mode 100644 index 915cfe2..0000000 --- a/.github/workflows/linting.yml +++ /dev/null @@ -1,13 +0,0 @@ -on: - push: - branches: ["master"] - pull_request: -name: Golang linting -jobs: - linting: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Run golangci-lint - uses: actions-contrib/golangci-lint@v1 From f64aff5cb5ee5ccc3c4b0c7279545ec2f7bc0c98 Mon Sep 17 00:00:00 2001 From: Christoph Petrausch Date: Wed, 8 Jul 2020 12:18:07 +0200 Subject: [PATCH 8/8] Streamline job naming --- .github/workflows/go.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index b414bbe..a13709e 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -24,6 +24,7 @@ jobs: run: make all linting: + name: Linting runs-on: ubuntu-latest steps: - name: Checkout code