switch to go 1.19 (#1709)

This commit is contained in:
blotus 2022-08-26 13:31:49 +02:00 committed by GitHub
parent bd2757c63d
commit 1f5224b74b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 46 additions and 73 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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

View file

@ -1,4 +1,4 @@
name: golangci-lint (linux) name: golangci-lint
on: on:
push: push:
@ -17,8 +17,11 @@ on:
- 'README.md' - 'README.md'
jobs: jobs:
golangci: golangci:
strategy:
matrix:
os: [ubuntu-latest, windows-2022]
name: lint name: lint
runs-on: ubuntu-latest runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: golangci-lint - 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 # 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 version: v1.48
# Optional: golangci-lint command line arguments. # 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`. # Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: false only-new-issues: false
# Optional: if set to true then the all caching functionality will be complete disabled, # Optional: if set to true then the all caching functionality will be complete disabled,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

2
go.mod
View file

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

View file

@ -52,7 +52,7 @@ func (f *MockSource) ConfigureByDSN(string, map[string]string, *log.Entry) error
return fmt.Errorf("not supported") 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 { type MockSourceCantRun struct {
MockSource MockSource
} }
@ -60,7 +60,7 @@ type MockSourceCantRun struct {
func (f *MockSourceCantRun) CanRun() error { return fmt.Errorf("can't run bro") } func (f *MockSourceCantRun) CanRun() error { return fmt.Errorf("can't run bro") }
func (f *MockSourceCantRun) GetName() string { return "mock_cant_run" } 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() { func appendMockSource() {
if GetDataSourceIface("mock") == nil { if GetDataSourceIface("mock") == nil {
mock := struct { mock := struct {
@ -445,7 +445,6 @@ READLOOP:
} }
} }
//
type MockTailError struct { type MockTailError struct {
MockTail MockTail
} }
@ -493,11 +492,10 @@ READLOOP:
} }
} }
//nolint: structcheck,unused
type MockSourceByDSN struct { type MockSourceByDSN struct {
configuration.DataSourceCommonCfg `yaml:",inline"` configuration.DataSourceCommonCfg `yaml:",inline"`
Toto string `yaml:"toto"` Toto string `yaml:"toto"`
logger *log.Entry logger *log.Entry //nolint: unused
} }
func (f *MockSourceByDSN) Configure(cfg []byte, logger *log.Entry) error { return nil } func (f *MockSourceByDSN) Configure(cfg []byte, logger *log.Entry) error { return nil }

View file

@ -3,6 +3,7 @@ package journalctlacquisition
import ( import (
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"runtime" "runtime"
"testing" "testing"
"time" "time"
@ -279,7 +280,9 @@ journalctl_filter:
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
if os.Getenv("USE_SYSTEM_JOURNALCTL") == "" { 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()) os.Exit(m.Run())
} }

View file

@ -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 not if it will actually reject plugins with invalid permissions
*/ */