Skip to content

Commit

Permalink
Fixes #2426 Build on GitHub Actions instead of AppVeyor (#2428)
Browse files Browse the repository at this point in the history
* Fixes #2426 Build on GitHub Actions instead of AppVeyor

* add msbuild to path

* restore

* windows env variables

* consolidate packages

* reduce number of build digits

* remove appveyor from sln

* coverage GHA

* rename action

* tokenize

* using: "composite"

* detailedXML

* remove unused switches

* use OSP workflow

* ref main

* coverage on a schedule
  • Loading branch information
rwmcintosh authored Feb 19, 2025
1 parent 0f8f775 commit 1e261be
Show file tree
Hide file tree
Showing 59 changed files with 285 additions and 250 deletions.
132 changes: 132 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Build and Publish

on:
push:
pull_request:
branches:
- develop

env:
MAJOR: 12
MINOR: 1
RUN: ${{ github.run_number }}

jobs:
get-version:
runs-on: ubuntu-latest
outputs:
BUILD_ID: ${{ steps.get_build_id.outputs.BUILD_ID}}
APP_VERSION: ${{ steps.get_app_version.outputs.APP_VERSION}}
steps:
- name: Get New Build Number
id: get_build_id
shell: bash
run: |
# Get the build ID
if [[ "${{ github.event_name }}" == 'push' && "${{ github.ref_name }}" == "${{ github.event.repository.default_branch }}" ]]; then
# Fetch the latest version from the organization NuGet package
response=$(curl -s -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/Open-Systems-Pharmacology/packages/nuget/OSPSuite.Core/versions)
# Log the raw response for debugging
echo "API Response: $response"
# Check if the response indicates a package not found error or is not valid JSON
if echo "$response" | jq -e '.message == "Package not found." or (.[0].name // empty | length == 0)' >/dev/null 2>&1; then
# Set the build number to 15 if no package is found or response is invalid (since the last build was 12.1.14)
new_build_id=15
else
latest_version=$(echo "$response" | jq -r '.[0].name // empty')
# Extract MAJOR, MINOR from the latest version
IFS='.' read -r last_major last_minor last_build <<< "$latest_version"
# Compare with the current MAJOR, MINOR
if [[ "$last_major" -eq "${{ env.MAJOR }}" && "$last_minor" -eq "${{ env.MINOR }}" ]]; then
# Increment the last number if they match
new_build_id=$((last_build + 1))
else
# Reset build number to 0 if the current version is different
new_build_id=0
fi
fi
echo "latest build number: ${latest_version:-'None found'}"
echo "new build number: ${new_build_id}"
build_id="${new_build_id}"
else
build_id="9${{ env.RUN }}"
fi
echo "New Build ID: ${build_id}"
echo "BUILD_ID=${build_id}" >> $GITHUB_ENV
echo "BUILD_ID=${build_id}" >> $GITHUB_OUTPUT
- name: Get App Version
id: get_app_version
shell: bash
run: |
app_version="${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.BUILD_ID }}"
echo "App Version: ${app_version}"
echo "APP_VERSION=${app_version}" >> $GITHUB_ENV
echo "APP_VERSION=${app_version}" >> $GITHUB_OUTPUT
build:
runs-on: windows-latest
needs: get-version
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'true'

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2

- name: Restore dependencies
run: |
nuget sources add -username Open-Systems-Pharmacology -password ${{ secrets.GITHUB_TOKEN }} -name OSP-GitHub-Packages -source "https://nuget.pkg.github.com/Open-Systems-Pharmacology/index.json"
nuget sources add -name bddhelper -source https://ci.appveyor.com/nuget/ospsuite-bddhelper
nuget sources add -name utility -source https://ci.appveyor.com/nuget/ospsuite-utility
nuget sources add -name serializer -source https://ci.appveyor.com/nuget/ospsuite-serializer
nuget sources add -name databinding -source https://ci.appveyor.com/nuget/ospsuite-databinding
nuget sources add -name texreporting -source https://ci.appveyor.com/nuget/ospsuite-texreporting
nuget sources add -name databinding-devexpress -source https://ci.appveyor.com/nuget/ospsuite-databinding-devexpress
dotnet restore
- name: define env variables
run: |
echo "APP_VERSION=${{needs.get-version.outputs.APP_VERSION}}" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "BUILD_ID=${{needs.get-version.outputs.BUILD_ID}}" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Build
run: msbuild OSPSuite.Core.sln /p:Version=${{env.APP_VERSION}}

