-
Notifications
You must be signed in to change notification settings - Fork 20
KUBESAW-230: add test gh action for pairing mechanism #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rsoaresd
wants to merge
4
commits into
codeready-toolchain:master
Choose a base branch
from
rsoaresd:add_test_gh_action_for_pairing_mechanism
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
34bb9d3
add test gh action for pairing mechanism
rsoaresd 98d62d9
Merge branch 'master' into add_test_gh_action_for_pairing_mechanism
rsoaresd 2e5ff2f
requested changes
rsoaresd 85630d4
Merge branch 'master' into add_test_gh_action_for_pairing_mechanism
rsoaresd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| name: Build & Test Pairing | ||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| tags-ignore: | ||
| - "*.*" | ||
| paths: | ||
| - "pairing/**" | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| paths: | ||
| - "pairing/**" | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ${{ matrix.os }} | ||
| defaults: | ||
| run: | ||
| working-directory: ./pairing | ||
| strategy: | ||
| matrix: | ||
| os: [ ubuntu-latest ] | ||
| name: Test | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: ./pairing/go.mod | ||
|
|
||
| - name: Cache dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/go/pkg/mod | ||
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-go- | ||
|
|
||
| - name: Lint | ||
| uses: golangci/golangci-lint-action@v8 | ||
| with: | ||
| version: v2.1.6 | ||
| skip-pkg-cache: true | ||
| skip-build-cache: true | ||
| working-directory: ./pairing | ||
| args: --config=./.golangci.yml --verbose | ||
|
|
||
| - name: Test | ||
| run: | | ||
| make test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| version: "2" | ||
| linters: | ||
| enable: | ||
| - asasalint | ||
| - asciicheck | ||
| - bidichk | ||
| - bodyclose | ||
| - durationcheck | ||
| - errchkjson | ||
| - errorlint | ||
| - exhaustive | ||
| - gocheckcompilerdirectives | ||
| - gochecksumtype | ||
| - gocyclo | ||
| - gosec | ||
| - gosmopolitan | ||
| - loggercheck | ||
| - makezero | ||
| - misspell | ||
| - musttag | ||
| - nilerr | ||
| - nilnesserr | ||
| - protogetter | ||
| - reassign | ||
| - recvcheck | ||
| - revive | ||
| - rowserrcheck | ||
| - spancheck | ||
| - sqlclosecheck | ||
| - testifylint | ||
| - unparam | ||
| - zerologlint | ||
| disable: | ||
| - contextcheck | ||
| - noctx | ||
| settings: | ||
| revive: | ||
| rules: | ||
| - name: dot-imports | ||
| disabled: true | ||
| unparam: | ||
| check-exported: true | ||
| exclusions: | ||
| generated: lax | ||
| presets: | ||
| - comments | ||
| - common-false-positives | ||
| - legacy | ||
| - std-error-handling | ||
| paths: | ||
| - third_party$ | ||
| - builtin$ | ||
| - examples$ | ||
| formatters: | ||
| enable: | ||
| - gofmt | ||
| exclusions: | ||
| generated: lax | ||
| paths: | ||
| - third_party$ | ||
| - builtin$ | ||
| - examples$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # It's necessary to set this because some environments don't link sh -> bash. | ||
| SHELL := /bin/bash | ||
|
|
||
| include ./make/*.mk | ||
| .DEFAULT_GOAL := help | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package dummy | ||
|
|
||
| func Add(a, b int) int { | ||
| return a + b | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package dummy | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestAdd(t *testing.T) { | ||
| result := Add(2, 3) | ||
|
|
||
| assert.Equal(t, 5, result) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| module github.com/codeready-toolchain/pairing | ||
|
|
||
| go 1.22.12 | ||
|
|
||
| require github.com/stretchr/testify v1.10.0 | ||
|
|
||
| require ( | ||
| github.com/davecgh/go-spew v1.1.1 // indirect | ||
| github.com/pmezard/go-difflib v1.0.0 // indirect | ||
| gopkg.in/yaml.v3 v3.0.1 // indirect | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
| github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= | ||
| github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | ||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/codeready-toolchain/pairing/dummy" | ||
| ) | ||
|
|
||
| func main() { | ||
| result := dummy.Add(2, 3) | ||
| fmt.Printf("2 + 3 = %d\n", result) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| GO_PACKAGE_ORG_NAME ?= codeready-toolchain | ||
| GO_PACKAGE_REPO_NAME ?= pairing | ||
| GO_PACKAGE_PATH ?= github.com/${GO_PACKAGE_ORG_NAME}/${GO_PACKAGE_REPO_NAME} | ||
| goarch ?= amd64 | ||
|
|
||
| BIN_DIR = $(OUT_DIR)/bin | ||
| .PHONY: build | ||
| ## Build the operator | ||
| build: GO_COMMAND=build | ||
| build: GO_EXTRA_FLAGS=-o $(BIN_DIR)/ | ||
| build: clean-bin run-go | ||
|
|
||
| .PHONY: install | ||
| ## installs the binary executable | ||
| install: GO_COMMAND=install | ||
| install: run-go | ||
|
|
||
| run-go: | ||
| $(Q)CGO_ENABLED=0 \ | ||
| env GOOS=linux GOARCH=${goarch} go ${GO_COMMAND} ${V_FLAG} \ | ||
| -ldflags "-X ${GO_PACKAGE_PATH}/pkg/version.Commit=${GIT_COMMIT_ID} -X ${GO_PACKAGE_PATH}/pkg/version.BuildTime=${BUILD_TIME}" \ | ||
| ${GO_EXTRA_FLAGS} ${GO_PACKAGE_PATH}/... | ||
|
|
||
| .PHONY: lint | ||
| lint: | ||
| ifeq (, $(shell which golangci-lint 2>/dev/null)) | ||
| $(error "golangci-lint not found in PATH. Please install it using instructions on https://golangci-lint.run/usage/install/#local-installation") | ||
| endif | ||
| golangci-lint ${V_FLAG} run --config=./.golangci.yml --verbose ./... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| .PHONY: clean | ||
| clean: clean-bin | ||
| $(Q)-rm -rf ${V_FLAG} ./vendor | ||
| $(Q)-rm -rf ($COV_DIR) | ||
| $(Q)go clean ${X_FLAG} ./... | ||
|
|
||
| .PHONY: clean-bin | ||
| clean-bin: | ||
| @rm -rf $(BIN_DIR) 2>/dev/null || true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Create output directory for artifacts and test results. `./build/_output` is supposed to | ||
| # be a safe place for all targets to write to while knowing that all content | ||
| # inside of `./build/_output` is wiped once "make clean" is run. | ||
| OUT_DIR := ./build/_output | ||
| $(shell mkdir -p $(OUT_DIR)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| .PHONY: test | ||
| test: build | ||
| @echo "running the pairing unit tests..." | ||
| go test -v -failfast ./... | ||
rsoaresd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| # Output directory for coverage information | ||
| COV_DIR = $(OUT_DIR)/coverage | ||
|
|
||
| .PHONY: test-with-coverage | ||
| ## runs the tests with coverage | ||
| test-with-coverage: | ||
| @echo "running the unit tests with coverage..." | ||
| @-mkdir -p $(COV_DIR) | ||
| @-rm $(COV_DIR)/coverage.txt | ||
| $(Q)go test -vet off ${V_FLAG} $(shell go list ./... | grep -v /cmd/manager) -coverprofile=$(COV_DIR)/coverage.txt -covermode=atomic ./... | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # When you run make VERBOSE=1 (the default), executed commands will be printed | ||
| # before executed. If you run make VERBOSE=2 verbose flags are turned on and | ||
| # quiet flags are turned off for various commands. Use V_FLAG in places where | ||
| # you can toggle on/off verbosity using -v. Use Q_FLAG in places where you can | ||
| # toggle on/off quiet mode using -q. Use S_FLAG where you want to toggle on/off | ||
| # silence mode using -s... | ||
| VERBOSE ?= 1 | ||
| Q = @ | ||
| Q_FLAG = -q | ||
| QUIET_FLAG = --quiet | ||
| V_FLAG = | ||
| S_FLAG = -s | ||
| X_FLAG = | ||
| ifeq ($(VERBOSE),1) | ||
| Q = | ||
| endif | ||
| ifeq ($(VERBOSE),2) | ||
| Q = | ||
| Q_FLAG = | ||
| QUIET_FLAG = | ||
| S_FLAG = | ||
| V_FLAG = -v | ||
| X_FLAG = -x | ||
| endif |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.