Browse Source

switch to go 1.19 (#1709)

blotus 2 years ago
parent
commit
1f5224b74b

+ 4 - 4
.github/workflows/bats-hub.yml

@@ -23,10 +23,10 @@ jobs:
           sudo chmod +w /etc/machine-id
           echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
 
-    - name: "Set up Go 1.17"
+    - name: "Set up Go 1.19"
       uses: actions/setup-go@v3
       with:
-        go-version: 1.17
+        go-version: 1.19
       id: go
 
     - name: "Clone CrowdSec"
@@ -39,8 +39,8 @@ jobs:
       run: |
         sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq netcat-openbsd
         go install github.com/mikefarah/yq/v4@latest
-        go install github.com/cloudflare/cfssl/cmd/cfssl@latest
-        go install github.com/cloudflare/cfssl/cmd/cfssljson@latest
+        go install github.com/cloudflare/cfssl/cmd/cfssl@master
+        go install github.com/cloudflare/cfssl/cmd/cfssljson@master
         sudo cp -u ~/go/bin/yq /usr/local/bin/
         sudo cp -u ~/go/bin/cfssl /usr/local/bin
         sudo cp -u ~/go/bin/cfssljson /usr/local/bin

+ 4 - 4
.github/workflows/bats-mysql.yml

@@ -34,10 +34,10 @@ jobs:
           sudo chmod +w /etc/machine-id
           echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
 
-    - name: "Set up Go 1.17"
+    - name: "Set up Go 1.19"
       uses: actions/setup-go@v3
       with:
-        go-version: 1.17
+        go-version: 1.19
       id: go
 
     - name: "Check out CrowdSec repository"
@@ -50,8 +50,8 @@ jobs:
       run: |
         sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq netcat-openbsd
         go install github.com/mikefarah/yq/v4@latest
-        go install github.com/cloudflare/cfssl/cmd/cfssl@latest
-        go install github.com/cloudflare/cfssl/cmd/cfssljson@latest
+        go install github.com/cloudflare/cfssl/cmd/cfssl@master
+        go install github.com/cloudflare/cfssl/cmd/cfssljson@master
         sudo cp -u ~/go/bin/yq ~/go/bin/cfssl ~/go/bin/cfssljson /usr/local/bin/
 
     - name: "Build crowdsec and fixture"

+ 4 - 4
.github/workflows/bats-postgres.yml

@@ -35,10 +35,10 @@ jobs:
           sudo chmod +w /etc/machine-id
           echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
 
-    - name: "Set up Go 1.17"
+    - name: "Set up Go 1.19"
       uses: actions/setup-go@v3
       with:
-        go-version: 1.17
+        go-version: 1.19
       id: go
 
     - name: "Check out CrowdSec repository"
@@ -51,8 +51,8 @@ jobs:
       run: |
         sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq netcat-openbsd
         go install github.com/mikefarah/yq/v4@latest
-        go install github.com/cloudflare/cfssl/cmd/cfssl@latest
-        go install github.com/cloudflare/cfssl/cmd/cfssljson@latest
+        go install github.com/cloudflare/cfssl/cmd/cfssl@master
+        go install github.com/cloudflare/cfssl/cmd/cfssljson@master
         sudo cp -u ~/go/bin/yq ~/go/bin/cfssl ~/go/bin/cfssljson /usr/local/bin/
 
     - name: "Build crowdsec and fixture (DB_BACKEND: pgx)"

+ 4 - 4
.github/workflows/bats-sqlite-coverage.yml

@@ -21,10 +21,10 @@ jobs:
           sudo chmod +w /etc/machine-id
           echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
 
-    - name: "Set up Go 1.17"
+    - name: "Set up Go 1.19"
       uses: actions/setup-go@v3
       with:
-        go-version: 1.17
+        go-version: 1.19
       id: go
 
     - name: "Check out CrowdSec repository"
@@ -37,8 +37,8 @@ jobs:
       run: |
         sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq netcat-openbsd
         go install github.com/mikefarah/yq/v4@latest
-        go install github.com/cloudflare/cfssl/cmd/cfssl@latest
-        go install github.com/cloudflare/cfssl/cmd/cfssljson@latest
+        go install github.com/cloudflare/cfssl/cmd/cfssl@master
+        go install github.com/cloudflare/cfssl/cmd/cfssljson@master
         sudo cp -u ~/go/bin/yq ~/go/bin/cfssl ~/go/bin/cfssljson /usr/local/bin/
         go install github.com/wadey/gocovmerge@latest
         sudo cp -u ~/go/bin/gocovmerge /usr/local/bin/

+ 2 - 2
.github/workflows/ci-windows-build-msi.yml

@@ -14,10 +14,10 @@ jobs:
     name: Build
     runs-on: windows-2019
     steps:
-    - name: Set up Go 1.17
+    - name: Set up Go 1.19
       uses: actions/setup-go@v1
       with:
-        go-version: 1.17
+        go-version: 1.19
       id: go
     - name: Check out code into the Go module directory
       uses: actions/checkout@v2

+ 0 - 31
.github/workflows/ci_golangci-lint-windows.yml

@@ -1,31 +0,0 @@
-name: golangci-lint (windows)
-
-on:
-  push:
-    tags:
-      - v*
-    branches:
-      - master
-    paths-ignore:
-      - 'docs/**'
-      - 'mkdocs.yml'
-      - 'README.md'
-  pull_request:
-    paths-ignore:
-      - 'docs/**'
-      - 'mkdocs.yml'
-      - 'README.md'
-jobs:
-  golangci:
-    name: lint
-    runs-on: windows-2022
-    steps:
-      - uses: actions/checkout@v3
-      - name: golangci-lint
-        uses: golangci/golangci-lint-action@v3
-        with:
-          # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
-          version: v1.48
-          # Optional: golangci-lint command line arguments.
-          args: --issues-exit-code=0 --timeout 10m
-          only-new-issues: true

+ 6 - 3
.github/workflows/ci_golangci-lint.yml

@@ -1,4 +1,4 @@
-name: golangci-lint (linux)
+name: golangci-lint
 
 on:
   push:
@@ -17,8 +17,11 @@ on:
       - 'README.md'
 jobs:
   golangci:
+    strategy:
+      matrix:
+        os: [ubuntu-latest, windows-2022]
     name: lint
-    runs-on: ubuntu-latest
+    runs-on: ${{ matrix.os }}
     steps:
       - uses: actions/checkout@v3
       - name: golangci-lint
@@ -27,7 +30,7 @@ jobs:
           # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
           version: v1.48
           # Optional: golangci-lint command line arguments.
-          args: --issues-exit-code=1 --timeout 5m
+          args: --issues-exit-code=1 --timeout 10m
           # Optional: show only new issues if it's a pull request. The default value is `false`.
           only-new-issues: false
           # Optional: if set to true then the all caching functionality will be complete disabled,

+ 2 - 2
.github/workflows/go-tests-windows.yml

@@ -21,10 +21,10 @@ jobs:
 
     steps:
 
-    - name: "Set up Go 1.17"
+    - name: "Set up Go 1.19"
       uses: actions/setup-go@v3
       with:
-        go-version: 1.17
+        go-version: 1.19
       id: go
 
     - name: Check out CrowdSec repository

+ 2 - 2
.github/workflows/go-tests.yml

@@ -58,10 +58,10 @@ jobs:
 
     steps:
 
-    - name: "Set up Go 1.17"
+    - name: "Set up Go 1.19"
       uses: actions/setup-go@v3
       with:
-        go-version: 1.17
+        go-version: 1.19
       id: go
 
     - name: Check out CrowdSec repository

+ 4 - 4
.github/workflows/release_publish-package.yml

@@ -10,10 +10,10 @@ jobs:
     name: Build and upload binary package
     runs-on: ubuntu-latest
     steps:
-    - name: Set up Go 1.17
+    - name: Set up Go 1.19
       uses: actions/setup-go@v3
       with:
-        go-version: 1.17
+        go-version: 1.19
       id: go
     - name: Check out code into the Go module directory
       uses: actions/checkout@v3
@@ -29,10 +29,10 @@ jobs:
     name: Build and upload binary package
     runs-on: ubuntu-latest
     steps:
-    - name: Set up Go 1.17
+    - name: Set up Go 1.19
       uses: actions/setup-go@v1
       with:
-        go-version: 1.17
+        go-version: 1.19
       id: go
     - name: Check out code into the Go module directory
       uses: actions/checkout@v3

+ 1 - 1
Dockerfile

@@ -1,4 +1,4 @@
-ARG GOVERSION=1.17
+ARG GOVERSION=1.19
 
 FROM golang:${GOVERSION}-alpine AS build
 

+ 1 - 1
Dockerfile.debian

@@ -1,4 +1,4 @@
-ARG GOVERSION=1.17
+ARG GOVERSION=1.19
 
 FROM golang:${GOVERSION}-bullseye AS build
 

+ 2 - 2
azure-pipelines.yml

@@ -25,9 +25,9 @@ stages:
               custom: 'tool'
               arguments: 'install --global SignClient --version 1.3.155'
           - task: GoTool@0
-            displayName: "Install Go 1.17"
+            displayName: "Install Go 1.19"
             inputs:
-                version: '1.17.9'
+                version: '1.19'
 
           - pwsh: |
               choco install -y jq

+ 1 - 1
go.mod

@@ -1,6 +1,6 @@
 module github.com/crowdsecurity/crowdsec
 
-go 1.17
+go 1.19
 
 require (
 	entgo.io/ent v0.10.1

+ 4 - 6
pkg/acquisition/acquisition_test.go

@@ -52,7 +52,7 @@ func (f *MockSource) ConfigureByDSN(string, map[string]string, *log.Entry) error
 	return fmt.Errorf("not supported")
 }
 
-//copy the mocksource, but this one can't run
+// copy the mocksource, but this one can't run
 type MockSourceCantRun struct {
 	MockSource
 }
@@ -60,7 +60,7 @@ type MockSourceCantRun struct {
 func (f *MockSourceCantRun) CanRun() error   { return fmt.Errorf("can't run bro") }
 func (f *MockSourceCantRun) GetName() string { return "mock_cant_run" }
 
-//appendMockSource is only used to add mock source for tests
+// appendMockSource is only used to add mock source for tests
 func appendMockSource() {
 	if GetDataSourceIface("mock") == nil {
 		mock := struct {
@@ -445,7 +445,6 @@ READLOOP:
 	}
 }
 
-//
 type MockTailError struct {
 	MockTail
 }
@@ -493,11 +492,10 @@ READLOOP:
 	}
 }
 
-//nolint: structcheck,unused
 type MockSourceByDSN struct {
 	configuration.DataSourceCommonCfg `yaml:",inline"`
-	Toto                              string `yaml:"toto"`
-	logger                            *log.Entry
+	Toto                              string     `yaml:"toto"`
+	logger                            *log.Entry //nolint: unused
 }
 
 func (f *MockSourceByDSN) Configure(cfg []byte, logger *log.Entry) error           { return nil }

+ 4 - 1
pkg/acquisition/modules/journalctl/journalctl_test.go

@@ -3,6 +3,7 @@ package journalctlacquisition
 import (
 	"os"
 	"os/exec"
+	"path/filepath"
 	"runtime"
 	"testing"
 	"time"
@@ -279,7 +280,9 @@ journalctl_filter:
 
 func TestMain(m *testing.M) {
 	if os.Getenv("USE_SYSTEM_JOURNALCTL") == "" {
-		os.Setenv("PATH", "./test_files"+":"+os.Getenv("PATH"))
+		currentDir, _ := os.Getwd()
+		fullPath := filepath.Join(currentDir, "test_files")
+		os.Setenv("PATH", fullPath+":"+os.Getenv("PATH"))
 	}
 	os.Exit(m.Run())
 }

+ 1 - 1
pkg/csplugin/broker_win_test.go

@@ -20,7 +20,7 @@ import (
 )
 
 /*
-Due to the complexity of file permission modification with go on windows, we only test the basic behaviour the broker,
+Due to the complexity of file permission modification with go on windows, we only test the basic behavior the broker,
 not if it will actually reject plugins with invalid permissions
 */