Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests in parallel, one per framework #354

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
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
42 changes: 22 additions & 20 deletions .github/workflows/ci+cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
framework: [net461, net6.0, net8.0]
exclude:
# dotnet on Linux cannot build net461 without additional, unnecessary, work
- os: ubuntu-latest
framework: net461
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.framework }}
cancel-in-progress: true

steps:
Expand All @@ -53,44 +58,45 @@ jobs:
run: sudo apt-get install python2
if: matrix.os == 'ubuntu-latest'

# Unfortunately we need two test steps because we need different filters.
# We could conditionally set an environment variable, but unfortunately
# the syntax to access that is different on Windows vs Linux.
- name: Test on Linux
run: dotnet test --no-build -c Release --filter TestCategory!=RequiresUI -- NUnit.TestOutputXml=TestResults
if: matrix.os == 'ubuntu-latest'
- name: Test Chorus
run: dotnet test src/Chorus.Tests/Chorus.Tests.csproj -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults
if: matrix.framework == 'net461'

- name: Test ChorusMerge
run: dotnet test src/ChorusMerge.Tests/ChorusMerge.Tests.csproj -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults

- name: Test on Windows
run: dotnet test --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults
if: matrix.os == 'windows-latest'
- name: Test LibChorus
run: dotnet test src/LibChorusTests/LibChorus.Tests.csproj -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults

# TODO: Give each test result its own name based on OS and framework and change the test-results.yml workflow accordingly, so that they don't overwrite each other
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Test Results (${{matrix.os}})
name: Test Results (${{ matrix.framework }} on ${{matrix.os}})
path: "**/TestResults/*.xml"

build-installers:
name: "Build Windows installers"
runs-on: windows-latest
needs: build-and-test
steps:
- name: Checkout Chorus Help # required for Chorus Merge Module
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
with:
repository: sillsdev/chorushelp
path: DistFiles/Help
if: matrix.os == 'windows-latest'

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@34cfbaee7f672c76950673338facd8a73f637506 # v1.1.3
if: matrix.os == 'windows-latest'

# ChorusMergeModule.msm is used by FieldWorks, FLExBridge, and possibly WeSay installers (as of 2022.12).
# CMM must be built after tests have been run, since the fixutf8.pyc files are generated only when the .py files are run.
- name: Build Merge Module
run: msbuild src/Installer/ChorusMergeModule.wixproj
if: matrix.os == 'windows-latest'

- name: Pack Merge Module
run: msbuild src/Installer/ChorusMergeModule.wixproj -t:pack
if: matrix.os == 'windows-latest'