- name : Test
run: dotnet test .\tests\**\bin\Debug\net472\OSPSuite*Tests.dll -v normal --no-build --logger:"html;LogFileName=../testLog_Windows.html"

- name: Pack the project
run: dotnet pack .\OSPSuite.Core.sln --no-build --no-restore -o ./ -p:PackageVersion=${{env.APP_VERSION}} --configuration=Debug --include-symbols --no-build

- name: Push nupkg as artifact
# if it is a push to a branch
if: github.event_name == 'push' && github.ref_name != github.event.repository.default_branch
uses: actions/upload-artifact@v4
with:
name: OSPSuite.Core
path: ./*.nupkg

- name: Push test log as artifact
uses: actions/upload-artifact@v4
with:
name: testLog_Windows
path: ./testLog*.html

- name: Publish to GitHub registry
# if it is a merge to default branch
if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch
run: dotnet nuget push ./*.nupkg --source https://nuget.pkg.github.com/${{github.repository_owner}}/index.json --api-key ${{ secrets.GITHUB_TOKEN }}
38 changes: 38 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Code Coverage

on:
schedule:
- cron: '0 1 * * 4'

jobs:
cover:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'true'

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2

- name: Restore dependencies
run: |
nuget sources add -username Open-Systems-Pharmacology -password ${{ secrets.GITHUB_TOKEN }} -name OSP-GitHub-Packages -source "https://nuget.pkg.github.com/Open-Systems-Pharmacology/index.json"
nuget sources add -name bddhelper -source https://ci.appveyor.com/nuget/ospsuite-bddhelper
nuget sources add -name utility -source https://ci.appveyor.com/nuget/ospsuite-utility
nuget sources add -name serializer -source https://ci.appveyor.com/nuget/ospsuite-serializer
nuget sources add -name databinding -source https://ci.appveyor.com/nuget/ospsuite-databinding
nuget sources add -name texreporting -source https://ci.appveyor.com/nuget/ospsuite-texreporting
nuget sources add -name databinding-devexpress -source https://ci.appveyor.com/nuget/ospsuite-databinding-devexpress
dotnet restore
- name: Build
run: msbuild OSPSuite.Core.sln /p:Version=12.1.999


- name: Cover and report
uses: Open-Systems-Pharmacology/Workflows/.github/actions/dotCover@main
with:
xml-configuration: dotcover.xml
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 0 additions & 2 deletions OSPSuite.Core.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OSPSuite.Core", "src\OSPSui
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{25A7357D-0812-44F3-AF90-244FD752FAE2}"
ProjectSection(SolutionItems) = preProject
appveyor-coverage.yml = appveyor-coverage.yml
appveyor.yml = appveyor.yml
logo.png = logo.png
rakefile.rb = rakefile.rb
SolutionInfo.cs = SolutionInfo.cs
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
Core functionalities of the Open Systems Pharmacology Suite.

## Code Status
[![NuGet version](https://img.shields.io/nuget/v/OSPSuite.Core.svg?style=flat)](https://www.nuget.org/packages/OSPSuite.Core)
[![Build status](https://ci.appveyor.com/api/projects/status/skw2giv5jxy3pvo0/branch/develop?svg=true)](https://ci.appveyor.com/project/open-systems-pharmacology-ci/ospsuite-core/branch/develop)
[![Build status](https://img.shields.io/github/actions/workflow/status/Open-Systems-Pharmacology/OSPSuite.Core/build-and-publish.yml?logo=nuget&label=Build%20status)](https://github.com/Open-Systems-Pharmacology/OSPSuite.Core/actions/workflows/build-and-publish.yml)
[![Coverage status](https://codecov.io/gh/Open-Systems-Pharmacology/OSPSuite.Core/branch/develop/graph/badge.svg)](https://codecov.io/gh/Open-Systems-Pharmacology/OSPSuite.Core)

## Code of conduct
Expand Down
42 changes: 0 additions & 42 deletions appveyor-coverage.yml

This file was deleted.

64 changes: 0 additions & 64 deletions appveyor.yml

This file was deleted.

26 changes: 26 additions & 0 deletions dotcover.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<CoverageParams>
<TargetArguments>
Tests\OSPSuite.Core.Tests\bin\Debug\net472\OSPSuite.Core.Tests.dll
Tests\OSPSuite.Core.IntegrationTests\bin\Debug\net472\OSPSuite.Core.IntegrationTests.dll
Tests\OSPSuite.Presentation.Tests\bin\Debug\net472\OSPSuite.Presentation.Tests.dll
Tests\OSPSuite.Infrastructure.Tests\bin\Debug\net472\OSPSuite.Infrastructure.Tests.dll
Tests\OSPSuite.R.Tests\bin\Debug\net472\OSPSuite.R.Tests.dll
Tests\OSPSuite.UI.Tests\bin\Debug\net472\OSPSuite.UI.Tests.dll
</TargetArguments>
<TargetWorkingDir>./</TargetWorkingDir>

<ExcludeFileMasks>
<Mask>src/**/*.Designer.cs</Mask>
<Mask>src/OSPSuite.UI/Views/**</Mask>
<Mask>src/OSPSuite.UI/Controls/**</Mask>
</ExcludeFileMasks>

<Filters>
<ExcludeFilters>
<FilterEntry>
<ModuleMask>FakeItEasy</ModuleMask>
</FilterEntry>
</ExcludeFilters>
</Filters>
</CoverageParams>
5 changes: 0 additions & 5 deletions src/OSPSuite.Assets.Images/OSPSuite.Assets.Images.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>OSPSuite.Assets.Images</AssemblyName>
<Version>1.0.0</Version>
<PackageVersion>1.0.0</PackageVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<InformationalVersion>1.0.0.0</InformationalVersion>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<PackageProjectUrl>https://github.com/Open-Systems-Pharmacology/OSPSuite.Core</PackageProjectUrl>
Expand Down
5 changes: 0 additions & 5 deletions src/OSPSuite.Assets/OSPSuite.Assets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>OSPSuite.Assets</AssemblyName>
<Version>1.0.0</Version>
<PackageVersion>1.0.0</PackageVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<InformationalVersion>1.0.0.0</InformationalVersion>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<PackageProjectUrl>https://github.com/Open-Systems-Pharmacology/OSPSuite.Core</PackageProjectUrl>
Expand Down
9 changes: 2 additions & 7 deletions src/OSPSuite.Core/OSPSuite.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>OSPSuite.Core</AssemblyName>
<Version>1.0.0</Version>
<PackageVersion>1.0.0</PackageVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<InformationalVersion>1.0.0.0</InformationalVersion>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<PackageProjectUrl>https://github.com/Open-Systems-Pharmacology/OSPSuite.Core</PackageProjectUrl>
Expand Down Expand Up @@ -43,8 +38,8 @@
<PackageReference Include="MathNet.Numerics" Version="4.15.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.0" />
<PackageReference Include="OSPSuite.Serializer" Version="3.0.0.1" />
<PackageReference Include="OSPSuite.FuncParser" Version="4.0.0.68" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModel" Version="4.0.0.71" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.FuncParser" Version="4.0.0.73" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModel" Version="4.0.0.75" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.Utility" Version="4.1.0.6" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>1.0.0</Version>
<PackageVersion>1.0.0</PackageVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<InformationalVersion>1.0.0.0</InformationalVersion>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<PackageProjectUrl>https://github.com/Open-Systems-Pharmacology/OSPSuite.Core</PackageProjectUrl>
Expand Down
Loading

0 comments on commit 1e261be

Please sign in to comment.