Skip to content

AsmResolver.DotNet.PortablePdbs #332

AsmResolver.DotNet.PortablePdbs

AsmResolver.DotNet.PortablePdbs #332

name: Test and Publish
on:
push:
branches:
- master
- development
- 'cicd/**'
pull_request:
branches:
- master
- development
- 'cicd/**'
concurrency:
group: ${{github.workflow}}-${{github.event.pull_request.number || github.ref}}
cancel-in-progress: true
env:
# Disable the .NET logo in the console output.
DOTNET_NOLOGO: true
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build.
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending .NET CLI telemetry to Microsoft.
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
upload-event-file:
name: Upload Event File
runs-on: ubuntu-24.04
steps:
- name: Upload event file
uses: actions/upload-artifact@v6
with:
name: test-event-file
path: ${{ github.event_path }}
retention-days: 1
# Construct a version suffix including the branch name, build number and commit hash (e.g., "development.58+abcdef12").
get-version:
name: Calculating Version Suffix
runs-on: ubuntu-24.04
outputs:
version_suffix: ${{ steps.set-vars.outputs.version_suffix }}
steps:
- uses: actions/checkout@v6
- id: git-vars
name: Get git branch information
shell: bash
run: |
echo "##[set-output name=git_branch;]$(echo $GITHUB_REF)"
echo "::set-output name=git_hash::$(git rev-parse --short HEAD)"
- id: set-vars
uses: actions/github-script@v8
with:
script: |
let runNumber = "${{ github.run_number }}";
let gitHash = "${{ steps.git-vars.outputs.git_hash }}";
let rawGitRef = "${{ steps.git-vars.outputs.git_branch }}";
console.log("rawGitRef: " + rawGitRef);
let gitRef = rawGitRef.replace(/^refs\/heads\//, "").replace(/^refs\/heads\//, "").replace(/[_//!@#$%&]/g, "-");
if(gitRef.indexOf("refs/pull/") === 0) {
gitRef = "pr-" + gitRef.substring(10, gitRef.lastIndexOf("/"));
}
var versSuffix = `${gitRef}.${runNumber}+${gitHash}`;
console.log(versSuffix);
core.setOutput("version_suffix", versSuffix);
# Main build job for compiling all csprojs.
build:
name: Build
runs-on: windows-2025
needs: [get-version]
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
# Master branch is just a normal build.
- name: Build on master branch
if: ${{github.ref == 'refs/heads/master'}}
run: |
dotnet restore AsmResolver.sln
dotnet build AsmResolver.sln `
--configuration Release `
--property:CheckEolTargetFramework=false
# For non-master branches (e.g., development or feature branches) we apply a fixup on the version suffix.
- name: Build on non-master branch
if: ${{github.ref != 'refs/heads/master'}}
run: |
dotnet restore AsmResolver.sln `
--property:VersionSuffix=${{needs.get-version.outputs.version_suffix}} `
--property:CheckEolTargetFramework=false
dotnet build AsmResolver.sln `
--configuration Release `
--property:VersionSuffix=${{needs.get-version.outputs.version_suffix}} `
--property:CheckEolTargetFramework=false
- name: Upload Build Artifacts
uses: actions/upload-artifact@v6
with:
name: build-artifacts
path: artifacts/
retention-days: 7
# Multiplexed test job running all tests on different architectures.
test:
name: Test
needs: [get-version, build]
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
runner: [
{ image: 'windows-2025', arch: 'x64' },
{ image: 'ubuntu-24.04', arch: 'x64' },
# TODO: We disable x86 tests for now due to it being too unstable.
# In particular, x86 tests often fail on spawning the xunit's test host process (cannot load hostpolicy.dll,
# as if dotnet x86 is not installed/loaded properly). This should be addressed in the future, as dynamic
# features that load metadata from live processes (as happens in e.g., AsmResolver.DotNet.Dynamic) should be
# properly covered by CI across architectures as well.
# { image: 'windows-2022', arch: 'x86' },
]
runs-on: ${{ matrix.runner.image }}
steps:
- uses: actions/checkout@v6
- name: Get .NET Installation Path
uses: ./.github/actions/dotnet-path
id: dotnet-path
with:
architecture: ${{ matrix.runner.arch }}
# We need to include many dotnet versions, even including some (specific) EOL versions, as many tests run binaries
# from all kinds of versions.
- name: Setup .NET
uses: dlemstra/setup-dotnet@add-architecture-option
with:
dotnet-architecture: ${{ matrix.runner.arch }}
dotnet-version: |
2.1.202
2.1.818
2.2.402
3.1.426
5.0.x
6.0.x
8.0.x
9.0.x
10.0.x
env:
DOTNET_INSTALL_DIR: ${{steps.dotnet-path.outputs.install-path}}
- name: Get Installed .NET Information
shell: pwsh
run: '& "${{ steps.dotnet-path.outputs.exe-path }}" --info'
# We need wine on linux as many tests build and run (semi-)native PE files.
- name: Setup Wine
if: ${{runner.os == 'Linux'}}
uses: ./.github/actions/setup-wine-ubuntu
- name: Get Installed Wine Information
if: ${{runner.os == 'Linux'}}
run: wine --version
# We need mono on linux as many tests build and run netfx PE files.
- name: Setup Mono
if: ${{runner.os == 'Linux'}}
uses: codebeltnet/install-mono@v1
- name: Get Installed Mono Information
if: ${{runner.os == 'Linux'}}
run: mono --version
- name: Download Build Artifacts
uses: actions/download-artifact@v7
with:
name: build-artifacts
path: artifacts/
# Run all csproj tests, outputting test results as TRX files.
- name: Run Tests (x86)
shell: pwsh
if: "${{ matrix.runner.arch == 'x86' }}"
run: |
& "${{ steps.dotnet-path.outputs.exe-path }}" test AsmResolver.sln `
--arch x86 `
--configuration Release `
--property:VersionSuffix=${{needs.get-version.outputs.version_suffix}} `
--property:CheckEolTargetFramework=false `
--logger "trx" `
--logger "console;verbosity=minimal"
- name: Run Tests (x64)
shell: pwsh
if: "${{ matrix.runner.arch == 'x64' }}"
run: |
& "${{ steps.dotnet-path.outputs.exe-path }}" test AsmResolver.sln `
--configuration Release `
--property:VersionSuffix=${{needs.get-version.outputs.version_suffix}} `
--property:CheckEolTargetFramework=false `
--logger "trx" `
--logger "console;verbosity=minimal"
# Collect all trx files and upload them.
- name: Upload Test Results
uses: actions/upload-artifact@v6
if: always()
with:
name: test-results-${{matrix.runner.image}}-${{matrix.runner.arch}}
path: '**/*.trx'
if-no-files-found: 'warn'
retention-days: 1
# Job to publish to nuget feeds.
publish:
name: Publish NuGet Packages
runs-on: ubuntu-24.04
needs: [test]
if: ${{github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master'}}
steps:
- uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Download Build Artifacts
uses: actions/download-artifact@v7
with:
name: build-artifacts
path: artifacts/
- name: Push to NuGet Nightly`
if: ${{github.ref == 'refs/heads/development'}}
shell: pwsh
env:
NIGHTLY_NUGET_API_KEY: ${{secrets.NIGHTLY_NUGET_API_KEY}}
NIGHTLY_NUGET_SOURCE: ${{secrets.NIGHTLY_NUGET_SOURCE}}
run: dotnet nuget push "./artifacts/**/*.nupkg" -k "$env:NIGHTLY_NUGET_API_KEY" -s "$env:NIGHTLY_NUGET_SOURCE" --skip-duplicate
- name: Push to NuGet
if: ${{github.ref == 'refs/heads/master'}}
shell: pwsh
env:
NUGET_API_KEY: ${{secrets.NUGET_API_KEY}}
run: dotnet nuget push "./artifacts/**/*.nupkg" -k "$env:NUGET_API_KEY" -s https://api.nuget.org/v3/index.json --skip-duplicate