Skip to content

Commit

Permalink
go.mk: standardize CI with other Go repos (#64)
Browse files Browse the repository at this point in the history
Co-authored-by: Philipp Sauter <[email protected]>
  • Loading branch information
sauterp and sauterp authored May 16, 2023
1 parent 07f3c69 commit e6bd846
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 86 deletions.
53 changes: 0 additions & 53 deletions .github/workflows/ci.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on:
push:
branches:
- '**'
paths-ignore:
- '**.md'
tags-ignore:
- 'v**' # Don't run CI tests on release tags

jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: git submodule update --init --recursive go.mk
- uses: ./go.mk/.github/actions/setup

- uses: ./go.mk/.github/actions/pre-check

- name: Run tests
run: make test-verbose

build:
needs: unit-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: git submodule update --init --recursive go.mk
- uses: ./go.mk/.github/actions/setup
- name: Build
run: make build

docker-build:
needs: unit-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: git submodule update --init --recursive go.mk
- uses: ./go.mk/.github/actions/setup
- name: Build Docker image
run: make docker
2 changes: 0 additions & 2 deletions .golangci.yml

This file was deleted.

5 changes: 3 additions & 2 deletions cmd/exoscale-cloud-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"time"

"github.com/exoscale/exoscale-cloud-controller-manager/exoscale"
"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/util/wait"
cloudprovider "k8s.io/cloud-provider"
Expand All @@ -17,6 +16,8 @@ import (
_ "k8s.io/component-base/metrics/prometheus/clientgo" // load all the prometheus client-go plugins
_ "k8s.io/component-base/metrics/prometheus/version" // for version metric registration
"k8s.io/klog/v2"

"github.com/exoscale/exoscale-cloud-controller-manager/exoscale"
)

func main() {
Expand Down Expand Up @@ -54,7 +55,7 @@ func main() {
})

if err := command.Execute(); err != nil {
os.Exit(1)
os.Exit(1) //nolint:gocritic
}
}

Expand Down
3 changes: 2 additions & 1 deletion exoscale/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"sync"

egoscale "github.com/exoscale/egoscale/v2"

"gopkg.in/fsnotify.v1"
)

Expand Down Expand Up @@ -51,7 +52,7 @@ func newRefreshableExoscaleClient(ctx context.Context, config *globalConfig) (*r
c.apiEnvironment = config.ApiEnvironment
}

