From 15e96a92c9a92227a05e05c02e7b84cd04419479 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Tue, 29 Oct 2024 14:58:50 +0700 Subject: [PATCH 01/14] Run tests in parallel, one per framework Now that tests run on three frameworks (net461, net6.0, net8.0), we can save a lot of build time by running each framework's tests in parallel. --- .github/workflows/ci+cd.yml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci+cd.yml b/.github/workflows/ci+cd.yml index ab259f37..ac4d4186 100644 --- a/.github/workflows/ci+cd.yml +++ b/.github/workflows/ci+cd.yml @@ -26,6 +26,11 @@ 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 }} cancel-in-progress: true @@ -47,7 +52,7 @@ jobs: run: dotnet restore - name: Build - run: dotnet build --no-restore -c Release + run: dotnet build -f ${{ matrix.framework }} --no-restore -c Release - name: Install python2 for test execution run: sudo apt-get install python2 @@ -57,7 +62,7 @@ jobs: # 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 + run: dotnet test -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=RequiresUI -- NUnit.TestOutputXml=TestResults if: matrix.os == 'ubuntu-latest' - name: Test on Windows @@ -68,29 +73,30 @@ jobs: 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 @@ -99,14 +105,12 @@ 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 @@ -114,7 +118,6 @@ jobs: name: chorus-hub-installer path: | output/Release/*.msi - if: matrix.os == 'windows-latest' - name: Pack run: dotnet pack --no-restore --no-build -c Release @@ -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 From 631bb2942235e959c1048e7db45f036ef0dbc03a Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Tue, 29 Oct 2024 15:17:34 +0700 Subject: [PATCH 02/14] Ensure parallel test runs don't cancel each other --- .github/workflows/ci+cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci+cd.yml b/.github/workflows/ci+cd.yml index ac4d4186..46265258 100644 --- a/.github/workflows/ci+cd.yml +++ b/.github/workflows/ci+cd.yml @@ -32,7 +32,7 @@ jobs: - 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: From b65080356ad1f85955d908047cee4d5d468ecb21 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Tue, 29 Oct 2024 15:18:26 +0700 Subject: [PATCH 03/14] Don't specify framework for `dotnet build` step --- .github/workflows/ci+cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci+cd.yml b/.github/workflows/ci+cd.yml index 46265258..a30a86a2 100644 --- a/.github/workflows/ci+cd.yml +++ b/.github/workflows/ci+cd.yml @@ -52,7 +52,7 @@ jobs: run: dotnet restore - name: Build - run: dotnet build -f ${{ matrix.framework }} --no-restore -c Release + run: dotnet build --no-restore -c Release - name: Install python2 for test execution run: sudo apt-get install python2 From 0f0965a86da817aba532912497858fb1f9eed769 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Wed, 30 Oct 2024 11:32:43 +0700 Subject: [PATCH 04/14] Attempt to work around `dotnet test` bug If running with `--no-build`, then `dotnet test` complains about DLLs being invalid arguments, resulting in an exit code of 1 even if all tests passed. This then makes GHA think the build was a failure. The discussion in the dotnet SDK issue suggests removing `--no-build` as one possible workaround for this issue. --- .github/workflows/ci+cd.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci+cd.yml b/.github/workflows/ci+cd.yml index a30a86a2..e77a5faf 100644 --- a/.github/workflows/ci+cd.yml +++ b/.github/workflows/ci+cd.yml @@ -61,14 +61,16 @@ jobs: # 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. + # Note: we also omit `--no-build` on Linux due to dotnet SDK bug 29742, so that `dotnet test` won't complain about pre-built DLLs - name: Test on Linux - run: dotnet test -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=RequiresUI -- NUnit.TestOutputXml=TestResults + run: dotnet test -f ${{ matrix.framework }} -c Release --filter TestCategory!=RequiresUI -- NUnit.TestOutputXml=TestResults if: matrix.os == 'ubuntu-latest' - name: Test on Windows run: dotnet test --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults if: matrix.os == 'windows-latest' + # 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 From 2f7ee4abcc3f57d5ec4f3ec9df8f428303aa1d82 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Wed, 30 Oct 2024 11:39:06 +0700 Subject: [PATCH 05/14] Try doing restore-build-test in one go on Linux Otherwise we get errors about the dotnet restore not being done for the right framework. --- .github/workflows/ci+cd.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci+cd.yml b/.github/workflows/ci+cd.yml index e77a5faf..59bfc1e4 100644 --- a/.github/workflows/ci+cd.yml +++ b/.github/workflows/ci+cd.yml @@ -48,11 +48,14 @@ jobs: 6.0.x 8.0.x + # We skip restore and build steps on Linux due to a dotnet SDK bug - 2024-10-30 RM - name: Restore run: dotnet restore + if: matrix.os == 'windows-latest' - name: Build run: dotnet build --no-restore -c Release + if: matrix.os == 'windows-latest' - name: Install python2 for test execution run: sudo apt-get install python2 @@ -61,7 +64,7 @@ jobs: # 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. - # Note: we also omit `--no-build` on Linux due to dotnet SDK bug 29742, so that `dotnet test` won't complain about pre-built DLLs + # Note: we also omit `--no-build` on Linux due to dotnet SDK bug 29742, so that `dotnet test` won't complain about pre-built DLLs - 2024-10-30 RM - name: Test on Linux run: dotnet test -f ${{ matrix.framework }} -c Release --filter TestCategory!=RequiresUI -- NUnit.TestOutputXml=TestResults if: matrix.os == 'ubuntu-latest' From a02ce1169fcf007058fd563b7227cbb631b63434 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Wed, 30 Oct 2024 12:07:08 +0700 Subject: [PATCH 06/14] Try restoring for specific target framework --- .github/workflows/ci+cd.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci+cd.yml b/.github/workflows/ci+cd.yml index 59bfc1e4..ba4fd399 100644 --- a/.github/workflows/ci+cd.yml +++ b/.github/workflows/ci+cd.yml @@ -48,14 +48,11 @@ jobs: 6.0.x 8.0.x - # We skip restore and build steps on Linux due to a dotnet SDK bug - 2024-10-30 RM - name: Restore - run: dotnet restore - if: matrix.os == 'windows-latest' + run: dotnet restore -p:TargetFramework=${{ matrix.framework }} - name: Build - run: dotnet build --no-restore -c Release - if: matrix.os == 'windows-latest' + run: dotnet build --no-restore -c Release -f ${{ matrix.framework }} - name: Install python2 for test execution run: sudo apt-get install python2 From 57a9be59a81129bbb4382238f3fd9c7310559b37 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Wed, 30 Oct 2024 12:12:42 +0700 Subject: [PATCH 07/14] Try specifying platform on Linux Also, forgot to specify target framework on Windows; no wonder it was taking so much longer! --- .github/workflows/ci+cd.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci+cd.yml b/.github/workflows/ci+cd.yml index ba4fd399..7d98b174 100644 --- a/.github/workflows/ci+cd.yml +++ b/.github/workflows/ci+cd.yml @@ -49,10 +49,10 @@ jobs: 8.0.x - name: Restore - run: dotnet restore -p:TargetFramework=${{ matrix.framework }} + run: dotnet restore - name: Build - run: dotnet build --no-restore -c Release -f ${{ matrix.framework }} + run: dotnet build --no-restore -c Release - name: Install python2 for test execution run: sudo apt-get install python2 @@ -63,11 +63,11 @@ jobs: # the syntax to access that is different on Windows vs Linux. # Note: we also omit `--no-build` on Linux due to dotnet SDK bug 29742, so that `dotnet test` won't complain about pre-built DLLs - 2024-10-30 RM - name: Test on Linux - run: dotnet test -f ${{ matrix.framework }} -c Release --filter TestCategory!=RequiresUI -- NUnit.TestOutputXml=TestResults + run: dotnet test -f ${{ matrix.framework }} --no-build --runtime linux-x64 -c Release --filter TestCategory!=RequiresUI -- NUnit.TestOutputXml=TestResults if: matrix.os == 'ubuntu-latest' - name: Test on Windows - run: dotnet test --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults + run: dotnet test -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults if: matrix.os == 'windows-latest' # 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 From 41d360a43ca3220d39b11af632c04dc4feb42b13 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Wed, 30 Oct 2024 12:14:52 +0700 Subject: [PATCH 08/14] Try not specifying runtime for Linux --- .github/workflows/ci+cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci+cd.yml b/.github/workflows/ci+cd.yml index 7d98b174..dcf0af8b 100644 --- a/.github/workflows/ci+cd.yml +++ b/.github/workflows/ci+cd.yml @@ -63,7 +63,7 @@ jobs: # the syntax to access that is different on Windows vs Linux. # Note: we also omit `--no-build` on Linux due to dotnet SDK bug 29742, so that `dotnet test` won't complain about pre-built DLLs - 2024-10-30 RM - name: Test on Linux - run: dotnet test -f ${{ matrix.framework }} --no-build --runtime linux-x64 -c Release --filter TestCategory!=RequiresUI -- NUnit.TestOutputXml=TestResults + run: dotnet test -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=RequiresUI -- NUnit.TestOutputXml=TestResults if: matrix.os == 'ubuntu-latest' - name: Test on Windows From 49b1b2a49d9d2396eef83624341115494cdd1052 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Tue, 5 Nov 2024 15:12:26 +0700 Subject: [PATCH 09/14] ChorusMerge tests should run on all frameworks Since ChorusMerge runs on net461;net6.0;net8.0, the ChorusMerge tests should be run on all the same frameworks. --- src/ChorusMerge.Tests/ChorusMerge.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ChorusMerge.Tests/ChorusMerge.Tests.csproj b/src/ChorusMerge.Tests/ChorusMerge.Tests.csproj index 05545f26..2e713030 100644 --- a/src/ChorusMerge.Tests/ChorusMerge.Tests.csproj +++ b/src/ChorusMerge.Tests/ChorusMerge.Tests.csproj @@ -4,6 +4,7 @@ ChorusMerge.Tests ChorusMerge.Tests Unit tests for LibChorus.dll + net461;net6.0;net8.0 true false From b1d6cb5cdf62be5b07783bb8471f5baf72bf590a Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Tue, 5 Nov 2024 15:18:10 +0700 Subject: [PATCH 10/14] Explicitly specify test project per step Also only run Chorus.Tests on net461, since it's not defined for net6.0 and net8.0. --- .github/workflows/ci+cd.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci+cd.yml b/.github/workflows/ci+cd.yml index dcf0af8b..26845083 100644 --- a/.github/workflows/ci+cd.yml +++ b/.github/workflows/ci+cd.yml @@ -58,17 +58,15 @@ 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. - # Note: we also omit `--no-build` on Linux due to dotnet SDK bug 29742, so that `dotnet test` won't complain about pre-built DLLs - 2024-10-30 RM - - name: Test on Linux - run: dotnet test -f ${{ matrix.framework }} --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 -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults - if: matrix.os == 'windows-latest' + - name: Test LibChorus + run: dotnet test src/LibChorus.Tests/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 From 39c47f5382088fde847cd6694d4fbcee7e55af10 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Tue, 5 Nov 2024 15:44:06 +0700 Subject: [PATCH 11/14] Correct path to LibChorus tests --- .github/workflows/ci+cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci+cd.yml b/.github/workflows/ci+cd.yml index 26845083..799efd5f 100644 --- a/.github/workflows/ci+cd.yml +++ b/.github/workflows/ci+cd.yml @@ -66,7 +66,7 @@ jobs: run: dotnet test src/ChorusMerge.Tests/ChorusMerge.Tests.csproj -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults - name: Test LibChorus - run: dotnet test src/LibChorus.Tests/LibChorus.Tests.csproj -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults + 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 From ffdb2c46adadc9a42835b617d9cc03a24ca2767e Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Wed, 6 Nov 2024 11:52:21 +0700 Subject: [PATCH 12/14] lowered NUnit3TestAdapter version to a version which supports net461 --- src/Chorus.Tests/Chorus.Tests.csproj | 2 +- src/ChorusHubTests/ChorusHubTests.csproj | 2 +- src/ChorusMerge.Tests/ChorusMerge.Tests.csproj | 2 +- src/LibChorusTests/LibChorus.Tests.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Chorus.Tests/Chorus.Tests.csproj b/src/Chorus.Tests/Chorus.Tests.csproj index 835c0f3f..eb7391b3 100644 --- a/src/Chorus.Tests/Chorus.Tests.csproj +++ b/src/Chorus.Tests/Chorus.Tests.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/ChorusHubTests/ChorusHubTests.csproj b/src/ChorusHubTests/ChorusHubTests.csproj index fd08abfe..657938e5 100644 --- a/src/ChorusHubTests/ChorusHubTests.csproj +++ b/src/ChorusHubTests/ChorusHubTests.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/ChorusMerge.Tests/ChorusMerge.Tests.csproj b/src/ChorusMerge.Tests/ChorusMerge.Tests.csproj index 2e713030..392edefa 100644 --- a/src/ChorusMerge.Tests/ChorusMerge.Tests.csproj +++ b/src/ChorusMerge.Tests/ChorusMerge.Tests.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/LibChorusTests/LibChorus.Tests.csproj b/src/LibChorusTests/LibChorus.Tests.csproj index 1654a1ba..523dab49 100644 --- a/src/LibChorusTests/LibChorus.Tests.csproj +++ b/src/LibChorusTests/LibChorus.Tests.csproj @@ -15,7 +15,7 @@ - + From 1837f1db033791f7dbd3b9721ada507b32517fb9 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Wed, 6 Nov 2024 11:53:33 +0700 Subject: [PATCH 13/14] run Chorus hub tests in CI --- .github/workflows/ci+cd.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci+cd.yml b/.github/workflows/ci+cd.yml index 799efd5f..9e847896 100644 --- a/.github/workflows/ci+cd.yml +++ b/.github/workflows/ci+cd.yml @@ -62,6 +62,10 @@ jobs: 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 Chorus Hub + run: dotnet test src/ChorusHubTests/ChorusHubTests.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 From 1eaa017b87ebbb18c6fa64ddb22e474ee1a998b0 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Thu, 7 Nov 2024 11:26:00 +0700 Subject: [PATCH 14/14] Checkout sources before building installer Now that the installer job is not running in the same job matrix as the tests, we need to re-run the dotnet restore and build steps again. --- .github/workflows/ci+cd.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/ci+cd.yml b/.github/workflows/ci+cd.yml index 9e847896..28d84c82 100644 --- a/.github/workflows/ci+cd.yml +++ b/.github/workflows/ci+cd.yml @@ -85,6 +85,17 @@ jobs: runs-on: windows-latest needs: build-and-test steps: + - name: Checkout + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 + with: + fetch-depth: 0 # fetch full history for GitVersion + + - name: Restore + run: dotnet restore + + - name: Build + run: dotnet build --no-restore -c Release + - name: Checkout Chorus Help # required for Chorus Merge Module uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 with: