Improve golang CI
This commit is contained in:
parent
8145690bfd
commit
fee9ec19fd
5 changed files with 46 additions and 29 deletions
53
.github/workflows/go.yml
vendored
53
.github/workflows/go.yml
vendored
|
|
@ -7,32 +7,45 @@ on:
|
||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Test
|
name: Test with latest golang
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: Check out repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up Go 1.x
|
- name: Set up latest golang
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: ^1.16
|
go-version: ^1.18
|
||||||
id: go
|
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Get dependencies
|
|
||||||
run: |
|
|
||||||
go get -v -t -d ./...
|
|
||||||
if [ -f Gopkg.toml ]; then
|
|
||||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
|
||||||
dep ensure
|
|
||||||
fi
|
|
||||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: go test -v -race ./...
|
run: go test -v -race ./...
|
||||||
|
|
||||||
- name: Lint
|
test-old:
|
||||||
run: golangci-lint run ./...
|
name: Test with 1.15
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Go 1.15
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.15
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: go test -v -race ./...
|
||||||
|
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.17
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: golangci-lint
|
||||||
|
uses: golangci/golangci-lint-action@v3
|
||||||
|
with:
|
||||||
|
version: v1.46.2
|
||||||
|
|
@ -45,3 +45,5 @@ linters:
|
||||||
- varnamelen # Forbids short var names
|
- varnamelen # Forbids short var names
|
||||||
- ireturn # Prevents returning interfaces
|
- ireturn # Prevents returning interfaces
|
||||||
- forcetypeassert # Forces to assert types in tests
|
- forcetypeassert # Forces to assert types in tests
|
||||||
|
- nonamedreturns # Disallows named returns
|
||||||
|
- exhaustruct # Forces all structs to be named
|
||||||
|
|
@ -148,7 +148,7 @@ func (keyRing *KeyRing) NewManualAttachmentProcessor(
|
||||||
return attachmentProc, nil
|
return attachmentProc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// readAll works a bit like io.ReadAll
|
// readAll works a bit like ioutil.ReadAll
|
||||||
// but we can choose the buffer to write to
|
// but we can choose the buffer to write to
|
||||||
// and we don't grow the slice in case of overflow.
|
// and we don't grow the slice in case of overflow.
|
||||||
func readAll(buffer []byte, reader io.Reader) (int, error) {
|
func readAll(buffer []byte, reader io.Reader) (int, error) {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package crypto
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -65,7 +66,7 @@ func TestKeyRing_EncryptDecryptStream(t *testing.T) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("Expected an error while verifying the signature before reading the data, got nil")
|
t.Fatal("Expected an error while verifying the signature before reading the data, got nil")
|
||||||
}
|
}
|
||||||
decryptedBytes, err := io.ReadAll(decryptedReader)
|
decryptedBytes, err := ioutil.ReadAll(decryptedReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +89,7 @@ func TestKeyRing_EncryptDecryptStream(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Expected no error while calling decrypting stream with key ring, got:", err)
|
t.Fatal("Expected no error while calling decrypting stream with key ring, got:", err)
|
||||||
}
|
}
|
||||||
decryptedBytes, err = io.ReadAll(decryptedReaderNoVerify)
|
decryptedBytes, err = ioutil.ReadAll(decryptedReaderNoVerify)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
||||||
}
|
}
|
||||||
|
|
@ -188,7 +189,7 @@ func TestKeyRing_DecryptStreamCompatible(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Expected no error while calling decrypting stream with key ring, got:", err)
|
t.Fatal("Expected no error while calling decrypting stream with key ring, got:", err)
|
||||||
}
|
}
|
||||||
decryptedBytes, err := io.ReadAll(decryptedReader)
|
decryptedBytes, err := ioutil.ReadAll(decryptedReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
||||||
}
|
}
|
||||||
|
|
@ -257,7 +258,7 @@ func TestKeyRing_EncryptDecryptSplitStream(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Expected no error while decrypting split stream with key ring, got:", err)
|
t.Fatal("Expected no error while decrypting split stream with key ring, got:", err)
|
||||||
}
|
}
|
||||||
decryptedBytes, err := io.ReadAll(decryptedReader)
|
decryptedBytes, err := ioutil.ReadAll(decryptedReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
||||||
}
|
}
|
||||||
|
|
@ -379,7 +380,7 @@ func TestKeyRing_DecryptSplitStreamCompatible(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Expected no error while decrypting split stream with key ring, got:", err)
|
t.Fatal("Expected no error while decrypting split stream with key ring, got:", err)
|
||||||
}
|
}
|
||||||
decryptedBytes, err := io.ReadAll(decryptedReader)
|
decryptedBytes, err := ioutil.ReadAll(decryptedReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package crypto
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -55,7 +56,7 @@ func TestSessionKey_EncryptDecryptStream(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Expected no error while calling DecryptStream, got:", err)
|
t.Fatal("Expected no error while calling DecryptStream, got:", err)
|
||||||
}
|
}
|
||||||
decryptedBytes, err := io.ReadAll(decryptedReader)
|
decryptedBytes, err := ioutil.ReadAll(decryptedReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
||||||
}
|
}
|
||||||
|
|
@ -158,7 +159,7 @@ func TestSessionKey_DecryptStreamCompatible(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Expected no error while calling DecryptStream, got:", err)
|
t.Fatal("Expected no error while calling DecryptStream, got:", err)
|
||||||
}
|
}
|
||||||
decryptedBytes, err := io.ReadAll(decryptedReader)
|
decryptedBytes, err := ioutil.ReadAll(decryptedReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
t.Fatal("Expected no error while reading the decrypted data, got:", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue