Enable Go 1.18 in the ci and release workflows

* Enable Go 1.18 in the ci and release workflows

* Fix lint warning

* Add golangci as a make target
This commit is contained in:
Cosmin Cojocar 2022-03-21 16:53:22 +01:00 committed by GitHub
parent b99b5f7838
commit 607d607b51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 49 deletions

View file

@ -13,6 +13,7 @@ jobs:
go_version: go_version:
- '1.16' - '1.16'
- '1.17' - '1.17'
- '1.18'
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GO111MODULE: on GO111MODULE: on
@ -44,7 +45,7 @@ jobs:
- name: Setup go - name: Setup go
uses: actions/setup-go@v3 uses: actions/setup-go@v3
with: with:
go-version: '1.17' go-version: '1.18'
- name: Checkout Source - name: Checkout Source
uses: actions/checkout@v3 uses: actions/checkout@v3
- uses: actions/cache@v2 - uses: actions/cache@v2

View file

@ -17,11 +17,11 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@v3
with: with:
go-version: 1.17 go-version: 1.18
- name: Install Cosign - name: Install Cosign
uses: sigstore/cosign-installer@main uses: sigstore/cosign-installer@main
with: with:
cosign-release: 'v1.5.2' cosign-release: 'v1.6.0'
- name: Store Cosign private key in a file - name: Store Cosign private key in a file
run: 'echo "$COSIGN_KEY" > /tmp/cosign.key' run: 'echo "$COSIGN_KEY" > /tmp/cosign.key'
shell: bash shell: bash
@ -66,7 +66,7 @@ jobs:
tags: ${{steps.meta.outputs.tags}} tags: ${{steps.meta.outputs.tags}}
labels: ${{steps.meta.outputs.labels}} labels: ${{steps.meta.outputs.labels}}
push: true push: true
build-args: GO_VERSION=1.17 build-args: GO_VERSION=1.18
- name: Sign Docker Image - name: Sign Docker Image
run: cosign sign -key /tmp/cosign.key ${TAGS} run: cosign sign -key /tmp/cosign.key ${TAGS}
env: env:

View file

@ -12,7 +12,7 @@ GOBIN ?= $(GOPATH)/bin
GOLINT ?= $(GOBIN)/golint GOLINT ?= $(GOBIN)/golint
GOSEC ?= $(GOBIN)/gosec GOSEC ?= $(GOBIN)/gosec
GINKGO ?= $(GOBIN)/ginkgo GINKGO ?= $(GOBIN)/ginkgo
GO_VERSION = 1.17 GO_VERSION = 1.18
default: default:
$(MAKE) build $(MAKE) build
@ -31,12 +31,16 @@ fmt:
@([ ! -z "$(FORMATTED)" ] && printf "Fixed unformatted files:\n$(FORMATTED)") || true @([ ! -z "$(FORMATTED)" ] && printf "Fixed unformatted files:\n$(FORMATTED)") || true
lint: lint:
@echo "LINTING" @echo "LINTING: golint"
$(GO_NOMOD) get -u golang.org/x/lint/golint $(GO_NOMOD) get -u golang.org/x/lint/golint
$(GOLINT) -set_exit_status ./... $(GOLINT) -set_exit_status ./...
@echo "VETTING" @echo "VETTING"
$(GO) vet ./... $(GO) vet ./...
golangci:
@echo "LINTING: golangci-lint"
golangci-lint run
sec: sec:
@echo "SECURITY SCANNING" @echo "SECURITY SCANNING"
./$(BIN) ./... ./$(BIN) ./...

View file

@ -1,7 +1,3 @@
//go:build go1.14 || !go1.11
// +build go1.14 !go1.11
// main
package main package main
import ( import (

View file

@ -1,34 +0,0 @@
//go:build go1.12 && !go1.14
// +build go1.12,!go1.14
// This file can be removed once go1.13 is no longer supported
package main
import (
"crypto/tls"
"sort"
)
func mapTLSVersions(tlsVersions []string) []int {
var versions []int
for _, tlsVersion := range tlsVersions {
switch tlsVersion {
case "TLSv1.3":
versions = append(versions, tls.VersionTLS13)
case "TLSv1.2":
versions = append(versions, tls.VersionTLS12)
case "TLSv1.1":
versions = append(versions, tls.VersionTLS11)
case "TLSv1":
versions = append(versions, tls.VersionTLS10)
case "SSLv3":
// unsupported from go1.14
versions = append(versions, tls.VersionSSL30)
default:
continue
}
}
sort.Ints(versions)
return versions
}

View file

@ -1,6 +1,3 @@
//go:build go1.12
// +build go1.12
package main package main
import ( import (
@ -14,9 +11,10 @@ import (
"log" "log"
"net/http" "net/http"
"path/filepath" "path/filepath"
"strings"
"github.com/mozilla/tls-observatory/constants" "github.com/mozilla/tls-observatory/constants"
"golang.org/x/text/cases"
"golang.org/x/text/language"
) )
var ( var (
@ -82,7 +80,8 @@ func getTLSConfFromURL(url string) (*ServerSideTLSJson, error) {
} }
func getGoCipherConfig(name string, sstls ServerSideTLSJson) (goCipherConfiguration, error) { func getGoCipherConfig(name string, sstls ServerSideTLSJson) (goCipherConfiguration, error) {
cipherConf := goCipherConfiguration{Name: strings.Title(name)} caser := cases.Title(language.English)
cipherConf := goCipherConfiguration{Name: caser.String(name)}
conf, ok := sstls.Configurations[name] conf, ok := sstls.Configurations[name]
if !ok { if !ok {
return cipherConf, fmt.Errorf("TLS configuration '%s' not found", name) return cipherConf, fmt.Errorf("TLS configuration '%s' not found", name)