Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
name: Deploy

on:
workflow_dispatch:
release:
types: [published]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: |
3.1.x
6.0.x
7.0.x
- name: Retore Workload
run: dotnet workload restore
- name: Restore dependencies
run: dotnet restore
- name: Set Assembly Version
run: ./build.sh --task=GitVersion --configuration=Release
- name: Build Library
run: dotnet build ./Float.TinCan.ActivityLibrary/Float.TinCan.ActivityLibrary.csproj --configuration Release --no-restore
- name: Update Version
run: sed -i "s/<Version><\/Version>/<Version>${{ github.event.release.name }}<\/Version>/" ./Float.TinCan.ActivityLibrary/Float.TinCan.ActivityLibrary.csproj
- name: Pack and Upload
run: dotnet pack --configuration Release --no-restore

- name: Deploy to NuGet
env:
FLOAT_NUGET_TOKEN: ${{ secrets.FLOAT_NUGET_TOKEN }}
run: ./build.sh --task=Deploy --configuration=Release --nugetUrl="https://api.nuget.org/v3/index.json" --nugetToken="${FLOAT_NUGET_TOKEN}"
run: dotnet nuget push ./Float.TinCan.ActivityLibrary/bin/Release/Float.TinCan.ActivityLibrary.${{ github.event.release.name }}.nupkg --api-key "${FLOAT_NUGET_TOKEN}" --source https://api.nuget.org/v3/index.json
34 changes: 22 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,28 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.x
6.0.x
7.0.x
- name: Retore Workload
run: dotnet workload restore
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal --logger:"trx;"
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
**/TestResults/*.trx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>9.0</LangVersion>
<UseMaui>true</UseMaui>
</PropertyGroup>
<ItemGroup>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="NunitXml.TestLogger" Version="3.0.127" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NunitXml.TestLogger" Version="3.1.15" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
17 changes: 14 additions & 3 deletions Float.TinCan.ActivityLibrary/ActivityDownloader.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Threading.Tasks;
using Float.FileDownloader;
using Float.TinCan.ActivityLibrary.Definition;
#if NETSTANDARD
using Xamarin.Forms;
#else
using Microsoft.Maui;
using Microsoft.Maui.ApplicationModel;
#endif

namespace Float.TinCan.ActivityLibrary
{
Expand Down Expand Up @@ -60,11 +66,16 @@ public static DownloadStatus Download(IActivity activity, IRemoteFileProvider fi
{
tasks?.Exception?.Handle(exc =>
{
Device.BeginInvokeOnMainThread(() =>
Action mainThreadCode = () =>
{
DeleteDownloadsForActivity(activity, metaDataProvider);
ActiveDownloads.Remove(activity);
});
};
#if NETSTANDARD
Device.BeginInvokeOnMainThread(mainThreadCode);
#else
MainThread.BeginInvokeOnMainThread(mainThreadCode);
#endif

return true;
});
Expand Down
51 changes: 41 additions & 10 deletions Float.TinCan.ActivityLibrary/ActivityLaunchCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TinCan;
#if NETSTANDARD
using Xamarin.Forms;
#else
using Microsoft.Maui;
using Microsoft.Maui.ApplicationModel;
using Microsoft.Maui.Controls;
#endif

namespace Float.TinCan.ActivityLibrary
{
Expand Down Expand Up @@ -111,7 +117,7 @@ public override void Start()
}
else
{
Device.BeginInvokeOnMainThread(async () =>
Action mainThreadCode = async () =>
{
try
{
Expand All @@ -129,7 +135,12 @@ public override void Start()
downloadStatus.DownloadsCompleted += HandleDownloadCompleted;
downloadStatus.DownloadsCancelled += HandleDownloadCancelled;
await ShowDownloadStatus(CreateDownloadStatusPage(downloadStatus));
});
};
#if NETSTANDARD
Device.BeginInvokeOnMainThread(mainThreadCode);
#else
MainThread.BeginInvokeOnMainThread(mainThreadCode);
#endif
}
}

Expand Down Expand Up @@ -243,11 +254,16 @@ protected virtual void OnActivityFinished(object sender, EventArgs args)
/// </summary>
protected void ShowCompletionScreen()
{
Device.BeginInvokeOnMainThread(async () =>
Action mainThreadCode = async () =>
{
var completionPage = CreateActivityCompletePage(AvailablePostAssessments != null && AvailablePostAssessments.Any());
await NavigationContext.PresentPageAsync(completionPage);
});
};
#if NETSTANDARD
Device.BeginInvokeOnMainThread(mainThreadCode);
#else
MainThread.BeginInvokeOnMainThread(mainThreadCode);
#endif
}

/// <summary>
Expand All @@ -273,10 +289,15 @@ protected virtual void HandleCancelDownloadRequested(object sender, EventArgs ar
/// <param name="args">Arguments related to the event.</param>
protected virtual void HandleActivityFinished(object sender, EventArgs args)
{
Device.BeginInvokeOnMainThread(() =>
Action mainThreadCode = () =>
{
this.Activity.CompletionDate = DateTimeOffset.Now;
});
};
#if NETSTANDARD
Device.BeginInvokeOnMainThread(mainThreadCode);
#else
MainThread.BeginInvokeOnMainThread(mainThreadCode);
#endif

if (args is not StatementEventArgs statementArgs)
{
Expand Down Expand Up @@ -319,10 +340,15 @@ protected virtual void HandleActivityProgressed(object sender, EventArgs args)
return;
}

Device.BeginInvokeOnMainThread(() =>
Action mainThreadCode = () =>
{
this.Activity.PercentComplete = (double)percentComplete / 100;
});
};
#if NETSTANDARD
Device.BeginInvokeOnMainThread(mainThreadCode);
#else
MainThread.BeginInvokeOnMainThread(mainThreadCode);
#endif
}

/// <summary>
Expand Down Expand Up @@ -414,7 +440,7 @@ protected virtual void HandleDownloadError(object sender, EventArgs args)

void CreateRunnerAndHandleErrors()
{
Device.BeginInvokeOnMainThread(async () =>
Action mainThreadCode = async () =>
{
try
{
Expand All @@ -427,7 +453,12 @@ void CreateRunnerAndHandleErrors()
OnActivityLaunchException(e);
Finish(EventArgs.Empty);
}
});
};
#if NETSTANDARD
Device.BeginInvokeOnMainThread(mainThreadCode);
#else
MainThread.BeginInvokeOnMainThread(mainThreadCode);
#endif
}

/// <summary>
Expand Down
7 changes: 6 additions & 1 deletion Float.TinCan.ActivityLibrary/Definition/IActivityViewer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using Xamarin.Forms;
#if NETSTANDARD
using Xamarin.Forms;
#else
using Microsoft.Maui;
using Microsoft.Maui.Controls;
#endif

namespace Float.TinCan.ActivityLibrary.Definition
{
Expand Down
19 changes: 12 additions & 7 deletions Float.TinCan.ActivityLibrary/Float.TinCan.ActivityLibrary.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2;net6.0;net7.0</TargetFrameworks>
<AssemblyName>Float.TinCan.ActivityLibrary</AssemblyName>
<AssemblyAuthor>Float</AssemblyAuthor>
<AssemblyDescription>A library for starting xAPI activities.</AssemblyDescription>
Expand All @@ -11,6 +11,9 @@
<Title>$(AssemblyName)</Title>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<LangVersion>9.0</LangVersion>
<ReleaseVersion>1.0.0</ReleaseVersion>
<Version></Version>
<UseMaui>true</UseMaui>
</PropertyGroup>
<ItemGroup>
<AdditionalFiles Include="$(SolutionDir)/stylecop.json" />
Expand All @@ -29,17 +32,19 @@
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Float.FileDownloader" Version="[1.0.0.5,2)" />
<PackageReference Include="Float.TinCan" Version="[1.0.3.29,2)" />
<PackageReference Include="Float.TinCan.LocalLRSServer" Version="[1.0.0.24,2)" />
<PackageReference Include="Xamarin.Forms" Version="[5.0.0.1874,6)" />
<PackageReference Include="Float.Core" Version="[1.0.0.50,2)" />
<PackageReference Include="Float.FileDownloader" Version="1.0.0.44" />
<PackageReference Include="Float.TinCan" Version="1.0.3.30" />
<PackageReference Include="Float.TinCan.LocalLRSServer" Version="2.0.0.1" />
<PackageReference Include="Float.Core" Version="2.0.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard'))">
<PackageReference Include="Xamarin.Forms" Version="[5.0.0.1874,6)" />
</ItemGroup>
<ItemGroup>
<None Include="../readme.md" Pack="true" PackagePath="\"/>
<None Include="../readme.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ Task("GitVersion")
});

Task("Build")
.IsDependentOn("RestorePackages")
.IsDependentOn("GitVersion")
.Does(() =>
{
Expand Down