diff --git a/.github/workflows/module.yml b/.github/workflows/module.yml new file mode 100644 index 0000000..11dd058 --- /dev/null +++ b/.github/workflows/module.yml @@ -0,0 +1,61 @@ +name: Check Module +on: + workflow_call: + inputs: + name: + required: true + type: string + secrets: + sonar-token: + required: true +env: + id: x-${{ inputs.name }} + path: x/${{ inputs.name }} +jobs: + lint: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.21' + - name: Configure + run: cmake -S . -B build + - name: Lint + run: cmake --build build --target lint_${{ env.id }} + build: + name: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.21' + - name: Configure + run: cmake -S . -B build + - name: Build + run: cmake --build build --target build_${{ env.id }} + test: + name: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - uses: actions/setup-go@v5 + with: + go-version: '1.21' + - name: Configure + run: cmake -S . -B build + - name: Test + run: | + VERBOSE=1 ctest --test-dir build --output-on-failure --stop-on-failure -R ${{ env.id }} + mv build/${{ env.path }}/cover.out ${{ env.path }}/ + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.sonar-token }} + with: + projectBaseDir: ${{ env.path }}/ diff --git a/.github/workflows/modules.yml b/.github/workflows/modules.yml new file mode 100644 index 0000000..01bb656 --- /dev/null +++ b/.github/workflows/modules.yml @@ -0,0 +1,18 @@ +name: Check Modules +on: + pull_request: +jobs: + check-modules: + name: check modules + strategy: + matrix: + include: + - name: test + sonar-token: SONAR_TOKEN_X_TEST + - name: escrow + sonar-token: SONAR_TOKEN_X_ESCROW + uses: ./.github/workflows/module.yml + with: + name: ${{ matrix.name }} + secrets: + sonar-token: ${{ secrets[matrix.sonar-token] }} diff --git a/CMakeLists.txt b/CMakeLists.txt index f085828..d15bff7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,9 @@ enable_testing() # go add_custom_target(tidy) -add_custom_target(lint) +add_custom_target(lint_fix) add_custom_target(build ALL) +add_custom_target(lint) # buf add_custom_target(buf_build) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index b65116a..af2179b 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -11,13 +11,13 @@ add_dependencies(tidy tidy_app ) -add_custom_target(lint_app +add_custom_target(lint_fix_app COMMAND golangci-lint run --fix WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM ) -add_dependencies(lint - lint_app +add_dependencies(lint_fix + lint_fix_app ) add_custom_target(build_app @@ -29,6 +29,15 @@ add_dependencies(build build_app ) +add_custom_target(lint_app + COMMAND golangci-lint run + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM +) +add_dependencies(lint + lint_app +) + add_test( NAME app COMMAND go test ./... diff --git a/cmd/and/CMakeLists.txt b/cmd/and/CMakeLists.txt index aa1951f..ab120cd 100644 --- a/cmd/and/CMakeLists.txt +++ b/cmd/and/CMakeLists.txt @@ -11,13 +11,13 @@ add_dependencies(tidy tidy_and ) -add_custom_target(lint_and +add_custom_target(lint_fix_and COMMAND golangci-lint run --fix WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM ) -add_dependencies(lint - lint_and +add_dependencies(lint_fix + lint_fix_and ) add_custom_target(build_and @@ -29,6 +29,15 @@ add_dependencies(build build_and ) +add_custom_target(lint_and + COMMAND golangci-lint run + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM +) +add_dependencies(lint + lint_and +) + add_test( NAME and COMMAND go test ./... diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..a9caa7d --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=0tech_andromeda +sonar.organization=0tech + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=0tech_andromeda +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 diff --git a/x/escrow/CMakeLists.txt b/x/escrow/CMakeLists.txt index c894a17..14957fb 100644 --- a/x/escrow/CMakeLists.txt +++ b/x/escrow/CMakeLists.txt @@ -11,13 +11,13 @@ add_dependencies(tidy tidy_x-escrow ) -add_custom_target(lint_x-escrow +add_custom_target(lint_fix_x-escrow COMMAND golangci-lint run --fix WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM ) -add_dependencies(lint - lint_x-escrow +add_dependencies(lint_fix + lint_fix_x-escrow ) add_custom_target(build_x-escrow @@ -29,9 +29,18 @@ add_dependencies(build build_x-escrow ) +add_custom_target(lint_x-escrow + COMMAND golangci-lint run + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM +) +add_dependencies(lint + lint_x-escrow +) + add_test( NAME x-escrow - COMMAND go test ./... + COMMAND go test -coverprofile ${CMAKE_CURRENT_BINARY_DIR}/cover.out ./... WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/x/escrow/sonar-project.properties b/x/escrow/sonar-project.properties new file mode 100644 index 0000000..56fae18 --- /dev/null +++ b/x/escrow/sonar-project.properties @@ -0,0 +1,17 @@ +sonar.projectKey=0tech_andromeda_x-escrow +sonar.organization=0tech + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=andromeda - x/escrow +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. +sonar.inclusions=**/*.go +sonar.exclusions=api/**,**/*.pb.go,**/*.pb.gw.go,**/*_test.go +sonar.test.inclusions=**/*_test.go +sonar.go.coverage.reportPaths=cover.out + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 diff --git a/x/test/CMakeLists.txt b/x/test/CMakeLists.txt index 43c9e53..92b5900 100644 --- a/x/test/CMakeLists.txt +++ b/x/test/CMakeLists.txt @@ -11,13 +11,13 @@ add_dependencies(tidy tidy_x-test ) -add_custom_target(lint_x-test +add_custom_target(lint_fix_x-test COMMAND golangci-lint run --fix WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM ) -add_dependencies(lint - lint_x-test +add_dependencies(lint_fix + lint_fix_x-test ) add_custom_target(build_x-test @@ -29,9 +29,18 @@ add_dependencies(build build_x-test ) +add_custom_target(lint_x-test + COMMAND golangci-lint run + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM +) +add_dependencies(lint + lint_x-test +) + add_test( NAME x-test - COMMAND go test ./... + COMMAND go test -coverprofile ${CMAKE_CURRENT_BINARY_DIR}/cover.out ./... WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/x/test/sonar-project.properties b/x/test/sonar-project.properties new file mode 100644 index 0000000..999cda4 --- /dev/null +++ b/x/test/sonar-project.properties @@ -0,0 +1,17 @@ +sonar.projectKey=0tech_andromeda_x-test +sonar.organization=0tech + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=andromeda - x/test +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. +sonar.inclusions=**/*.go +sonar.exclusions=api/**,**/*.pb.go,**/*.pb.gw.go,**/*_test.go +sonar.test.inclusions=**/*_test.go +sonar.go.coverage.reportPaths=cover.out + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8