From 612468d739cd80eac0250b0a7d451d684809ba55 Mon Sep 17 00:00:00 2001 From: "chopin.fan" Date: Thu, 27 Jun 2024 09:42:59 +0800 Subject: [PATCH 01/12] Add a SonarQube configuration file to implement static code analysis. --- .github/workflows/sonarqube.yaml | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/sonarqube.yaml diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml new file mode 100644 index 0000000000..0209b437e1 --- /dev/null +++ b/.github/workflows/sonarqube.yaml @@ -0,0 +1,42 @@ +on: + pull_request: + types: [opened, synchronize, reopened] + +name: PR Static Code Analysis +jobs: + static-code-analysis: + runs-on: ubuntu-latest + steps: + - name: Code Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '7.0' + - name: Set up JDK 17 + uses: actions/setup-java@v1 + with: + java-version: 17 + - name: Cache SonarQube packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache SonarQube scanner + id: cache-sonar-scanner + uses: actions/cache@v1 + with: + path: ./.sonar/scanner + key: ${{ runner.os }}-sonar-scanner + restore-keys: ${{ runner.os }}-sonar-scanner + - name: Install SonarScanner for .NET + run: dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner + - name: Add .NET global tools to PATH + run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH + - name: Begin SonarQube analysis + run: | + ./.sonar/scanner/dotnet-sonarscanner begin /k:"AElf" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" + dotnet build + ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file From 8010f68613d900029d12286927de3ccf010cef9b Mon Sep 17 00:00:00 2001 From: "chopin.fan" Date: Thu, 27 Jun 2024 14:35:00 +0800 Subject: [PATCH 02/12] To clarify the specific project to be built. --- .github/workflows/sonarqube.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 0209b437e1..4f021c18b0 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -38,5 +38,5 @@ jobs: - name: Begin SonarQube analysis run: | ./.sonar/scanner/dotnet-sonarscanner begin /k:"AElf" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" - dotnet build - ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file + dotnet build AElf.All.sln + ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" From 98846f27a59c747a1a24ade0be29a6938405c369 Mon Sep 17 00:00:00 2001 From: "chopin.fan" Date: Thu, 27 Jun 2024 14:50:24 +0800 Subject: [PATCH 03/12] Add protobuf in sonarqube.yaml --- .github/workflows/sonarqube.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 4f021c18b0..19c1f8357b 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -35,8 +35,10 @@ jobs: run: dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner - name: Add .NET global tools to PATH run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH + - name: Install protobuf + run: sudo apt-get update && sudo apt-get install -y protobuf-compiler - name: Begin SonarQube analysis run: | ./.sonar/scanner/dotnet-sonarscanner begin /k:"AElf" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" dotnet build AElf.All.sln - ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" + ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file From 784bcb5a0d02ff65eebf80edf4525662aa8c4669 Mon Sep 17 00:00:00 2001 From: "chopin.fan" Date: Thu, 27 Jun 2024 15:01:24 +0800 Subject: [PATCH 04/12] Change the version of Protobuf to 3.19.4 --- .github/workflows/sonarqube.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 19c1f8357b..d4066c57ad 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -35,8 +35,10 @@ jobs: run: dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner - name: Add .NET global tools to PATH run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH - - name: Install protobuf - run: sudo apt-get update && sudo apt-get install -y protobuf-compiler + - name: Install Protoc + uses: arduino/setup-protoc@v3 + with: + version: "19.4" - name: Begin SonarQube analysis run: | ./.sonar/scanner/dotnet-sonarscanner begin /k:"AElf" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" From 66de35c0b59b8a017198007eb101f7521d364769 Mon Sep 17 00:00:00 2001 From: "chopin.fan" Date: Thu, 27 Jun 2024 15:03:40 +0800 Subject: [PATCH 05/12] Change the version of Protobuf to 3.19.4 --- .github/workflows/sonarqube.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index d4066c57ad..abc7545e76 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -38,7 +38,7 @@ jobs: - name: Install Protoc uses: arduino/setup-protoc@v3 with: - version: "19.4" + version: "3.19.4" - name: Begin SonarQube analysis run: | ./.sonar/scanner/dotnet-sonarscanner begin /k:"AElf" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" From 6b701bff8a99afbd7703fda35d8d03a535288653 Mon Sep 17 00:00:00 2001 From: "chopin.fan" Date: Thu, 27 Jun 2024 15:11:33 +0800 Subject: [PATCH 06/12] Change the version of Protobuf to 3.19.4 --- .github/workflows/sonarqube.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index abc7545e76..29ec611228 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -35,10 +35,10 @@ jobs: run: dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner - name: Add .NET global tools to PATH run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH - - name: Install Protoc - uses: arduino/setup-protoc@v3 - with: - version: "3.19.4" + - name: Install Protobuf 3.19.4 + run: | + sudo apt-get update + sudo apt-get install -y protobuf-compiler=3.19.4 - name: Begin SonarQube analysis run: | ./.sonar/scanner/dotnet-sonarscanner begin /k:"AElf" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" From 54d980ee2c0cab70df6ee42d0442c8a689baaefe Mon Sep 17 00:00:00 2001 From: "chopin.fan" Date: Thu, 27 Jun 2024 15:13:26 +0800 Subject: [PATCH 07/12] Change the version of Protobuf to 3.19.4 --- .github/workflows/sonarqube.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 29ec611228..1f70cc8d32 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -38,7 +38,7 @@ jobs: - name: Install Protobuf 3.19.4 run: | sudo apt-get update - sudo apt-get install -y protobuf-compiler=3.19.4 + sudo apt-get install -y protobuf-compiler=3.19.4-1 - name: Begin SonarQube analysis run: | ./.sonar/scanner/dotnet-sonarscanner begin /k:"AElf" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" From 9f3b2766b6d9825dc545b27985af4f4431fc997a Mon Sep 17 00:00:00 2001 From: "chopin.fan" Date: Thu, 27 Jun 2024 15:35:22 +0800 Subject: [PATCH 08/12] Change the version of Protobuf to 3.19.4 --- .github/workflows/sonarqube.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 1f70cc8d32..32bcb0fbd2 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -35,10 +35,11 @@ jobs: run: dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner - name: Add .NET global tools to PATH run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH - - name: Install Protobuf 3.19.4 + - name: Install Protobuf for C# run: | - sudo apt-get update - sudo apt-get install -y protobuf-compiler=3.19.4-1 + dotnet tool install --global Grpc.Tools --version 2.51.0 + dotnet tool install --global Google.Protobuf.Tools --version 3.19.4 + echo "$HOME/.dotnet/tools" >> $GITHUB_PATH - name: Begin SonarQube analysis run: | ./.sonar/scanner/dotnet-sonarscanner begin /k:"AElf" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" From 4006f5b2239442372183175aa918e90cdbe24c5c Mon Sep 17 00:00:00 2001 From: "chopin.fan" Date: Thu, 27 Jun 2024 15:38:45 +0800 Subject: [PATCH 09/12] Change the version of Protobuf to 3.19.4 --- .github/workflows/sonarqube.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 32bcb0fbd2..19c1f8357b 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -35,11 +35,8 @@ jobs: run: dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner - name: Add .NET global tools to PATH run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH - - name: Install Protobuf for C# - run: | - dotnet tool install --global Grpc.Tools --version 2.51.0 - dotnet tool install --global Google.Protobuf.Tools --version 3.19.4 - echo "$HOME/.dotnet/tools" >> $GITHUB_PATH + - name: Install protobuf + run: sudo apt-get update && sudo apt-get install -y protobuf-compiler - name: Begin SonarQube analysis run: | ./.sonar/scanner/dotnet-sonarscanner begin /k:"AElf" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" From 6540d8fba5d1be51d345d638e00b4fef6247018d Mon Sep 17 00:00:00 2001 From: "chopin.fan" Date: Thu, 27 Jun 2024 15:44:16 +0800 Subject: [PATCH 10/12] Change dotnet-version to 6. --- .github/workflows/sonarqube.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 19c1f8357b..cf33b0dd86 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -13,7 +13,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '7.0' + dotnet-version: '6.0' - name: Set up JDK 17 uses: actions/setup-java@v1 with: From b41e056de354f631fc0deec35d3df639f29e50bd Mon Sep 17 00:00:00 2001 From: "chopin.fan" Date: Thu, 27 Jun 2024 16:04:54 +0800 Subject: [PATCH 11/12] dotnet-version: '6.0' -> dotnet-version: '7.0' --- .github/workflows/sonarqube.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index cf33b0dd86..19c1f8357b 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -13,7 +13,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0' + dotnet-version: '7.0' - name: Set up JDK 17 uses: actions/setup-java@v1 with: From 39d6aa122c268803ba7b8a348270bda1e374f444 Mon Sep 17 00:00:00 2001 From: "chopin.fan" Date: Thu, 27 Jun 2024 16:16:40 +0800 Subject: [PATCH 12/12] Change the version of Protobuf to 3.19.4 --- .github/workflows/sonarqube.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 19c1f8357b..01e315a740 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -14,6 +14,8 @@ jobs: - uses: actions/setup-dotnet@v4 with: dotnet-version: '7.0' + - name: Create temporary global.json + run: echo '{"sdk":{"version":"7.0.410"}}' > ./global.json - name: Set up JDK 17 uses: actions/setup-java@v1 with: @@ -41,4 +43,7 @@ jobs: run: | ./.sonar/scanner/dotnet-sonarscanner begin /k:"AElf" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" dotnet build AElf.All.sln - ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file + ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" + + + \ No newline at end of file