Skip to content

Commit

Permalink
Add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
0Tech committed Jan 25, 2024
1 parent 89e2f28 commit c9b971f
Show file tree
Hide file tree
Showing 10 changed files with 178 additions and 15 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/module.yml
Original file line number Diff line number Diff line change
@@ -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 }}/
18 changes: 18 additions & 0 deletions .github/workflows/modules.yml
Original file line number Diff line number Diff line change
@@ -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] }}
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 12 additions & 3 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ./...
Expand Down
15 changes: 12 additions & 3 deletions cmd/and/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ./...
Expand Down
13 changes: 13 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -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
17 changes: 13 additions & 4 deletions x/escrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
)

Expand Down
17 changes: 17 additions & 0 deletions x/escrow/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -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
17 changes: 13 additions & 4 deletions x/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
)

Expand Down
17 changes: 17 additions & 0 deletions x/test/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c9b971f

Please sign in to comment.