Skip to content

Commit 8d5c893

Browse files
authored
GH actions - PR tests and code coverage (#20)
* GH actions - PR tests * Add code owners
1 parent 8f255a4 commit 8d5c893

File tree

17 files changed

+125
-9
lines changed

17 files changed

+125
-9
lines changed

.github/.codecov.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# To validate:
2+
# cat codecov.yml | curl --data-binary @- https://codecov.io/validate
3+
4+
codecov:
5+
# Avoid "Missing base report"
6+
# https://docs.codecov.io/docs/comparing-commits
7+
allow_coverage_offsets: true
8+
notify:
9+
require_ci_to_pass: yes
10+
11+
coverage:
12+
precision: 2
13+
round: down
14+
range: "50...75"
15+
16+
status:
17+
project:
18+
default:
19+
threshold: 1
20+
unittest:
21+
threshold: 1
22+
only_pulls: true
23+
flags:
24+
- "unittest"
25+
# Disable patch since it is noisy and not correct
26+
patch:
27+
default:
28+
enabled: no
29+
if_not_found: success
30+
31+
comment: false
32+
33+
ignore:
34+
- "api/v1alpha1/**/*"
35+
- "hack/**/*"

.github/dependabot.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# See https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#package-ecosystem
2+
version: 2
3+
updates:
4+
- package-ecosystem: "gomod"
5+
directory: "/"
6+
schedule:
7+
interval: "monthly"

.github/workflows/pr-tests.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Automatic Pull Request test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "main"
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
unit-test:
13+
name: Unit test
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout latest commit in the PR
17+
uses: actions/checkout@v3
18+
- name: Set up Go
19+
uses: actions/setup-go@v3
20+
with:
21+
go-version: "1.20"
22+
- name: Set up tools
23+
run: |
24+
go install golang.org/x/lint/golint@latest
25+
go install golang.org/x/tools/cmd/goimports@latest
26+
- name: Run code checks
27+
run: |
28+
make check-format
29+
make vet
30+
- name: Build
31+
run: make build
32+
- name: Unit test
33+
run: make test
34+
- name: Upload code coverage
35+
uses: codecov/codecov-action@v3
36+
docker-build:
37+
name: Build Docker images
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout latest commit in the PR
41+
uses: actions/checkout@v3
42+
- name: Set up QEMU
43+
uses: docker/setup-qemu-action@v2
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v2
46+
- name: Set up Go
47+
uses: actions/setup-go@v3
48+
with:
49+
go-version: "1.20"
50+
- name: Build Network Policy Controller images
51+
run: make docker-buildx

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @aws/eks-networking

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,14 @@ GO_RUNNER_IMAGE=public.ecr.aws/eks-distro/kubernetes/go-runner:v0.15.0-eks-1-27-
176176
.PHONY: docker-buildx
177177
docker-buildx: test
178178
docker buildx build --platform=$(PLATFORMS) -t $(IMG)-$(GOARCH) --build-arg BASE_IMAGE=$(BASE_IMAGE) --build-arg BUILD_IMAGE=$(BUILD_IMAGE) --build-arg $(GOARCH) --load .
179+
180+
# Check formatting of source code files without modification.
181+
check-format: FORMAT_FLAGS = -l
182+
check-format: format
183+
184+
format: ## Format all Go source code files.
185+
@command -v goimports >/dev/null || { echo "ERROR: goimports not installed"; exit 1; }
186+
@exit $(shell find ./* \
187+
-type f \
188+
-name '*.go' \
189+
-print0 | sort -z | xargs -0 -- goimports $(or $(FORMAT_FLAGS),-w) | wc -l | bc)

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/eventhandlers/namespace.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package eventhandlers
22

33
import (
44
"context"
5+
56
"github.com/aws/amazon-network-policy-controller-k8s/pkg/k8s"
67
"github.com/aws/amazon-network-policy-controller-k8s/pkg/resolvers"
78

internal/eventhandlers/policy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ package eventhandlers
1818

1919
import (
2020
"context"
21-
"github.com/aws/amazon-network-policy-controller-k8s/pkg/resolvers"
2221
"time"
2322

23+
"github.com/aws/amazon-network-policy-controller-k8s/pkg/resolvers"
24+
2425
"github.com/aws/amazon-network-policy-controller-k8s/pkg/k8s"
2526
"github.com/go-logr/logr"
2627
networking "k8s.io/api/networking/v1"

internal/eventhandlers/service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package eventhandlers
1818

1919
import (
2020
"context"
21+
2122
"github.com/aws/amazon-network-policy-controller-k8s/pkg/k8s"
2223
"github.com/aws/amazon-network-policy-controller-k8s/pkg/resolvers"
2324
"github.com/go-logr/logr"

pkg/config/runtime_config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package config
22

33
import (
4+
"time"
5+
46
corev1 "k8s.io/api/core/v1"
57
"k8s.io/apimachinery/pkg/runtime"
68
"k8s.io/client-go/rest"
79
"k8s.io/client-go/tools/clientcmd"
810
ctrl "sigs.k8s.io/controller-runtime"
9-
"time"
1011

1112
"github.com/spf13/pflag"
1213
)

0 commit comments

Comments
 (0)