- name: Upload Merge Module
uses: actions/upload-artifact@v4
Expand All @@ -99,22 +105,19 @@ jobs:
path: |
output/Release/*.msm
output/*.nupkg
if: matrix.os == 'windows-latest'

- name: Build Chorus Hub Installer
run: |
msbuild src/Installer/ChorusHub.wixproj /t:Restore
msbuild src/Installer/ChorusHub.wixproj /t:StampLicenseYear
msbuild src/Installer/ChorusHub.wixproj /t:Build
if: matrix.os == 'windows-latest'

- name: Upload Chorus Hub Installer
uses: actions/upload-artifact@v4
with:
name: chorus-hub-installer
path: |
output/Release/*.msi
if: matrix.os == 'windows-latest'

- name: Pack
run: dotnet pack --no-restore --no-build -c Release
Expand All @@ -126,12 +129,11 @@ jobs:
path: |
output/*.nupkg
output/*.snupkg
if: matrix.os == 'ubuntu-latest'

publish-nuget:
name: "Publish NuGet package"
runs-on: ubuntu-latest
needs: build-and-test
needs: build-installers
if: github.event_name == 'push'
steps:
- name: Download Artifacts
Expand Down
2 changes: 1 addition & 1 deletion src/Chorus/UI/Sync/SyncStartModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ internal bool GetUsbStatusLink(IUsbDriveLocator usbDriveLocator, out string mess
try
{
var first = usbDrives[0];
if (!Platform.IsMono)
if (Platform.IsWindows)
{
message = string.Format(LocalizationManager.GetString(
"GetUsbStatus.DriveInfoAndFreeSpace",
Expand Down
1 change: 1 addition & 0 deletions src/ChorusMerge.Tests/ChorusMerge.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<RootNamespace>ChorusMerge.Tests</RootNamespace>
<AssemblyTitle>ChorusMerge.Tests</AssemblyTitle>
<Description>Unit tests for LibChorus.dll</Description>
<TargetFrameworks>net461;net6.0;net8.0</TargetFrameworks>
<IsTestProject>true</IsTestProject>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
26 changes: 19 additions & 7 deletions src/LibChorus/FileTypeHandlers/text/TextFileTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace Chorus.FileTypeHandlers.text
[Export(typeof(IChorusFileTypeHandler))]
public class TextFileTypeHandler : IChorusFileTypeHandler
{
//NB: there is a post-build step in this project which copies the diff3 folder into the output on Windows
private static string _diff3Exe = Platform.IsWindows ? "diff3/bin/diff3.exe" : "diff3";
internal TextFileTypeHandler()
{}

Expand Down Expand Up @@ -64,26 +66,36 @@ public static string GetRawMerge(string oursPath, string commonPath, string thei
{
//NB: surrounding with quotes didn't cut it to get past paths with spaces

return RunProcess("diff3/bin/diff3.exe", "-m " + LongToShortConverter.GetShortPath(oursPath) + " " +
LongToShortConverter.GetShortPath(commonPath) + " " +
LongToShortConverter.GetShortPath(theirPath));
return RunProcess(_diff3Exe, new string[] {"-m", LongToShortConverter.GetShortPath(oursPath),
LongToShortConverter.GetShortPath(commonPath),
LongToShortConverter.GetShortPath(theirPath) });
}

protected static string SurroundWithQuotes(string path)
{
return "\"" + path + "\"";
}

public static string RunProcess(string filePath, string arguments)
public static string RunProcess(string filePath, string[] arguments)
{
Process p = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;

//NB: there is a post-build step in this project which copies the diff3 folder into the output
p.StartInfo.FileName = filePath;
p.StartInfo.Arguments = arguments;
// netstandard2.1 has p.StartInfo.ArgumentList that would solve all our problems, but we have to target netstandard2.0 so we have to do this ourselves
var quotedArgs = new List<string>(arguments.Length);
foreach (var arg in arguments)
{
if (arg.Contains(" ")) {
quotedArgs.Add("\"" + arg.Replace("\"", "\\\"") + "\"");
} else {
quotedArgs.Add(arg);
}
}
p.StartInfo.Arguments = string.Join(" ", quotedArgs);
p.StartInfo.CreateNoWindow = true;
p.Start();
p.WaitForExit();
Expand Down Expand Up @@ -154,7 +166,7 @@ private static extern int GetShortPathName(

public static string GetShortPath(string path)
{
if (Platform.IsMono)
if (!Platform.IsWindows)
return path;

var shortPath = new StringBuilder(255);
Expand Down
2 changes: 1 addition & 1 deletion src/LibChorus/VcsDrivers/Mercurial/HgRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ public List<Revision> GetRevisionsFromQueryResultText(string queryResultText)
switch (label)
{
default:
if (Platform.IsMono)
if (Platform.IsLinux)
infiniteLoopChecker++;
break;
case "changeset":
Expand Down
3 changes: 2 additions & 1 deletion src/LibChorus/merge/text/PartialTextMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ public static string GetRawMerge(string oursPath, string commonPath, string thei
p.StartInfo.RedirectStandardOutput = true;

//NB: there is a post-build step in this project which copies the diff3 folder into the output
p.StartInfo.FileName = "diff3/bin/diff3.exe";
var filename = File.Exists("diff3/bin/diff3.exe") ? "diff3/bin/diff3.exe" : "diff3"; // On Linux, just use diff3 from the PATH
p.StartInfo.FileName = filename;
p.StartInfo.Arguments = "-m " + oursPath + " "+commonPath+" "+theirPath;
p.StartInfo.CreateNoWindow = true;
p.Start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Dispose()
private static void UpdateExtensions()
{
var extensions = new Dictionary<string, string>();
if (!Platform.IsMono)
if (Platform.IsWindows)
extensions.Add("eol", ""); //for converting line endings on windows machines
extensions.Add("hgext.graphlog", ""); //for more easily readable diagnostic logs
extensions.Add("convert", ""); //for catastrophic repair in case of repo corruption
Expand Down
Loading