Merge pull request #101 from abhinavminhas/dev #540
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #CI/MANUAL TRIGGER | |
| name: Build / Test | |
| on: | |
| push: | |
| branches: [ main, dev ] | |
| paths-ignore: | |
| - '**.md' | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| jobs: | |
| Build_DotNet_OS-VSVersion: | |
| name: Build/Test (.NET Framework) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ windows-2022 ] | |
| vs-version: [ '17.14'] | |
| env: | |
| VSTEST_CONSOLE_PATH: C:\"Program Files"\"Microsoft Visual Studio"\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install .NET Framework SDK [ Version - 4.6.1 ] | |
| shell: powershell | |
| run: | | |
| choco install netfx-4.6.1-devpack | |
| - name: Nuget Restore | |
| run: nuget restore GmailAPIHelper.sln -Verbosity quiet | |
| - name: Setup-MSBuild VS-Version (${{ matrix.vs-version }}) | |
| uses: microsoft/setup-msbuild@v2 | |
| with: | |
| vs-version: ${{ matrix.vs-version }} | |
| - name: Find And Replace Values (App Config) | |
| uses: abhinavminhas/replace-tokens@main | |
| with: | |
| files: '${{ github.workspace }}\GmailAPIHelper.NET.Tests\App.config' | |
| replacements: '__GMAILID__=${{ secrets.GMAIL_ID }}' | |
| - name: Build | |
| id: build | |
| run: | | |
| msbuild GmailAPIHelper.sln /p:configuration=Release /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal /v:m | |
| - name: Find And Replace Values (OAuth) | |
| uses: abhinavminhas/replace-tokens@main | |
| with: | |
| files: '${{ github.workspace }}\GmailAPIHelper.NET.Tests\bin\Release\token.json\Google.Apis.Auth.OAuth2.Responses.TokenResponse-user' | |
| replacements: '__ACCESSTOKEN__=${{ secrets.ACCESS_TOKEN }}' | |
| - name: Find And Replace Values (Client Secret) | |
| uses: abhinavminhas/replace-tokens@main | |
| with: | |
| files: '${{ github.workspace }}\GmailAPIHelper.NET.Tests\bin\Release\credentials.json' | |
| replacements: '__CLIENTSECRET__=${{ secrets.CLIENT_SECRET }}' | |
| - name: Setup-VSTest | |
| run: echo 'VSTEST Console Path --> ${{env.VSTEST_CONSOLE_PATH}}' | |
| - name: Test | |
| run: ${{env.VSTEST_CONSOLE_PATH}}\vstest.console.exe ${{ github.workspace }}\GmailAPIHelper.NET.Tests\bin\Release\GmailAPIHelper.NET.Tests.dll /TestCaseFilter:"TestCategory=GMAIL-TESTS-DOTNETFRAMEWORK" | |
| Build_DotNetCore_OS-Version: | |
| name: Build (.NET Core) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ windows-2022, ubuntu-22.04, macOS-15 ] | |
| dotnet-version: [ '3.1.x', '6.0.x', '8.0.x', '9.0.x' ] | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install .NET Core SDK [ Version - ${{ matrix.dotnet-version }} ] (MacOS) | |
| if: ${{ runner.os == 'macOS' }} | |
| uses: ./.github/workflows/install-dotnet-core | |
| with: | |
| dotnet-version: ${{ matrix.dotnet-version }} | |
| architecture: x64 | |
| - name: Setup Dotnet [ Version - ${{ matrix.dotnet-version }} ] | |
| if: ${{ runner.os != 'macOS' }} | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ matrix.dotnet-version }} | |
| - name: Find And Replace Values (App Config) | |
| uses: abhinavminhas/replace-tokens@main | |
| with: | |
| files: '${{ github.workspace }}/GmailAPIHelper.CORE.Tests/App.config' | |
| replacements: '__GMAILID__=${{ secrets.GMAIL_ID }}' | |
| - name: Build | |
| run: dotnet build GmailAPIHelper.CORE.Tests/GmailAPIHelper.CORE.Tests.csproj --configuration Release | |
| - name: Find And Replace Values (OAuth) | |
| if: ${{ matrix.dotnet-version == 'N/A' }} | |
| uses: abhinavminhas/replace-tokens@main | |
| with: | |
| files: '${{ github.workspace }}/GmailAPIHelper.CORE.Tests/bin/Release/netcoreapp3.1/token.json/Google.Apis.Auth.OAuth2.Responses.TokenResponse-user' | |
| replacements: '__ACCESSTOKEN__=${{ secrets.ACCESS_TOKEN }}' | |
| - name: Find And Replace Values (Client Secret) | |
| if: ${{ matrix.dotnet-version == 'N/A' }} | |
| uses: abhinavminhas/replace-tokens@main | |
| with: | |
| files: '${{ github.workspace }}/GmailAPIHelper.CORE.Tests/bin/Release/netcoreapp3.1/credentials.json' | |
| replacements: '__CLIENTSECRET__=${{ secrets.CLIENT_SECRET }}' | |
| - name: Test | |
| if: ${{ matrix.dotnet-version == 'N/A' }} | |
| run: dotnet test --no-build --verbosity normal --configuration Release --filter TestCategory=GMAIL-TESTS-DOTNETCORE | |
| Code-Coverage: | |
| name: Code Coverage (Codecov) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ windows-2022, ubuntu-22.04, macOS-15 ] | |
| dotnet-version: [ '3.1.x' ] | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install .NET Core SDK [ Version - ${{ matrix.dotnet-version }} ] (MacOS) | |
| if: ${{ runner.os == 'macOS' }} | |
| uses: ./.github/workflows/install-dotnet-core | |
| with: | |
| dotnet-version: ${{ matrix.dotnet-version }} | |
| architecture: x64 | |
| - name: Setup Dotnet [ Version - ${{ matrix.dotnet-version }} ] | |
| if: ${{ runner.os != 'macOS' }} | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ matrix.dotnet-version }} | |
| - name: Find And Replace Values (App Config) | |
| uses: abhinavminhas/replace-tokens@main | |
| with: | |
| files: '${{ github.workspace }}/GmailAPIHelper.CORE.Tests/App.config' | |
| replacements: '__GMAILID__=${{ secrets.GMAIL_ID }}' | |
| - name: Build | |
| run: dotnet build GmailAPIHelper.CORE.Tests/GmailAPIHelper.CORE.Tests.csproj --configuration Release | |
| - name: Find And Replace Values (OAuth) | |
| if: ${{ matrix.dotnet-version == '3.1.x' }} | |
| uses: abhinavminhas/replace-tokens@main | |
| with: | |
| files: '${{ github.workspace }}/GmailAPIHelper.CORE.Tests/bin/Release/netcoreapp3.1/token.json/Google.Apis.Auth.OAuth2.Responses.TokenResponse-user' | |
| replacements: '__ACCESSTOKEN__=${{ secrets.ACCESS_TOKEN }}' | |
| - name: Find And Replace Values (Client Secret) | |
| if: ${{ matrix.dotnet-version == '3.1.x' }} | |
| uses: abhinavminhas/replace-tokens@main | |
| with: | |
| files: '${{ github.workspace }}/GmailAPIHelper.CORE.Tests/bin/Release/netcoreapp3.1/credentials.json' | |
| replacements: '__CLIENTSECRET__=${{ secrets.CLIENT_SECRET }}' | |
| - name: Test | |
| if: ${{ matrix.dotnet-version == '3.1.x' }} | |
| run: dotnet test --no-build --verbosity normal --configuration Release --filter TestCategory=GMAIL-TESTS-DOTNETCORE /p:CollectCoverage=true /p:CoverletOutputFormat=lcov | |
| - name: Upload Coverage To Codecov | |
| if: ${{ matrix.dotnet-version == '3.1.x' }} | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| Code-Quality: | |
| name: Code Quality (SonarCloud) | |
| runs-on: windows-latest | |
| steps: | |
| - name: Set Up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 17 | |
| distribution: 'zulu' | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Cache SonarQube Cloud Packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~\sonar\cache | |
| key: ${{ runner.os }}-sonar | |
| restore-keys: ${{ runner.os }}-sonar | |
| - name: Cache SonarQube Cloud Scanner | |
| id: cache-sonar-scanner | |
| uses: actions/cache@v4 | |
| with: | |
| path: .\.sonar\scanner | |
| key: ${{ runner.os }}-sonar-scanner | |
| restore-keys: ${{ runner.os }}-sonar-scanner | |
| - name: Install SonarQube Cloud Scanner | |
| if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' | |
| shell: powershell | |
| run: | | |
| New-Item -Path .\.sonar\scanner -ItemType Directory | |
| dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner | |
| - name: Build And Analyze | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| shell: powershell | |
| run: | | |
| .\.sonar\scanner\dotnet-sonarscanner begin /k:"abhinavminhas_Gmail-API-Helper" /o:"abhinavminhas" /d:sonar.token="$env:SONAR_TOKEN" /d:sonar.host.url="https://sonarcloud.io" | |
| dotnet build | |
| .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="$env:SONAR_TOKEN" |