Skip to content

Commit

Permalink
build(go): bump golang, build with 1.22, support 1.20+ (open-policy-a…
Browse files Browse the repository at this point in the history
…gent#6595)

https://go.dev/doc/go1.22

Signed-off-by: Stephan Renatus <[email protected]>
Signed-off-by: Thomas Sidebottom <[email protected]>
  • Loading branch information
srenatus authored and tsidebottom committed Apr 17, 2024
1 parent f87a9c9 commit 95dec3a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 159 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-latest]
version: ["1.19"]
version: ["1.20"]
steps:
- uses: actions/checkout@v4
- name: Download generated artifacts
Expand Down
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.5
1.22
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/open-policy-agent/opa

go 1.19
go 1.20

require (
github.com/OneOfOne/xxhash v1.2.8
Expand Down
145 changes: 0 additions & 145 deletions internal/prometheus/prometheus_go1.19_test.go

This file was deleted.

20 changes: 15 additions & 5 deletions internal/prometheus/prometheus_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright 2022 The OPA Authors. All rights reserved.
// Use of this source code is governed by an Apache2
// license that can be found in the LICENSE file.

// NOTE(an): Different go runtime metrics on 1.20.
// This can be removed when we drop support for go 1.19.
//go:build go1.20
// +build go1.20
//
// NOTE(sr): Different go runtime metrics on 1.20 vs 1.22.
// Let's only test these on 1.22.
//go:build go1.22

package prometheus

Expand Down Expand Up @@ -137,6 +136,13 @@ func TestJSONSerialization(t *testing.T) {
"go_godebug_non_default_behavior_x509usefallbackroots_events_total",
"go_godebug_non_default_behavior_zipinsecurepath_events_total",
"go_godebug_non_default_behavior_tlsmaxrsasize_events_total",
"go_godebug_non_default_behavior_gotypesalias_events_total", // BEGIN added in 1.22
"go_godebug_non_default_behavior_tlsunsafeekm_events_total",
"go_godebug_non_default_behavior_httplaxcontentlength_events_total",
"go_godebug_non_default_behavior_x509usepolicies_events_total",
"go_godebug_non_default_behavior_tls10server_events_total",
"go_godebug_non_default_behavior_httpmuxgo121_events_total",
"go_godebug_non_default_behavior_tlsrsakex_events_total",
},
"SUMMARY": {
"go_gc_duration_seconds",
Expand All @@ -146,6 +152,10 @@ func TestJSONSerialization(t *testing.T) {
"go_gc_heap_allocs_by_size_bytes", // was: "go_gc_heap_allocs_by_size_bytes_total"
"go_gc_heap_frees_by_size_bytes", // was: "go_gc_heap_frees_by_size_bytes_total"
"go_sched_latencies_seconds",
"go_sched_pauses_stopping_other_seconds", // BEGIN added in 1.22
"go_sched_pauses_stopping_gc_seconds",
"go_sched_pauses_total_gc_seconds",
"go_sched_pauses_total_other_seconds",
},
}
found := 0
Expand Down
6 changes: 0 additions & 6 deletions topdown/tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"encoding/json"
"fmt"
"os"
"runtime"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -472,12 +471,7 @@ func TestTopdownJWTEncodeSignECWithSeedReturnsSameSignature(t *testing.T) {
"d":"jpsQnnGQmL-YBIffH1136cspYG6-0iY7X1fCE9-E9LI"
}, x)`

// go1.20 and beyond
encodedSigned := "eyJhbGciOiAiRVMyNTYifQ.eyJwYXkiOiAibG9hZCJ9.GRp6wIqDZuYnvQH50hnIy559LdrjUux76v1ynxX6lH0XtlgwreyR16x2JMnuElo79X3zUbqlWrZITICv86arew"
if strings.HasPrefix(runtime.Version(), "go1.19") { // we don't use go1.18 anymore
encodedSigned = "eyJhbGciOiAiRVMyNTYifQ.eyJwYXkiOiAibG9hZCJ9.05wmHY3NomU1jr7yvusBvKwhthRklPuJhUPOkoeIn5e5n_GXvE25EfRs9AJK2wOy6NoY2ljhj07M9BMtV0dfyA"
}

for i := 0; i < 10; i++ {
q := NewQuery(ast.MustParseBody(query)).
WithSeed(&cng{}).
Expand Down

0 comments on commit 95dec3a

Please sign in to comment.