Avoid temp compilation artefacts during source generator tests (#300) #746
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: .NET CI | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
python: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
fail-fast: false | |
runs-on: "${{ matrix.os }}" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: conda-incubator/setup-miniconda@v3 | |
id: setup-conda | |
with: | |
auto-update-conda: true | |
python-version: ${{ matrix.python-version }} | |
activate-environment: csnakes_test | |
environment-file: src/Conda.Tests/python/environment.yml | |
- name: cleanup conda-incubator/setup-miniconda | |
run: conda clean --all --yes | |
- name: Setup Python | |
id: installpython | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "${{ matrix.python }}" | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
8.0.x | |
9.0.x | |
- uses: actions/cache@v4 | |
name: Cache NuGet packages | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('src/Directory.Packages.props') }} | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
- name: Restore dependencies | |
run: dotnet restore -bl:${{ github.workspace }}/restore-${{ matrix.os }}-${{ matrix.python }}.binlog | |
working-directory: src | |
env: | |
PYTHON_VERSION: ${{ steps.installpython.outputs.python-version }} | |
- name: Build | |
run: dotnet build --no-restore -bl:${{ github.workspace }}/build-${{ matrix.os }}-${{ matrix.python }}.binlog | |
working-directory: src | |
- name: Test | |
run: dotnet test --no-build --blame --verbosity m --collect "XPlat Code Coverage" --results-directory test-results /p:TrxLogFileNameSuffix=${{ matrix.os }}-${{ matrix.python }} -bl:${{ github.workspace }}/tests-${{ matrix.os }}-${{ matrix.python }}.binlog | |
working-directory: src | |
env: | |
PYTHON_VERSION: ${{ steps.installpython.outputs.python-version }} | |
- name: Upload logs | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: logs-${{ matrix.os }}-${{ matrix.python }} | |
path: | | |
${{ github.workspace }}/*.binlog | |
- name: Upload test results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: test-results-${{ matrix.os }}-${{ matrix.python }} | |
path: | | |
${{ github.workspace }}/src/test-results/** | |
build-samples: | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
python: ["3.12"] | |
sample: ["simple", "Aspire"] | |
fail-fast: false | |
runs-on: "${{ matrix.os }}" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
id: installpython | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "${{ matrix.python }}" | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
8.0.x | |
9.0.x | |
- name: Install Aspire workload | |
run: dotnet workload install aspire | |
- name: Restore dependencies | |
run: dotnet restore "${{ matrix.sample }}" | |
working-directory: samples | |
- name: Build | |
run: dotnet build --no-restore "${{ matrix.sample }}" | |
working-directory: samples | |
- name: Test | |
run: dotnet test --no-build --verbosity normal "${{ matrix.sample }}" | |
working-directory: samples | |
env: | |
PYTHON_VERSION: ${{ steps.installpython.outputs.python-version }} |