Skip to content

Continuous Integration #2839

Continuous Integration

Continuous Integration #2839

# Workflow Syntax: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
# Example: https://github.com/github/VisualStudio/blob/263aac11f57d53c5f9fe64ba9916f77c058974d7/.github/workflows/main.yml
# Build and Test (ref. https://docs.github.com/en/actions/guides/building-and-testing-net)
# Note: Github recommends using full commit SHAs when using 3rd party actions
name: Continuous Integration
concurrency:
group: ${{ github.workflow }}-${{ github.sha }}
cancel-in-progress: true
env:
build-config: Release
solution: EDDI.sln
# Build artifact variables
build-artifact-name: build-artifact
# Define our triggers
on:
push:
branches:
- '*'
- develop
- '!l10n_develop'
- '!refs/pull/*'
paths-ignore:
- docs/* # Every file in the root docs folder
- '**.html' # HTML files anywhere in the repo
- '**.md' # Markdown files anywhere in the repo
- '**.resx' # RESX files anywhere in the repo
pull_request:
# The branches below must be a subset of the branches above
branches:
- develop
paths-ignore:
- docs/* # Every file in the root docs folder
- '**.html' # HTML files anywhere in the repo
- '**.md' # Markdown files anywhere in the repo
- '**.resx' # RESX files anywhere in the repo
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │ * indicates 'all'
# │ │ │ │ │ Ref. https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule
# │ │ │ │ │
# * * * * *
- cron: '30 2 * * 0' # Runs at 2:30 AM UTC, any day of the month, any month of the year, on Sundays
jobs:
build:
name: Build & Test
runs-on: windows-latest
steps:
- name: Check out the repository on the workflow runner
uses: actions/[email protected]
# Build
- name: Add msbuild.exe to PATH
uses: microsoft/[email protected]
- name: Add nuget to PATH
uses: nuget/setup-nuget@fd9fffd6ca4541cf4152a9565835ca1a88a6eb37
with:
nuget-version: 'latest'
- name: Retrieve any cached copies of dependencies (these may be stored for up to a week)
uses: actions/cache@main
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} #hash of project files with embedded PackageReference data
restore-keys: |
${{ runner.os }}-nuget
- name: Restore any missing dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: nuget restore ${{ env.solution }} -NonInteractive
- name: Save our updated cache of dependencies
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} #hash of project files with embedded PackageReference data
- name: Build our solution
id: build
run: msbuild ${{ env.solution }} /p:Configuration=${{ env.build-config }} /p:UseSharedCompilation=false /verbosity:minimal
- name: Upload build artifacts
uses: actions/[email protected]
with:
name: ${{ env.build-artifact-name }}
path: ./bin/Release/*
# Perform unit testing
- name: Add VSTest.console.exe to PATH
uses: darenm/Setup-VSTest@d9a5dffa3f11d9c27ec42eb69515d3aaeaad9ef8
- name: Make a TestResults directory
run: mkdir -p ./TestResults
- name: Test our solution and generate a coverage report using OpenCover
uses: ./.github/actions/TestWithCoverage
with:
opencover-console-path: \.nuget\packages\OpenCover\4.6.519\tools\OpenCover.Console.exe
opencover-console-args: -mergebyhash -skipautoprops -excludebyattribute:*.ExcludeFromCodeCoverage*,*.GeneratedCodeAttribute* -excludebyfile:*\*.Designer.cs,*.xaml -filter:"+[Eddi*]* +[Utilities*]* +[Tests*]UnitTests*" -register:Path32 -returntargetcode
target-path: vstest.console.exe
target-args: Tests\bin\Release\Tests.dll /tests:UnitTests /Parallel /InIsolation /Blame
output-path: ./TestResults/coverage.xml
- name: Upload coverage to CodeCov (ref. https://github.com/codecov/codecov-action)
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70
with:
files: TestResults/coverage.xml
fail_ci_if_error: false # Specify if CI pipeline should fail when Codecov runs into errors during upload. Defaults to false