Skip to content

Template

Template #383

Workflow file for this run

# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: Build and Test
on:
push:
branches: [ "main" ]
paths-ignore:
- 'doc/**'
- 'README.md'
pull_request:
branches: [ "main" ]
paths-ignore:
- 'doc/**'
- 'README.md'
jobs:
build:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
include:
- os: windows-latest
artifact: windows.complog
slash: \
- os: ubuntu-latest
artifact: ubuntu.complog
slash: /
env:
TEST_ARTIFACTS_PATH: ${{ github.workspace }}${{ matrix.slash }}artifacts${{ matrix.slash }}test
TEST_RESULTS_PATH: ${{ github.workspace }}${{ matrix.slash }}artifacts${{ matrix.slash }}test-results
TEST_COVERAGE_PATH: ${{ github.workspace }}${{ matrix.slash }}artifacts${{ matrix.slash }}coverage
timeout-minutes: 30
name: Build and Test ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
# Setup the output directories for usage
- name: Create directories
shell: pwsh
run: New-Item -Type Directory -Path @("${{ env.TEST_ARTIFACTS_PATH }}", "${{ env.TEST_RESULTS_PATH }}", "${{ env.TEST_COVERAGE_PATH }}")
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.x
9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore -bl
- name: Test Linux
uses: ./.github/actions/dotnet-test
with:
name: 'Test-Linux'
framework: 'net8.0'
test-results-dir: ${{ env.TEST_RESULTS_PATH }}
test-coverage-dir: ${{ env.TEST_COVERAGE_PATH }}
if: matrix.os == 'ubuntu-latest'
- name: Test Windows .NET Core
uses: ./.github/actions/dotnet-test
with:
name: 'Test-Windows-Core'
framework: 'net8.0'
test-results-dir: ${{ env.TEST_RESULTS_PATH }}
test-coverage-dir: ${{ env.TEST_COVERAGE_PATH }}
if: matrix.os == 'windows-latest'
- name: Test Windows Framework
uses: ./.github/actions/dotnet-test
with:
name: 'Test-Windows-Framework'
framework: 'net472'
test-results-dir: ${{ env.TEST_RESULTS_PATH }}
test-coverage-dir: ${{ env.TEST_COVERAGE_PATH }}
if: matrix.os == 'windows-latest'
- name: Create Compiler Log
run: dotnet run --framework net8.0 --project src/Basic.CompilerLog/Basic.CompilerLog.csproj create msbuild.binlog
- name: Publish Compiler Log
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact }}
path: msbuild.complog
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ${{ env.TEST_COVERAGE_PATH }}
- name: Publish Test Results
uses: actions/upload-artifact@v3
if: always()
with:
name: test-results
path: ${{ env.TEST_RESULTS_PATH }}
- name: Publish Test Artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: Test Artifacts ${{ matrix.os }}
path: ${{ env.TEST_ARTIFACTS_PATH }}