Skip to content

Commit

Permalink
Remove build
Browse files Browse the repository at this point in the history
Signed-off-by: mehabhalodiya <[email protected]>
  • Loading branch information
mehabhalodiya committed Jan 24, 2024
1 parent 4ec2bde commit 9cd2d16
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 107 deletions.
44 changes: 9 additions & 35 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
# See http://docs.codecov.io/docs/coverage-configuration
coverage:
precision: 2 # 2 = xx.xx%, 0 = xx%
round: down
# For example: 20...60 would result in any coverage less than 20%
# would have a red background. The color would gradually change to
# green approaching 60%. Any coverage over 60% would result in a
# solid green color.
range: "20...60"

status:
# project will give us the diff in the total code coverage between a commit
# and its parent
project: yes
# Patch gives just the coverage of the patch
patch: yes
# changes tells us if there are unexpected code co verage changes in other files
# which were not changed by the diff
changes: yes

# See http://docs.codecov.io/docs/ignoring-paths
ignore:
- "build/*"
- "hack/*"
- "openshift-ci/*"
- "Makefile"
- ".travis.yml"

# See http://docs.codecov.io/docs/pull-request-comments-1
comment:
layout: "diff, files"
behavior: ""
# default = posts once then update, posts new if delete
# once = post once then updates
# new = delete old, post new
# spammy = post new
status:
# Allows coverage to drop by a 3% when compared against the base commit.
project:
default:
target: auto
threshold: 3%
patch:
default:
informational: true
94 changes: 94 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Go
on:
push:
branches:
- "master"
pull_request:
branches:
- "master"
env:
# Golang version to use across CI steps
GOLANG_VERSION: '1.20'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
event_file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v4
with:
name: Event File
path: ${{ github.event_path }}
lint-go:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
name: Lint Go code
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/[email protected]
with:
go-version: ${{ env.GOLANG_VERSION }}
- name: Checkout code
uses: actions/checkout@v4
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.53.3
args: --timeout 6m
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/[email protected]
with:
go-version: ${{ env.GOLANG_VERSION }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Restore go build cache
uses: actions/cache@v4
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}

- name: Download all Go modules
run: |
go mod download
- name: Compile all packages
run: make controller plugin

- name: Test
run: make test-unit

- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Unit Test Results
path: |
junit.xml
- name: Generate code coverage artifacts
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: coverage.out

- name: Upload code coverage information to codecov.io
uses: codecov/[email protected]
with:
file: coverage.out
27 changes: 27 additions & 0 deletions .github/workflows/gosec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Go Test on Pull Requests
on: # yamllint disable-line rule:truthy
pull_request:
types:
- opened
- synchronize
- reopened
paths:
- '**.go'
workflow_dispatch:
jobs:
gosec:
name: Check GO security
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: -exclude-generated ./...
env:
GOROOT: ""
72 changes: 0 additions & 72 deletions .github/workflows/pr-checks.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Go Test on Pull Requests
on:
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
go:
name: Check sources
runs-on: ubuntu-20.04
env:
OPERATOR_SDK_VERSION: v1.18.0
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
docker:
name: Check docker build
runs-on: ubuntu-20.04
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check if dockerimage build is working
run: docker build -f ./Dockerfile .
gitlint:
name: Run gitlint checks
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Install gitlint into container
run: python -m pip install gitlint
- name: Run gitlint check
run: gitlint --commits origin/${{ github.event.pull_request.base.ref }}..HEAD
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ all: build
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

lint:
golangci-lint run

##@ Development

manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
Expand All @@ -90,6 +93,22 @@ fmt: ## Run go fmt against code.
vet: ## Run go vet against code.
go vet ./...

##@ Test

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out

.PHONY: test-unit
test-unit: install-devtools-local ## run unit tests
${DIST_DIR}/gotestsum --junitfile=junit.xml --format=testname -- -covermode=count -coverprofile=coverage.out `go list ./... | grep -v ./test/cmd/metrics-plugin-sample`


.PHONY: coverage
coverage: test ## run coverage tests
go tool cover -html=coverage.out -o coverage.html
open coverage.html

test-all: manifests generate fmt vet ## Run all tests.
go test -timeout 1h ./... -coverprofile cover.out

Expand Down

0 comments on commit 9cd2d16

Please sign in to comment.