Skip to content

Bump the actions group with 2 updates (#239) #289

Bump the actions group with 2 updates (#239)

Bump the actions group with 2 updates (#239) #289

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
checks: write
jobs:
build-test-analyze:
name: Build, Test & Analyze
runs-on: ubuntu-latest
env:
# Secrets are not exposed to Dependabot or fork-triggered runs, so the
# token is empty there. The SonarQube steps below are skipped in that
# case so the build and tests still run.
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
steps:
- name: Set up JDK 17
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
java-version: 17
distribution: 'zulu'
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install .NET 10 SDK
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: '10.0.x'
- name: Cache SonarQube Cloud packages
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
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@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarQube Cloud scanner
if: ${{ env.SONAR_TOKEN != '' && steps.cache-sonar-scanner.outputs.cache-hit != 'true' }}
run: |
mkdir -p ${{ runner.temp }}/scanner
dotnet tool update dotnet-sonarscanner --tool-path ${{ runner.temp }}/scanner
- name: Restore
run: dotnet restore DockerUpdateGuard.slnx
- name: Install Reihitsu.Cli
run: dotnet tool install -g Reihitsu.Cli
- name: Check formatting
run: reihitsu-format --check .
- name: Begin SonarQube analysis
if: ${{ env.SONAR_TOKEN != '' }}
run: |
${{ runner.temp }}/scanner/dotnet-sonarscanner begin \
/k:"LarsLaskowski_DockerUpdateGuard" \
/o:"networlddev" \
/d:sonar.token="$SONAR_TOKEN" \
/d:sonar.cs.opencover.reportsPaths="${{ runner.temp }}/TestResults/**/coverage.opencover.xml"
- name: Build
run: dotnet build DockerUpdateGuard.slnx -c Release --no-restore
- name: Test
run: >
dotnet test DockerUpdateGuard.slnx
-c Release --no-build
--logger trx
--collect:"XPlat Code Coverage"
--results-directory ${{ runner.temp }}/TestResults
--
DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- name: End SonarQube analysis
if: ${{ !cancelled() && env.SONAR_TOKEN != '' }}
run: |
${{ runner.temp }}/scanner/dotnet-sonarscanner end /d:sonar.token="$SONAR_TOKEN"
- name: Publish test report
uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0
# Creating check runs needs a writable token, which Dependabot and
# fork-triggered runs do not get. Skip there; the test step itself
# still fails the job on a failing test.
if: ${{ !cancelled() && github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.fork != true }}
with:
name: dotnet tests
path: ${{ runner.temp }}/TestResults/**/*.trx
reporter: dotnet-trx
- name: Upload test & coverage artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ !cancelled() }}
with:
name: test-results
path: |
${{ runner.temp }}/TestResults/**/*.trx
${{ runner.temp }}/TestResults/**/coverage.opencover.xml
if-no-files-found: warn