Enable unit tests on more platforms #2282
Workflow file for this run
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
name: 'Continuous integration' | |
on: | |
workflow_dispatch: | |
inputs: | |
publish: | |
description: If this build should publish nuget packages | |
required: true | |
type: boolean | |
preview: | |
description: If this is a preview package | |
required: true | |
type: boolean | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
env: | |
configuration: Release | |
jobs: | |
build: | |
name: Build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest, macos-latest, ubuntu-latest] | |
include: | |
- os: windows-latest | |
shell: msys2 {0} | |
- os: ubuntu-latest | |
shell: bash | |
- os: macos-latest | |
shell: bash | |
defaults: | |
run: | |
shell: ${{ matrix.shell }} | |
steps: | |
- name: Prepare git | |
run: git config --global core.autocrlf false | |
shell: bash | |
- name: Checkout with submodules | |
uses: actions/checkout@v3 | |
with: | |
submodules: 'true' | |
- name: Prepare .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: | | |
6.0.x | |
7.0.x | |
- name: Install dependencies (Windows) | |
if: ${{ matrix.os == 'windows-latest' }} | |
uses: msys2/setup-msys2@v2 | |
with: | |
path-type: inherit # Inherit the path so that dotnet can be found | |
update: true | |
install: >- | |
mingw-w64-x86_64-cairo | |
mingw-w64-x86_64-gcc | |
mingw-w64-x86_64-gdk-pixbuf2 | |
mingw-w64-x86_64-gobject-introspection | |
mingw-w64-x86_64-meson | |
- name: Install dependencies (macOS) | |
if: ${{ matrix.os == 'macos-latest' }} | |
run: brew install cairo gdk-pixbuf gobject-introspection meson | |
# Note: gobject-introspection is the actual dependency, but | |
# libgirepository1.0-dev is needed so that meson can find it via pkg-config | |
- name: Install dependencies (Linux) | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: sudo apt update && sudo apt install meson libgirepository1.0-dev | |
- name: Compile native library | |
run: dotnet fsi GenerateGirTestLib.fsx | |
working-directory: './src' | |
- name: Call generator | |
run: dotnet fsi GenerateLibs.fsx GirTest-0.1.gir | |
working-directory: './src' | |
- name: Build complete solution | |
run: dotnet build --nologo -c ${{ env.configuration }} | |
working-directory: './src' | |
- name: Build libraries only | |
run: dotnet build --nologo -c ${{ env.configuration }} GirCore.Libs.slnf | |
working-directory: './src' | |
- name: Verify code format | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: dotnet format GirCore.sln --no-restore --verify-no-changes --exclude *.Generated.cs | |
working-directory: './src' | |
- name: Run unit tests | |
run: dotnet test --no-restore -c ${{ env.configuration }} --filter "TestCategory=UnitTest | TestCategory=BindingTest" | |
working-directory: './src' | |
- name: Run integration tests | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: dotnet test --no-restore -c ${{ env.configuration }} --filter TestCategory=IntegrationTest | |
working-directory: './src' | |
- name: Get current time | |
if: ${{ github.event.inputs.publish == 'true' && github.event.inputs.preview == 'true' && matrix.os == 'ubuntu-latest' }} | |
uses: josStorer/[email protected] | |
id: current-time | |
with: | |
format: YYYYMMDD-HHmmss | |
- name: Pack preview version | |
if: ${{ github.event.inputs.publish == 'true' && github.event.inputs.preview == 'true' && matrix.os == 'ubuntu-latest'}} | |
run: dotnet pack --no-build --nologo -c ${{ env.configuration }} --version-suffix "CI-${{ steps.current-time.outputs.formattedTime }}" -o ../Nuget | |
working-directory: './src' | |
- name: Pack release version | |
if: ${{ github.event.inputs.publish == 'true' && github.event.inputs.preview == 'false' && matrix.os == 'ubuntu-latest' }} | |
run: dotnet pack --no-build --nologo -c ${{ env.configuration }} -o ../Nuget | |
working-directory: './src' | |
- name: Publish to nuget org | |
if: ${{ github.event.inputs.publish == 'true' && matrix.os == 'ubuntu-latest' }} | |
run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s nuget.org | |
working-directory: './Nuget' | |