if config.ApiKey != "" && config.ApiSecret != "" {
if config.ApiKey != "" && config.ApiSecret != "" { //nolint:gocritic
infof("using Exoscale actual API credentials (key + secret)")

c.apiCredentials = exoscaleAPICredentials{
Expand Down
1 change: 1 addition & 0 deletions exoscale/client_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

egoscale "github.com/exoscale/egoscale/v2"

"github.com/stretchr/testify/mock"
)

Expand Down
1 change: 1 addition & 0 deletions exoscale/exoscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"

egoscale "github.com/exoscale/egoscale/v2"

"k8s.io/client-go/kubernetes"
cloudprovider "k8s.io/cloud-provider"
"k8s.io/klog/v2"
Expand Down
6 changes: 3 additions & 3 deletions exoscale/exoscale_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ var (
ApiKey: testAPIKey,
ApiSecret: testAPISecret,
},
Instances: instancesConfig{
Instances: instancesConfig{
Overrides: []instancesOverrideConfig{{
Name: testInstanceOverrideRegexpName,
Name: testInstanceOverrideRegexpName,
External: true,
Type: testInstanceOverrideExternalType,
Type: testInstanceOverrideExternalType,
Addresses: []instancesOverrideAddressConfig{
{Type: "InternalIP", Address: testInstanceOverrideAddress_internal},
{Type: "ExternalIP", Address: testInstanceOverrideAddress_external},
Expand Down
5 changes: 3 additions & 2 deletions exoscale/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"fmt"
"regexp"

egoscale "github.com/exoscale/egoscale/v2"
exoapi "github.com/exoscale/egoscale/v2/api"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
cloudprovider "k8s.io/cloud-provider"
cloudproviderapi "k8s.io/cloud-provider/api"

egoscale "github.com/exoscale/egoscale/v2"
exoapi "github.com/exoscale/egoscale/v2/api"
)

// Label value must be '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
Expand Down
8 changes: 4 additions & 4 deletions exoscale/instances_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (c *instancesConfig) getInstanceOverride(nodeName types.NodeName) *instance
// first try an exact match on name
for _, candidate := range c.Overrides {
if candidate.Name != "" && nodeName == types.NodeName(candidate.Name) {
config = &candidate
config = &candidate //nolint:exportloopref
break
}
}
Expand All @@ -56,7 +56,7 @@ func (c *instancesConfig) getInstanceOverride(nodeName types.NodeName) *instance
continue
}
if match {
config = &candidate
config = &candidate //nolint:exportloopref
break
}
}
Expand All @@ -73,7 +73,7 @@ func (c *instancesConfig) getInstanceOverrideByProviderID(providerID string) *in
// first try an exact match on externalID
for _, candidate := range c.Overrides {
if candidate.ExternalID != "" && instanceID == candidate.ExternalID {
config = &candidate
config = &candidate //nolint:exportloopref
break
}
}
Expand All @@ -82,7 +82,7 @@ func (c *instancesConfig) getInstanceOverrideByProviderID(providerID string) *in
if config == nil {
for _, candidate := range c.Overrides {
if candidate.ExternalID == "" && instanceID == defaultInstanceOverrideExternalID(candidate.Name) {
config = &candidate
config = &candidate //nolint:exportloopref
break
}
}
Expand Down
14 changes: 7 additions & 7 deletions exoscale/instances_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (

var (
// Overrides
testInstanceOverrideType = "testInstanceType"
testInstanceOverrideType = "testInstanceType"
testInstanceOverrideAddress_internal = "192.0.2.42"
testInstanceOverrideAddress_external = "203.0.113.42"
testInstanceOverrideExternalName = "testOverrideInstanceExternal"
testInstanceOverrideExternalID = "testInstanceExternalID"
testInstanceOverrideExternalType = "testInstanceTypeExternal"
testInstanceOverrideExternalRegion = "testInstanceRegionExternal"
testInstanceOverrideRegexpName = "/^testOverrideInstanceRegexp.*/"
testInstanceOverrideRegexpNodeName = "testOverrideInstanceRegexpF00b@r"
testInstanceOverrideExternalName = "testOverrideInstanceExternal"
testInstanceOverrideExternalID = "testInstanceExternalID"
testInstanceOverrideExternalType = "testInstanceTypeExternal"
testInstanceOverrideExternalRegion = "testInstanceRegionExternal"
testInstanceOverrideRegexpName = "/^testOverrideInstanceRegexp.*/"
testInstanceOverrideRegexpNodeName = "testOverrideInstanceRegexpF00b@r"
testInstanceOverrideRegexpInstanceID = fmt.Sprintf("external-%x", sha256.Sum256([]byte(testInstanceOverrideRegexpName)))
testInstanceOverrideRegexpProviderID = fmt.Sprintf("%s://%s", ProviderName, testInstanceOverrideRegexpInstanceID)

Expand Down
5 changes: 3 additions & 2 deletions exoscale/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"fmt"
"net"

egoscale "github.com/exoscale/egoscale/v2"
exoapi "github.com/exoscale/egoscale/v2/api"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/fake"
cloudprovider "k8s.io/cloud-provider"

egoscale "github.com/exoscale/egoscale/v2"
exoapi "github.com/exoscale/egoscale/v2/api"

"k8s.io/utils/pointer"
)

Expand Down
6 changes: 3 additions & 3 deletions exoscale/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"strings"
"time"

egoscale "github.com/exoscale/egoscale/v2"
exoapi "github.com/exoscale/egoscale/v2/api"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
v1 "k8s.io/api/core/v1"
cloudprovider "k8s.io/cloud-provider"

egoscale "github.com/exoscale/egoscale/v2"
exoapi "github.com/exoscale/egoscale/v2/api"
)

const (
Expand Down Expand Up @@ -244,7 +245,6 @@ func (l *loadBalancer) updateLoadBalancer(ctx context.Context, service *v1.Servi
return err
}


if nlbUpdate.ID == nil {
return errLoadBalancerIDAnnotationNotFound
}
Expand Down
3 changes: 2 additions & 1 deletion exoscale/loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"testing"
"time"

egoscale "github.com/exoscale/egoscale/v2"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/fake"

egoscale "github.com/exoscale/egoscale/v2"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions exoscale/sks_agent_runner_node_csr_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"testing"
"time"

egoscale "github.com/exoscale/egoscale/v2"
"github.com/stretchr/testify/mock"
k8scertv1 "k8s.io/api/certificates/v1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -24,13 +23,15 @@ import (
certificatesv1 "k8s.io/client-go/kubernetes/typed/certificates/v1"
fakecertificatesv1 "k8s.io/client-go/kubernetes/typed/certificates/v1/fake"
"k8s.io/utils/pointer"

egoscale "github.com/exoscale/egoscale/v2"
)

func (ts *exoscaleCCMTestSuite) generateK8sCSR(nodeName string, nodeIPAddresses []string) []byte {
privateKey, err := rsa.GenerateKey(rand.Reader, 1024)
ts.Require().NoError(err, "failed to generate RSA private key")

var ipAddresses []net.IP
ipAddresses := make([]net.IP, 0, len(nodeIPAddresses))
for _, ip := range nodeIPAddresses {
ipAddresses = append(ipAddresses, net.ParseIP(ip))
}
Expand Down
2 changes: 1 addition & 1 deletion go.mk
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
k8s.io/cloud-provider v0.25.0
k8s.io/component-base v0.25.0
k8s.io/klog/v2 v2.70.1
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
)

require (
Expand Down Expand Up @@ -101,7 +102,6 @@ require (
k8s.io/component-helpers v0.25.0 // indirect
k8s.io/controller-manager v0.25.0 // indirect
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.32 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ github.com/go-playground/validator/v10 v10.9.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSG
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/goccy/go-json v0.7.8/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
Expand Down

0 comments on commit e6bd846

Please sign in to comment.