diff --git a/.github/workflows/code-analysis.yml b/.github/workflows/code-analysis.yml new file mode 100644 index 000000000..fbb438c43 --- /dev/null +++ b/.github/workflows/code-analysis.yml @@ -0,0 +1,26 @@ +name: Static Analysis + +on: ["push"] + +jobs: + build: + name: Build and Analyze + runs-on: ubuntu-latest + steps: + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: '1.19' + - name: Clone Repository + uses: actions/checkout@master + - name: Analyze with SonarCloud + uses: sonarsource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + projectBaseDir: . + args: > + -Dsonar.organization=opensearch-go + -Dsonar.projectKey=zethuman_opensearch-go + -Dsonar.verbose=true \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7422aee3d..f7019a74a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,12 +1,9 @@ name: Lint check -on: - push: - branches: - - "*" - pull_request: - branches: - - "*" +on: ["push"] + +permissions: + contents: read env: GITHUB_ACTIONS: true @@ -18,15 +15,13 @@ jobs: steps: - uses: actions/checkout@v3 with: { fetch-depth: 1 } - - uses: actions/setup-go@v2 + - uses: actions/setup-go@v3 with: { go-version: '1.x' } - - name: Install dependencies - run: go install golang.org/x/lint/golint@latest - env: - GOBIN: ${{ env.GOROOT }}/bin - shell: bash - - run: go version - - run: make lint + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.52.2 + args: -v -c .golangci.yml prettify: name: Prettify diff --git a/.golangci.yml b/.golangci.yml index ecde6ec80..2ef1b24d6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,6 @@ run: modules-download-mode: readonly - issues-exit-code: 0 + issues-exit-code: 2 linters-settings: exhaustive: diff --git a/CHANGELOG.md b/CHANGELOG.md index 69c74688f..6ab46422c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,7 +32,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Adds `index_template` guide ([#289](https://github.com/opensearch-project/opensearch-go/pull/289)) - Adds `advanced_index_actions` guide ([#288](https://github.com/opensearch-project/opensearch-go/pull/288)) - Adds testcases to check UpdateByQuery functionality ([#304](https://github.com/opensearch-project/opensearch-go/pull/304)) -- Adds additional timeout after cluster start ([##303](https://github.com/opensearch-project/opensearch-go/pull/303)) +- Adds additional timeout after cluster start ([#303](https://github.com/opensearch-project/opensearch-go/pull/303)) +- Adds Codacy as quality analysis tool ([#313](https://github.com/opensearch-project/opensearch-go/pull/313)) ### Changed diff --git a/README.md b/README.md index bd0260fc6..6a36876c8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,11 @@ -[![Go Reference](https://pkg.go.dev/badge/github.com/opensearch-project/opensearch-go.svg)](https://pkg.go.dev/github.com/opensearch-project/opensearch-go/v2) [![Build](https://github.com/opensearch-project/opensearch-go/actions/workflows/lint.yml/badge.svg)](https://github.com/opensearch-project/opensearch-go/actions/workflows/lint.yml) [![Unit](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-unit.yml/badge.svg)](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-unit.yml) [![Integration](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-integration.yml/badge.svg)](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-integration.yml) [![codecov](https://codecov.io/gh/opensearch-project/opensearch-go/branch/main/graph/badge.svg?token=MI9g3KYHVx)](https://codecov.io/gh/opensearch-project/opensearch-go) [![Chat](https://img.shields.io/badge/chat-on%20forums-blue)](https://discuss.opendistrocommunity.dev/c/clients/) ![PRs welcome!](https://img.shields.io/badge/PRs-welcome!-success) +[![Go Reference](https://pkg.go.dev/badge/github.com/opensearch-project/opensearch-go.svg)](https://pkg.go.dev/github.com/opensearch-project/opensearch-go/v2) +[![Build](https://github.com/opensearch-project/opensearch-go/actions/workflows/lint.yml/badge.svg)](https://github.com/opensearch-project/opensearch-go/actions/workflows/lint.yml) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/a6371b0f281142a0b30a9c537d9fdb7e)](https://app.codacy.com/gh/zethuman/opensearch-go/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) +[![Unit](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-unit.yml/badge.svg)](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-unit.yml) +[![Integration](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-integration.yml/badge.svg)](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-integration.yml) +[![codecov](https://codecov.io/gh/opensearch-project/opensearch-go/branch/main/graph/badge.svg?token=MI9g3KYHVx)](https://codecov.io/gh/opensearch-project/opensearch-go) +[![Chat](https://img.shields.io/badge/chat-on%20forums-blue)](https://discuss.opendistrocommunity.dev/c/clients/) +![PRs welcome!](https://img.shields.io/badge/PRs-welcome!-success) ![OpenSearch logo](OpenSearch.svg) @@ -12,7 +19,10 @@ OpenSearch Go Client ## Welcome! -**opensearch-go** is [a community-driven, open source fork](https://aws.amazon.com/blogs/opensource/introducing-opensearch/) of go-elasticsearch licensed under the [Apache v2.0 License](LICENSE.txt). For more information, see [opensearch.org](https://opensearch.org/). +**opensearch-go** is +[a community-driven, open source fork](https://aws.amazon.com/blogs/opensource/introducing-opensearch/) +of go-elasticsearch licensed under the [Apache v2.0 License](LICENSE.txt). For +more information, see [opensearch.org](https://opensearch.org/). ## Project Resources @@ -31,7 +41,12 @@ OpenSearch Go Client ## Code of Conduct -This project has adopted the [Amazon Open Source Code of Conduct](CODE_OF_CONDUCT.md). For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq), or contact [opensource-codeofconduct@amazon.com](mailto:opensource-codeofconduct@amazon.com) with any additional questions or comments. +This project has adopted the +[Amazon Open Source Code of Conduct](CODE_OF_CONDUCT.md). For more information +see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq), or +contact +[opensource-codeofconduct@amazon.com](mailto:opensource-codeofconduct@amazon.com) +with any additional questions or comments. ## License