From 1331356bc1650a37f98cf18d792ec7e96326e8ff Mon Sep 17 00:00:00 2001 From: Beatrix Date: Tue, 1 Oct 2024 15:41:49 -0700 Subject: [PATCH 1/8] use buildDebug --- .github/workflows/cake-build.yml | 91 +++++++++++++++++++++----------- src/build.cake | 13 +++++ 2 files changed, 72 insertions(+), 32 deletions(-) diff --git a/.github/workflows/cake-build.yml b/.github/workflows/cake-build.yml index f7fc813..431196d 100644 --- a/.github/workflows/cake-build.yml +++ b/.github/workflows/cake-build.yml @@ -2,42 +2,69 @@ on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] workflow_dispatch: +# concurrency prevents multiple instances of the workflow from running at the same time, +# using `cancel-in-progress` to cancel any existing runs. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: - runs-on: windows-latest + # this now uses a dedicated large runner from GitHub running the following specs: + # 8-core, 32GB RAM, 300GB SSD + # https://github.com/organizations/sourcegraph/settings/actions/runner-groups/6 + runs-on: 16gb_16_core_large_window_runner + # do we want to run this on forks? + if: github.repository_owner == 'sourcegraph' steps: - - uses: actions/checkout@v3 - - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.3 - - - name: ⚙️ Prepare Visual Studio - run: '&"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings' - - - name: Install Cake.Tool - run: dotnet tool install --global Cake.Tool - - - name: Restore NuGet packages - run: nuget restore src\Cody.Core\Cody.Core.csproj -PackagesDirectory src\packages - - - name: Build Release - run: | - cd src - dotnet tool restore - corepack enable - corepack install --global pnpm@8.6.7 - dotnet cake - - - name: Tests - env: - Access_Token_UI_Tests: ${{ secrets.SRC_ACCESS_TOKEN_DOTCOM }} - run: | - cd src - dotnet cake --target Tests - dotnet test .\Cody.VisualStudio.Tests\bin\Debug\Cody.VisualStudio.Tests.dll -v detailed + - uses: actions/checkout@v3 + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.3 + + - name: ⚙️ Prepare Visual Studio + run: '&"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings' + + - name: Install Cake.Tool + run: dotnet tool install --global Cake.Tool + + - name: Restore NuGet packages + run: nuget restore src\Cody.Core\Cody.Core.csproj -PackagesDirectory src\packages + + - name: Cache cody-dist + uses: actions/cache@v3 + with: + path: cody-dist/agent + key: ${{ runner.os }}-cody-dist-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-cody-dist- + + - name: Common Build Setup + run: | + cd src + dotnet tool restore + corepack enable + + - name: Build Cody Agent + run: | + cd src + corepack install --global pnpm@8.6.7 + dotnet cake --target=BuildCodyAgent + + - name: Build Extension + run: | + cd src + dotnet cake --target=BuildDebug + + - name: Tests + env: + Access_Token_UI_Tests: ${{ secrets.SRC_ACCESS_TOKEN_DOTCOM }} + run: | + cd src + dotnet test .\Cody.VisualStudio.Tests\bin\Debug\Cody.VisualStudio.Tests.dll -v detailed diff --git a/src/build.cake b/src/build.cake index f94929c..462ba7b 100644 --- a/src/build.cake +++ b/src/build.cake @@ -181,6 +181,19 @@ Task("Build") }); }); +Task("BuildDebug") + .IsDependentOn("DownloadNode") + .IsDependentOn("Restore") + .Does(() => +{ + MSBuild("./Cody.sln", new MSBuildSettings + { + Configuration = "Debug", + PlatformTarget = PlatformTarget.MSIL, + Verbosity = Verbosity.Minimal + }); +}); + Task("Tests") //.IsDependentOn("Build") .Does(() => From bb1db0562c61faf30a5e6fe261c9f6c75c2a100c Mon Sep 17 00:00:00 2001 From: Beatrix Date: Tue, 1 Oct 2024 16:25:11 -0700 Subject: [PATCH 2/8] run tests in parallel --- .github/workflows/cake-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cake-build.yml b/.github/workflows/cake-build.yml index 431196d..3cdc144 100644 --- a/.github/workflows/cake-build.yml +++ b/.github/workflows/cake-build.yml @@ -67,4 +67,4 @@ jobs: Access_Token_UI_Tests: ${{ secrets.SRC_ACCESS_TOKEN_DOTCOM }} run: | cd src - dotnet test .\Cody.VisualStudio.Tests\bin\Debug\Cody.VisualStudio.Tests.dll -v detailed + dotnet test .\Cody.VisualStudio.Tests\bin\Debug\Cody.VisualStudio.Tests.dll -v detailed --parallel From 7c0e967c77945cdbfbef555077a6eecdf682a546 Mon Sep 17 00:00:00 2001 From: Beatrix Date: Tue, 1 Oct 2024 16:32:29 -0700 Subject: [PATCH 3/8] BuildCodyAgentIfNeeded --- .github/workflows/cake-build.yml | 4 ++-- src/build.cake | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cake-build.yml b/.github/workflows/cake-build.yml index 3cdc144..2b5446b 100644 --- a/.github/workflows/cake-build.yml +++ b/.github/workflows/cake-build.yml @@ -51,11 +51,11 @@ jobs: dotnet tool restore corepack enable - - name: Build Cody Agent + - name: Build Cody Agent if needed run: | cd src corepack install --global pnpm@8.6.7 - dotnet cake --target=BuildCodyAgent + dotnet cake --target=BuildCodyAgentIfNeeded - name: Build Extension run: | diff --git a/src/build.cake b/src/build.cake index 462ba7b..27600cc 100644 --- a/src/build.cake +++ b/src/build.cake @@ -148,6 +148,21 @@ Task("BuildCodyAgent") }); +Task("BuildCodyAgentIfNeeded") + .Does(() => +{ + var codyAgentDistDir = MakeAbsolute(codyDir + Directory("agent/dist")); + if (!DirectoryExists(codyAgentDistDir)) + { + Information("Cody Agent dist directory not found. Building Cody Agent..."); + RunTarget("BuildCodyAgent"); + } + else + { + Information("Cody Agent dist directory already exists. Skipping build."); + } +}); + Task("DownloadNode") .Does(() => { From 8c4e1f3fe1d0096ce1d326d1ed68db80e20a4fb7 Mon Sep 17 00:00:00 2001 From: Beatrix Date: Tue, 1 Oct 2024 16:41:00 -0700 Subject: [PATCH 4/8] use agentDir --- src/build.cake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/build.cake b/src/build.cake index 27600cc..3df3507 100644 --- a/src/build.cake +++ b/src/build.cake @@ -151,8 +151,7 @@ Task("BuildCodyAgent") Task("BuildCodyAgentIfNeeded") .Does(() => { - var codyAgentDistDir = MakeAbsolute(codyDir + Directory("agent/dist")); - if (!DirectoryExists(codyAgentDistDir)) + if (!DirectoryExists(agentDir)) { Information("Cody Agent dist directory not found. Building Cody Agent..."); RunTarget("BuildCodyAgent"); From aa37ad42bee683dff76bdabcbf97f3aa59d81015 Mon Sep 17 00:00:00 2001 From: Beatrix Date: Tue, 1 Oct 2024 16:50:48 -0700 Subject: [PATCH 5/8] use codyDir --- src/build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build.cake b/src/build.cake index 3df3507..9c64e1e 100644 --- a/src/build.cake +++ b/src/build.cake @@ -151,7 +151,7 @@ Task("BuildCodyAgent") Task("BuildCodyAgentIfNeeded") .Does(() => { - if (!DirectoryExists(agentDir)) + if (!DirectoryExists(codyDir)) { Information("Cody Agent dist directory not found. Building Cody Agent..."); RunTarget("BuildCodyAgent"); From 895d6663d34a2df302c22b949ae4cd461ff116e2 Mon Sep 17 00:00:00 2001 From: Beatrix Date: Tue, 1 Oct 2024 16:56:01 -0700 Subject: [PATCH 6/8] wip --- src/build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build.cake b/src/build.cake index 9c64e1e..23cbb1d 100644 --- a/src/build.cake +++ b/src/build.cake @@ -151,7 +151,7 @@ Task("BuildCodyAgent") Task("BuildCodyAgentIfNeeded") .Does(() => { - if (!DirectoryExists(codyDir)) + if (!DirectoryExists(codyDir) || !DirectoryExists(agentDir)) { Information("Cody Agent dist directory not found. Building Cody Agent..."); RunTarget("BuildCodyAgent"); From 6c871cab9f87ccdc04aeca3dade33f38bdecba90 Mon Sep 17 00:00:00 2001 From: Beatrix Date: Tue, 1 Oct 2024 16:59:05 -0700 Subject: [PATCH 7/8] cache --- .github/workflows/cake-build.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cake-build.yml b/.github/workflows/cake-build.yml index 2b5446b..3aca7d2 100644 --- a/.github/workflows/cake-build.yml +++ b/.github/workflows/cake-build.yml @@ -37,14 +37,6 @@ jobs: - name: Restore NuGet packages run: nuget restore src\Cody.Core\Cody.Core.csproj -PackagesDirectory src\packages - - name: Cache cody-dist - uses: actions/cache@v3 - with: - path: cody-dist/agent - key: ${{ runner.os }}-cody-dist-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-cody-dist- - - name: Common Build Setup run: | cd src @@ -57,6 +49,14 @@ jobs: corepack install --global pnpm@8.6.7 dotnet cake --target=BuildCodyAgentIfNeeded + - name: Cache cody-dist + uses: actions/cache@v3 + with: + path: cody-dist/agent + key: ${{ runner.os }}-cody-dist-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-cody-dist- + - name: Build Extension run: | cd src From e70af4908ef007b1b7f96569287bbda0484ef441 Mon Sep 17 00:00:00 2001 From: Beatrix Date: Wed, 2 Oct 2024 06:05:33 -0700 Subject: [PATCH 8/8] clean up --- .github/workflows/cake-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cake-build.yml b/.github/workflows/cake-build.yml index 65097e8..353cc41 100644 --- a/.github/workflows/cake-build.yml +++ b/.github/workflows/cake-build.yml @@ -57,7 +57,7 @@ jobs: restore-keys: | ${{ runner.os }}-cody-dist- - - name: Build Extension + - name: Build Extension (Debug) run: | cd src dotnet cake --target=BuildDebug