Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch the CI to GitHub Actions #2

Closed
22 of 23 tasks
petrsvihlik opened this issue Feb 26, 2021 · 2 comments
Closed
22 of 23 tasks

Switch the CI to GitHub Actions #2

petrsvihlik opened this issue Feb 26, 2021 · 2 comments
Assignees
Labels

Comments

@petrsvihlik
Copy link
Contributor

petrsvihlik commented Feb 26, 2021

Motivation

  • Create a PoC of automatic building, testing, and deploying using GH Actions to verify the possibility of migrating from AppVeyor.

Acceptance Criteria

  • The codebase is built and tested with every commit and PR (=> we know the status of the codebase)
  • Failing tests will make the build fail and prevent any further steps (deployment)
  • Artifacts are collected for every build Can be, it's easy but not necessary. We'll collect artifacts only for Releases.
  • It's possible to create a "Release" from the master branch
    • The release will trigger a workflow that'll build the master branch and deploy the resulting NuGet package to NuGet.org
    • Symbol packages are also deployed (snupkg)
    • The NuGet package is correctly versioned (semver)
    • The version of the NuGet package can be defined as the tag version of the release
    • Allow pre-release suffixes
    • Upload artifacts to GH release, or this
    • Update release instructions in affected repos
    • Set status checks for protected branches
    • Exclude test projects from coverage

Optionally

Proposed solution

Versioning

  • Employ Directory.build.props for defining the version or version patching (AssemblyInfo, *.csprojs)

Examples from AppVeyor:
<Project><PropertyGroup><Version>$($ENV:APPVEYOR_BUILD_VERSION)</Version></PropertyGroup></Project>" | out-file "Directory.build.props (before build)
And:

dotnet_csproj:
  patch: true
  file: '**\*.csproj'
  version: '{version}'
  version_prefix: '{version}'
  package_version: '{version}'
  assembly_version: '{version}'
  file_version: '{version}'
  informational_version: '{version}'

Coverage

$buildConfig = if ($ENV:CONFIGURATION -eq $null) { "Release" } else { $ENV:CONFIGURATION }

$buildFolder = if ($ENV:APPVEYOR_BUILD_FOLDER -eq $null) { $PSScriptRoot } else { $ENV:APPVEYOR_BUILD_FOLDER }

$openCover = 'C:\ProgramData\chocolatey\lib\opencover.portable\tools\OpenCover.Console.exe'

$target = '-target:C:\Program Files\dotnet\dotnet.exe'
$targetArgs = '-targetargs:"test -c:' + $buildConfig + ' --logger:trx;LogFileName=results.trx --filter FullyQualifiedName!~Benchmarks /p:DebugType=full"' 
$filter = '-filter:+[Kentico.Kontent.Delivery*]*-[*Tests]*-[*Benchmarks]*'
$output = '-output:' + $buildFolder + '\coverage.xml'
$register = if ($ENV:APPVEYOR -eq $true ) { '-register' } else { '-register:user' } # Magical parameter that breaks things

& $openCover $target $targetArgs $filter $register '-oldStyle' '-mergeoutput' $output

Remaining repos

  • kontent-sample-app-net (special: packing x86+x64 website for further internal CI steps)
  • kontent-generators-net (special: packing standalone apps for multiple platforms)

Outstanding tasks

  • fix globally: warning NU5048: The 'PackageIconUrl'/'iconUrl' element is deprecated. Consider using the 'PackageIcon'/'icon' element instead. Learn more at https://aka.ms/deprecateIconUrl
@petrsvihlik petrsvihlik self-assigned this Feb 27, 2021
@petrsvihlik petrsvihlik added this to To do in .NET Community Backlog via automation Feb 27, 2021
@petrsvihlik
Copy link
Contributor Author

petrsvihlik commented Feb 27, 2021

Findings:

Migration AppVeyor -> GitHub Actions (Win->Linux)

  • Linux - case sensitivity (Directory.Build.props)
  • some unit tests may be sensitive to the OS used (Win x Linux)
  • pushing multiple packages
  • Running PowerShell on Linux "shell: pwsh" There are two parameters: pwsh / powershell:
    • for “shell: pwsh”: powershell core(6.2.3) will be invoked.
    • for “shell: powershell”: desktop powershell(5.1) will be invoked.

Custom actions

  • it's impossible to nest GH actions (see above)
  • hosting multiple actions in a single repo IS possible...not sure if it's possible to publish them to the marketplace in this setup though

Symbols

  • enable deterministic builds /p:ContinuousIntegrationBuild=true

Collecting coverage

  • coverlet.msbuild is necessary for the following syntax dotnet test --no-build --verbosity normal --configuration Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
  • coverage - add coverlet.msbuild
    <PackageReference Include="coverlet.collector" Version="3.0.3">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="coverlet.msbuild" Version="3.0.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>

Protecting secrets when building forks

@petrsvihlik
Copy link
Contributor Author

articles to be published at https://dev.to/petrsvihlik

.NET Community Backlog automation moved this from To do to Done Mar 4, 2021
@pokornyd pokornyd removed this from Done in .NET Community Backlog Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant