Merge pull request #41 from IowaComputerGurus/dependabot/github_actio… #32
This file contains 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
name: CI Build | |
on: | |
push: | |
branches: [ develop ] | |
pull_request: | |
branches: [ develop ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
name: Validate Build | |
env: | |
solution-path: './src/ICG AspnetCore Utilities.CloudStorage.sln' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Ensure .NET Installed | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
- name: Install GitVersion | |
run: dotnet tool install --global GitVersion.Tool | |
- name: Determine Version | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0.10.2 | |
with: | |
useConfigFile: true | |
- name: Restore Packages | |
run: dotnet restore "${{ env.solution-path }}" | |
- name: Build | |
run: dotnet build "${{ env.solution-path }}" --no-restore --configuration Release -p:version=${{ steps.gitversion.outputs.majorMinorPatch }} | |
- name: Test | |
run: dotnet test "${{ env.solution-path }}" --no-build --configuration Release | |
code-quality: | |
if: github.actor != 'dependabot[bot]' | |
runs-on: windows-latest | |
name: Analyze Code Quality | |
env: | |
solution-path: './src/ICG AspnetCore Utilities.CloudStorage.sln' | |
steps: | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 11 | |
distribution: zulu | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v3.3.1 | |
with: | |
path: ~\sonar\cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache SonarCloud scanner | |
id: cache-sonar-scanner | |
uses: actions/cache@v3.3.1 | |
with: | |
path: .\.sonar\scanner | |
key: ${{ runner.os }}-sonar-scanner | |
restore-keys: ${{ runner.os }}-sonar-scanner | |
- name: Install SonarCloud 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: Install GitVersion | |
run: dotnet tool install --global GitVersion.Tool | |
- name: Determine Version | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0.10.2 | |
with: | |
useConfigFile: true | |
- name: Build and analyze | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
shell: powershell | |
run: | | |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"IowaComputerGurus_aspnetcore.utilities.cloudstorage" /o:"iowacomputergurus-github" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" | |
dotnet restore "${{ env.solution-path }}" | |
dotnet build "${{ env.solution-path }}" --no-restore --configuration Release -p:version=${{ steps.gitversion.outputs.majorMinorPatch }} | |
dotnet test "${{ env.solution-path }}" --no-build --configuration Release --collect "XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover --logger "trx;LogFileName=unittests.trx" | |
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" |