From 98fdcf83a9d76c281298084ea9597463522feed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AC=BC=E8=B0=B7=E5=AD=90?= <358683537@qq.com> Date: Thu, 19 Jan 2023 11:32:57 +0800 Subject: [PATCH] chore: add gitlab action --- .github/pull_request_template.md | 17 +++++ .github/workflows/Codecov.yml | 66 +++++++++++++++++++ .github/workflows/package_push_nuget.org.yml | 35 ++++++++++ .github/workflows/pr_run_test_ci.yml | 68 ++++++++++++++++++++ Masa.Blazor.Extensions.sln | 7 +- 5 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/Codecov.yml create mode 100644 .github/workflows/package_push_nuget.org.yml create mode 100644 .github/workflows/pr_run_test_ci.yml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..f91a373 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,17 @@ +# Description + +_Please explain the changes you've made_ + +## Issue reference + +We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation. + +Please reference the issue this PR will close: #_[issue number]_ + +## Checklist + +Please make sure you've completed the relevant tasks for this PR, out of the following list: + +* [ ] Code compiles correctly +* [ ] Created/updated tests +* [ ] Extended the documentation diff --git a/.github/workflows/Codecov.yml b/.github/workflows/Codecov.yml new file mode 100644 index 0000000..d1b5180 --- /dev/null +++ b/.github/workflows/Codecov.yml @@ -0,0 +1,66 @@ +name: Codecov +on: + push: + branches: + - 'main' + workflow_dispatch: + +jobs: + test: + name: codecov + runs-on: ubuntu-latest + + steps: + - name: git pull + uses: actions/checkout@v2 + + - name: run a one-line script + run: env + + - name: Configure sysctl limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 1.11 + + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~\sonar\cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache SonarCloud 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 SonarCloud scanner + run: | + dotnet tool install --global dotnet-sonarscanner + + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + dotnet-sonarscanner begin /k:"BlazorComponent_MASA.Blazor.Extensions" /o:"blazorcomponent" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + dotnet build /p:ContinuousIntegrationBuild=true + dotnet test --no-build --verbosity normal --collect "Code Coverage" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[*.Tests]*" + dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" + + - name: codecov + uses: codecov/codecov-action@v2 diff --git a/.github/workflows/package_push_nuget.org.yml b/.github/workflows/package_push_nuget.org.yml new file mode 100644 index 0000000..7f77130 --- /dev/null +++ b/.github/workflows/package_push_nuget.org.yml @@ -0,0 +1,35 @@ +name: Package Push Nuget +on: + release: + types: [published] + workflow_dispatch: + +jobs: + package-build: + name: package build and push + runs-on: ubuntu-latest + steps: + - name: git pull + uses: actions/checkout@v2 + + - name: run a one-line script + run: env + + - name: setting dotnet version + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '6.0.x' + include-prerelease: true + + - name: restore + run: dotnet restore + + - name: build + run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true + + - name: pack + run: dotnet pack --include-symbols -p:PackageVersion=$GITHUB_REF_NAME + + - name: package push + run: dotnet nuget push "**/*.symbols.nupkg" -k ${{secrets.NUGET_TOKEN}} -s https://api.nuget.org/v3/index.json + diff --git a/.github/workflows/pr_run_test_ci.yml b/.github/workflows/pr_run_test_ci.yml new file mode 100644 index 0000000..f0eb232 --- /dev/null +++ b/.github/workflows/pr_run_test_ci.yml @@ -0,0 +1,68 @@ +name: PR_Run_Test_CI +on: + pull_request: + branches: + - 'main' + workflow_dispatch: + +jobs: + test: + name: PR_Run_Test_CI + runs-on: ubuntu-latest + + steps: + - name: git pull + uses: actions/checkout@v2 + + - name: run a one-line script + run: env + + - name: setting dotnet version + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '6.0.x' + include-prerelease: true + + - name: Configure sysctl limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 1.11 + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~\sonar\cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache SonarCloud 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 SonarCloud scanner + run: | + dotnet tool install --global dotnet-sonarscanner + - name: Build and analyze for SonarCloud + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + if: ${{ env.SONAR_TOKEN != '' }} + run: | + dotnet-sonarscanner begin /k:"BlazorComponent_MASA.Blazor.Extensions" /o:"blazorcomponent" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + dotnet build /p:ContinuousIntegrationBuild=true + dotnet test --no-build --verbosity normal --collect "Code Coverage" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[*.Tests]*" + dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" + - name: Build and analyze for Codecov + run: | + dotnet build /p:ContinuousIntegrationBuild=true + dotnet test --no-build --verbosity normal --collect "Code Coverage" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[*.Tests]*" + \ No newline at end of file diff --git a/Masa.Blazor.Extensions.sln b/Masa.Blazor.Extensions.sln index 0a78d15..4053373 100644 --- a/Masa.Blazor.Extensions.sln +++ b/Masa.Blazor.Extensions.sln @@ -5,7 +5,9 @@ VisualStudioVersion = 17.5.33209.295 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{51E6BF6E-CF63-4DF0-B048-C821E763BE5A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masa.Blazor.Extensions.Languages.Razor", "src\Languages\Masa.Blazor.Extensions.Languages.Razor\Masa.Blazor.Extensions.Languages.Razor.csproj", "{0728B33B-0A33-403B-9586-41CBD4F9DB13}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Blazor.Extensions.Languages.Razor", "src\Languages\Masa.Blazor.Extensions.Languages.Razor\Masa.Blazor.Extensions.Languages.Razor.csproj", "{0728B33B-0A33-403B-9586-41CBD4F9DB13}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Languages", "Languages", "{B641C478-8E7D-4E62-BF0B-8214724AA144}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -22,7 +24,8 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {0728B33B-0A33-403B-9586-41CBD4F9DB13} = {51E6BF6E-CF63-4DF0-B048-C821E763BE5A} + {0728B33B-0A33-403B-9586-41CBD4F9DB13} = {B641C478-8E7D-4E62-BF0B-8214724AA144} + {B641C478-8E7D-4E62-BF0B-8214724AA144} = {51E6BF6E-CF63-4DF0-B048-C821E763BE5A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {58081D66-840C-41BE-AC2C-4E5B92BAE7E5}