Skip to content

Set up dotnet in dependent workflows #51

Set up dotnet in dependent workflows

Set up dotnet in dependent workflows #51

Workflow file for this run

# Copyright 2021 Yubico AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: CI build for pull requests into main and develop
# Triggers build on pull requests and pushes to the main and develop branches.
on:
pull_request:
branches:
- main
- 'develop**'
- 'release/**'
push:
branches:
- 'release/**'
jobs:
build:
# Give this job a friendly name to show in GitHub UI.
name: Build + Test the SDK
# Even though we build for multiple platforms, we only need to run
# on a single host operating system. This is because we utilize cross-
# build functionality of the dotnet build system.
runs-on: windows-latest
# Build both Debug and ReleaseWithDocs configurations. Most people are probably building 'Debug' the most often. We
# should be sure that Release also builds, and that our documentation also compiles successfully.
strategy:
matrix:
configuration: [Debug, ReleaseWithDocs]
steps:
# Checkout the local repository
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: run dotnet version
run: dotnet --version
- name: Add local NuGet repository
run: dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Yubico/index.json"
# Build the project
- name: Build Yubico.NET.SDK.sln
run: dotnet build --configuration ${{matrix.configuration}} --nologo --verbosity normal Yubico.NET.SDK.sln
# Save the built NuGet packages, just in case we need to inspect the build output.
- name: Save build artifacts
uses: actions/upload-artifact@v4
with:
name: Nuget Packages ${{matrix.configuration}}
path: |
Yubico.DotNetPolyfills/src/bin/${{matrix.configuration}}/*.nupkg
Yubico.Core/src/bin/${{matrix.configuration}}/*.nupkg
Yubico.YubiKey/src/bin/${{matrix.configuration}}/*.nupkg
- name: Save build artifacts
uses: actions/upload-artifact@v4
with:
name: Assemblies ${{matrix.configuration}}
path: |
Yubico.DotNetPolyfills/src/bin/${{matrix.configuration}}/**/*.dll
Yubico.Core/src/bin/${{matrix.configuration}}/**/*.dll
Yubico.YubiKey/src/bin/${{matrix.configuration}}/**/*.dll
# Test the project
#
# Here we call `dotnet test` on each individual test project that we want to have run as part of CI. We do this
# to skip running the integration tests which require actual YubiKeys to be present. We have tried using the filter
# capabilities of the `dotnet test` runner tool, however we have found that failures don't always register with
# GitHub when that is done.
- name: Test Yubico.YubiKey
run: dotnet test --configuration ${{matrix.configuration}} --verbosity normal --no-build --nologo Yubico.YubiKey/tests/unit/Yubico.YubiKey.UnitTests.csproj
- name: Test Yubico.Core
run: dotnet test --configuration ${{matrix.configuration}} --verbosity normal --no-build --nologo Yubico.Core/tests/Yubico.Core.UnitTests.csproj