Skip to content

Commit

Permalink
Feature/2022 04 ci updates (#98)
Browse files Browse the repository at this point in the history
* nuget updates

* boilerplate updates

* ci update

* change to reusable workflow

* readme update

* dependabot update

* vs warnings update

* file-scoped namespaces + global usings

Co-authored-by: Azure DevOps CI <agent@dev.azure.com>
  • Loading branch information
f2calv and Azure DevOps CI authored Apr 7, 2022
1 parent 0c4fbb5 commit 173183f
Show file tree
Hide file tree
Showing 27 changed files with 1,370 additions and 1,662 deletions.
70 changes: 3 additions & 67 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,67 +1,3 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

*.exe filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.msi filter=lfs diff=lfs merge=lfs -text
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
43 changes: 2 additions & 41 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,7 @@ updates:
time: "04:00"
open-pull-requests-limit: 10
ignore:
- dependency-name: CasCap.Common.Serialisation.Json
versions:
- 1.0.18
- 1.0.19
- 1.0.20
- 1.0.22
- 1.0.24
- dependency-name: CasCap.Common.Caching
versions:
- 1.0.18
- 1.0.19
- 1.0.20
- 1.0.22
- 1.0.24
- dependency-name: CasCap.Apis.GooglePhotos
versions:
- 1.0.14
- 1.0.15
- 1.0.16
- dependency-name: Microsoft.NET.Test.Sdk
versions:
- 16.8.3
- 16.9.1
- dependency-name: coverlet.collector
versions:
- 3.0.2
- 3.0.3
- dependency-name: Newtonsoft.Json
- dependency-name: coverlet.msbuild
versions:
- 3.0.2
- 3.0.3
- dependency-name: SixLabors.ImageSharp
versions:
- 1.0.3
- dependency-name: ShellProgressBar
versions:
- 5.1.0
- dependency-name: McMaster.Extensions.CommandLineUtils
versions:
- 3.1.0
- dependency-name: McMaster.Extensions.Hosting.CommandLine
versions:
- 3.1.0
- dependency-name: coverlet.collector
192 changes: 19 additions & 173 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,186 +4,32 @@ on:
workflow_dispatch:
inputs:
BuildConfiguration:
type: choice
description: Build Configuration
required: true
default: Release
options:
- Release
- Debug
PublishPreview:
type: string
description: Publish preview branch?
required: true
default: "false"
push:
branches-ignore:
- "preview/**"
paths-ignore:
- '.azure-pipelines/**'
- LICENSE
- README.md
- ".azure-pipelines/**"
- LICENSE
- README.md
pull_request:
branches: [main]
types: [opened, synchronize, reopened]

jobs:
build:
#no point using matrix build as "Container operations are only supported on Linux runners"
# strategy:
# matrix:
# os: [ubuntu-latest,windows-latest]
# runs-on: ${{matrix.os}}
runs-on: ubuntu-latest
outputs:
SemVer: ${{ steps.gitversion.outputs.SemVer }}

steps:

- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: .NET Core 3.1.x SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x

- name: .NET 5.x SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x

# - name: gitversion install
# uses: gittools/actions/gitversion/setup@v0.9.7
# with:
# versionSpec: 5.x

# #https://gitversion.net/docs/usage/
# - name: gitversion determine version
# id: gitversionOLD
# uses: gittools/actions/gitversion/execute@v0.9.7
# with:
# useConfigFile: true

- name: gitversion
id: gitversion
run: |
dotnet tool update -g GitVersion.Tool
$GitVersion = dotnet-gitversion ${{ github.workspace }} /nofetch | ConvertFrom-Json
echo "SemVer=$($GitVersion.SemVer)"
echo "::set-output name=SemVer::$($GitVersion.SemVer)"
shell: pwsh

- name: dotnet restore
run: dotnet restore --verbosity minimal --configfile nuget.config

- name: dotnet build
run: dotnet build -c Release --nologo --no-restore -p:Version='${{ steps.gitversion.outputs.SemVer }}' -p:SourceRevisionId=${{ github.sha }}

- name: dotnet test
run: dotnet test -c Release --nologo --no-restore --no-build -p:CollectCoverage=true -p:CoverletOutputFormat=lcov -p:CoverletOutput=${{ github.workspace }}/coverage/

- name: code coverage - coveralls (1 of 3) - .NET Core 3.1.x
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: ${{ github.workspace }}/coverage/coverage.netcoreapp3.1.info
flag-name: run-netcoreapp3.1
parallel: true

- name: code coverage - coveralls (2 of 3) - .NET 5.x SDK
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: ${{ github.workspace }}/coverage/coverage.net5.0.info
flag-name: run-net5.0
parallel: true

- name: code coverage - coveralls (3 of 3)
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true

# - name: code coverage - report generator
# uses: danielpalme/ReportGenerator-GitHub-Action@4.5.8
# if: runner.OS == 'Linux'
# with:
# reports: ./coverage/coverage.*.info
# targetdir: ./coveragereport
# reporttypes: lcov
# tag: ${{ github.run_number }}_${{ github.run_id }}

- name: reportgenerator
if: runner.OS == 'Linux'
run: |
dotnet tool update -g dotnet-reportgenerator-globaltool
reportgenerator -reports:./coverage/coverage.*.info \
-targetdir:./coveragereport \
-reporttypes:lcov \
-tag:${{ github.run_number }}_${{ github.run_id }}
- name: code coverage - upload-artifact
uses: actions/upload-artifact@v2
if: runner.OS == 'Linux'
with:
name: coveragereport
path: coveragereport

- name: dotnet pack
run: dotnet pack -c Release --nologo --no-build --include-symbols -p:Version='${{ steps.gitversion.outputs.SemVer }}'
if: github.ref == 'refs/heads/main' && runner.OS == 'Linux'

- name: dotnet push (nuget)
run: dotnet nuget push ${{ github.workspace }}/src/**/*.nupkg --skip-duplicate -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
if: github.ref == 'refs/heads/main'

- name: dotnet push (github)
run: |
dotnet tool update -g gpr
gpr push ${{ github.workspace }}/src/**/*.nupkg -k ${{ secrets.GITHUB_TOKEN }}
if: github.ref == 'refs/heads/main'

- name: create-release ${{ steps.gitversion.outputs.SemVer }}
uses: actions/create-release@v1 #todo: this is deprecated, replace with another action later...?
if: github.ref == 'refs/heads/main'
with:
tag_name: ${{ steps.gitversion.outputs.SemVer }}
release_name: Release ${{ steps.gitversion.outputs.SemVer }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

SonarQube:
runs-on: windows-latest
steps:
# below composite action does not work, github doesn't support actions inside composite actions :/
# https://github.com/actions/runner/issues/646
# - uses: ./.github/actions/sonarqube
# with:
# SonarToken: ${{ secrets.SONAR_TOKEN }}

- 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
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:
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:"${{ github.actor }}_${{ github.event.repository.name }}" /o:"${{ github.actor }}" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build -c Release
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
ci:
uses: f2calv/gha-workflows/.github/workflows/dotnet-publish-nuget-v1.yml@main
with:
BuildConfiguration: ${{ github.event.inputs.BuildConfiguration }}
PublishPreview: ${{ github.event.inputs.PublishPreview }}
11 changes: 7 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

<PropertyGroup>
<RootNamespace>CasCap</RootNamespace>
<LangVersion>9.0</LangVersion>
<LangVersion>10.0</LangVersion>
<!--nullable we enable on a per project basis-->
<!--<Nullable>enable</Nullable>-->
<UserSecretsId>255ba51e-c46d-40c4-9420-80d485ea10fe</UserSecretsId>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -34,16 +35,18 @@
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<!-- suppress roslyn naming convention messages -->
<NoWarn>IDE1006</NoWarn>
<!-- IDE1006 - suppress roslyn naming convention messages -->
<!-- IDE0079 - Remove unnecessary suppression -->
<!-- IDE0042 - Variable declaration can be deconstructed -->
<NoWarn>IDE1006;IDE0079;IDE0042</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<!-- suppress 'Unreachable code detected' -->
<NoWarn>CS0162</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

<PropertyGroup>
Expand Down
10 changes: 8 additions & 2 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
mode: MainLine
branches:
main:
regex: ^main$
tag: ''
feature:
tag: ci
regex: ^features?[/-]
tag: useBranchName
preview:
regex: ^preview?[/-]
tag: preview-{BranchName}
source-branches: ['main']
ignore:
sha: []
merge-message-formats: {}
merge-message-formats: {}
Loading

0 comments on commit 173183f

Please sign in to comment.