Skip to content

Commit a719f8a

Browse files
authored
feat: pr github action workflow (#96)
* feat: pr github action workflow Signed-off-by: Skye Gill <[email protected]> * check if bump go version fixes linter Signed-off-by: Skye Gill <[email protected]> * make test Signed-off-by: Skye Gill <[email protected]> * fix tar path Signed-off-by: Skye Gill <[email protected]> * bump dependency to remove vulnerability Signed-off-by: Skye Gill <[email protected]> Signed-off-by: Skye Gill <[email protected]>
1 parent 6016669 commit a719f8a

File tree

5 files changed

+99
-3
lines changed

5 files changed

+99
-3
lines changed

.github/workflows/pr-checks.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
env:
9+
# Default minimum version of Go to support.
10+
DEFAULT_GO_VERSION: 1.18
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Install Go
16+
uses: actions/setup-go@v3
17+
with:
18+
go-version: ${{ env.DEFAULT_GO_VERSION }}
19+
- name: Checkout repository
20+
uses: actions/checkout@v3
21+
- name: Setup Environment
22+
run: |
23+
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
24+
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
25+
- name: Module cache
26+
uses: actions/cache@v3
27+
env:
28+
cache-name: go-mod-cache
29+
with:
30+
path: ~/go/pkg/mod
31+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }}
32+
- name: Run linter
33+
run: make lint
34+
35+
test:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Install Go
39+
uses: actions/setup-go@v3
40+
with:
41+
go-version: ${{ env.DEFAULT_GO_VERSION }}
42+
- name: Checkout repository
43+
uses: actions/checkout@v3
44+
- name: Setup Environment
45+
run: |
46+
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
47+
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
48+
- name: Module cache
49+
uses: actions/cache@v3
50+
env:
51+
cache-name: go-mod-cache
52+
with:
53+
path: ~/go/pkg/mod
54+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }}
55+
- name: Run tests
56+
run: make test
57+
- name: Upload coverage to Codecov
58+
uses: codecov/codecov-action@v3
59+
60+
docker-local:
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v3
65+
with:
66+
submodules: recursive
67+
- name: Set up QEMU
68+
uses: docker/setup-qemu-action@master
69+
with:
70+
platforms: all
71+
- name: Set up Docker Buildx
72+
id: buildx
73+
uses: docker/setup-buildx-action@master
74+
- name: Build
75+
uses: docker/build-push-action@v2
76+
with:
77+
context: .
78+
outputs: type=docker,dest=${{ github.workspace }}/open-feature-operator-local.tar
79+
tags: open-feature-operator-local:test
80+
- name: Run Trivy vulnerability scanner
81+
uses: aquasecurity/trivy-action@master
82+
with:
83+
input: /github/workspace/open-feature-operator-local.tar
84+
format: "template"
85+
template: "@/contrib/sarif.tpl"
86+
output: "trivy-results.sarif"
87+
severity: "CRITICAL,HIGH"
88+
- name: Upload Trivy scan results to GitHub Security tab
89+
uses: github/codeql-action/upload-sarif@v2
90+
with:
91+
sarif_file: "trivy-results.sarif"

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ vet: ## Run go vet against code.
6363
test: manifests generate fmt vet envtest ## Run tests.
6464
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
6565

66+
.PHONY: lint
67+
lint:
68+
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
69+
${GOPATH}/bin/golangci-lint run --deadline=3m --timeout=3m ./... # Run linters
70+
6671
##@ Build
6772

6873
.PHONY: build

controllers/suite_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
. "github.com/onsi/ginkgo"
2424
. "github.com/onsi/gomega"
2525
"k8s.io/client-go/kubernetes/scheme"
26-
"k8s.io/client-go/rest"
2726
"sigs.k8s.io/controller-runtime/pkg/client"
2827
"sigs.k8s.io/controller-runtime/pkg/envtest"
2928
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
@@ -38,7 +37,6 @@ import (
3837
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
3938

4039
var (
41-
cfg *rest.Config
4240
k8sClient client.Client
4341
testEnv *envtest.Environment
4442
)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ require (
6363
go.uber.org/atomic v1.10.0 // indirect
6464
go.uber.org/multierr v1.8.0 // indirect
6565
golang.org/x/crypto v0.0.0-20220919173607-35f4265a4bc0 // indirect
66-
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b // indirect
66+
golang.org/x/net v0.0.0-20220906165146-f3363e06e74c // indirect
6767
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
6868
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect
6969
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,8 @@ golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su
712712
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
713713
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY=
714714
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
715+
golang.org/x/net v0.0.0-20220906165146-f3363e06e74c h1:yKufUcDwucU5urd+50/Opbt4AYpqthk7wHpHok8f1lo=
716+
golang.org/x/net v0.0.0-20220906165146-f3363e06e74c/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
715717
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
716718
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
717719
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=

0 commit comments

Comments
 (0)