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

Build/Publish base on GitHub Actions #142

Merged
merged 47 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5c38009
Build agent with PS scripts
Nov 6, 2024
f2ec626
github build script
Nov 6, 2024
dad06e2
missing env variable
Nov 6, 2024
4f98d08
Remove cake
Nov 6, 2024
952e283
fix + setting testing
Nov 6, 2024
36b040f
action name fix
Nov 6, 2024
60c3eab
action name fix
Nov 6, 2024
67e085b
action name fix
Nov 6, 2024
a16d03c
action name fix
Nov 6, 2024
a243aeb
msbuild restore
Nov 6, 2024
492de15
test search fix
Nov 6, 2024
251aaf3
test search fix
Nov 6, 2024
6d643f0
test search fix
Nov 6, 2024
1424f62
test search fix
Nov 6, 2024
5472fed
test search fix
Nov 6, 2024
b821112
test search fix
Nov 6, 2024
b16a1ea
test search fix
Nov 6, 2024
0546be7
test search fix
Nov 6, 2024
218c923
test search fix
Nov 6, 2024
4eaf57f
using vstest
Nov 7, 2024
f4a86b0
configuration variable
Nov 8, 2024
955c112
publish scripts
Nov 8, 2024
7f5d48e
action version fix
Nov 8, 2024
109efef
dll versionig fix
Nov 8, 2024
f3b1a07
dll versionig fix
Nov 8, 2024
16e859b
fix to debug in preview
Nov 8, 2024
952e80b
Create vsix feed
Nov 11, 2024
6c51cd5
fix
Nov 11, 2024
72a4dfd
fix
Nov 11, 2024
34f310d
fix folder structure
Nov 11, 2024
1181efe
fixes
Nov 11, 2024
f9ad083
fixes
Nov 11, 2024
54a6d77
Using Start-Process
Nov 11, 2024
ac28777
variable fix
Nov 11, 2024
f6f1c00
Added permissions
Nov 11, 2024
75c1a03
Added another permissions
Nov 11, 2024
4406aff
Added another permissions
Nov 11, 2024
8ef38ae
VS fix
Nov 12, 2024
6f74c0f
VS env changes
Nov 12, 2024
a014239
VS env changes
Nov 12, 2024
f97a160
Merge branch 'main' into tg/github-actions
Nov 12, 2024
21e24af
Remove VS preparation
Nov 14, 2024
c19be14
after review fixes
Nov 14, 2024
c971a5f
path fix
Nov 14, 2024
dc15a8e
fixes
Nov 14, 2024
55b9645
name fixes
Nov 15, 2024
ccc1f0a
quotes fix
Nov 15, 2024
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
30 changes: 30 additions & 0 deletions .github/actions/create-vsix-feed/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'VSIX gallery feed creator'
description: 'Create VSIX private gallery ATOM feed'
inputs:
vsix-directory:
description: 'Directory where all VSIX files to include in gallery are located'
required: true
feed-file:
description: 'Path to output feed file and assets'
required: false
default: './feed.xml'
source-path:
description: 'Download source path used in the feed file'
required: false
default: '.'
gallery-name:
description: 'Custom gallery name'
required: false
default: 'VSIX gallery'
runs:
using: "composite"
steps:
- name: Cache PrivateGalleryCreator
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/PrivateGalleryCreator
key: ${{ runner.os }}-PrivateGalleryCreator-1.0.64

- name: Generate gallery feed
shell: pwsh
run: ${{github.action_path}}/privateGalleryCreator.ps1 -vsixDirectory "${{ inputs.vsix-directory }}" -feedFile "${{ inputs.feed-file }}" -sourcePath "${{ inputs.source-path }}" -galleryName "${{ inputs.gallery-name }}"
22 changes: 22 additions & 0 deletions .github/actions/create-vsix-feed/privateGalleryCreator.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
param(
$vsixDirectory,
$feedFile,
$sourcePath,
$galleryName
)

$downloadUrl = "https://github.com/madskristensen/PrivateGalleryCreator/releases/download/1.0.64/PrivateGalleryCreator.zip"
$creatorFolder = Join-Path $env:GITHUB_WORKSPACE "PrivateGalleryCreator"
$zipFile = Join-Path $creatorFolder "PrivateGalleryCreator.zip"
$exePath = Join-Path $creatorFolder "PrivateGalleryCreator.exe"

if (!(Test-Path -Path $exePath -PathType Leaf)) {
md -Force $creatorFolder | Out-Null
Invoke-WebRequest $downloadUrl -OutFile $zipFile
Expand-Archive $zipFile -DestinationPath $creatorFolder
Remove-Item $zipFile
}

$prm = "--input=""$vsixDirectory"" --output=""$feedFile"" --source=""$sourcePath"" --name=""$galleryName"" --terminate"

Start-Process -FilePath $exePath -ArgumentList $prm -Wait -NoNewWindow
81 changes: 81 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Build and test extension

on:
push:
branches: [main]
pull_request:
branches: [main]

# 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: 16gb_16_core_large_window_runner
# do we want to run this on forks?
if: github.repository_owner == 'sourcegraph'
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
Configuration: Debug

steps:
- uses: actions/checkout@v4

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

- name: Cache nuget
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ github.sha }}
restore-keys: ${{ runner.os }}-nuget-

- name: Cache agent
id: cache-agent
uses: actions/cache@v4
with:
path: src/Cody.VisualStudio/Agent
key: ${{ runner.os }}-agent-${{ hashFiles('agent/agent.version') }}

- name: Build agent if needed
if: ${{ steps.cache-agent.outputs.cache-hit != 'true' }}
shell: pwsh
run: ./agent/runBuildAgent.ps1

- name: Build extension (${{ env.Configuration }})
run: msbuild src/Cody.sln -t:Build -restore -verbosity:minimal -property:Configuration=${{ env.Configuration }}

- name: Upload Cody.VisualStudio.vsix artifact
uses: actions/upload-artifact@v4
with:
name: Cody.VisualStudio.vsix
path: src/Cody.VisualStudio/bin/${{ env.Configuration }}/Cody.VisualStudio.vsix

#Running tests

- name: Change Screen Resolution
shell: pwsh
run: Set-DisplayResolution -Width 1920 -Height 1080 -Force

- name: Run tests
env:
Access_Token_UI_Tests: ${{ secrets.SRC_ACCESS_TOKEN_DOTCOM }}
run: dotnet test src/*Tests/bin/${{ env.Configuration }}/*.Tests.dll --logger:trx --verbosity detailed

- name: Upload screenshots for UI tests
uses: actions/upload-artifact@v4
if: always()
with:
name: UI Tests Screenshots
path: src/Cody.VisualStudio.Tests/bin/${{ env.Configuration }}/Screenshots
retention-days: 20

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: TestResults/**/*.trx
91 changes: 0 additions & 91 deletions .github/workflows/cake-build.yml

This file was deleted.

100 changes: 58 additions & 42 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Nightly Build
on:
schedule:
- cron: "0 2 * * *" # Runs at 2 AM UTC every day
workflow_dispatch: # Allows manual triggering
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -13,63 +13,79 @@ jobs:
build:
runs-on: 16gb_16_core_large_window_runner
if: github.repository_owner == 'sourcegraph'
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
Configuration: Debug

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

- name: Cache nuget
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ github.sha }}
restore-keys: ${{ runner.os }}-nuget-

- name: Find the latest tag in Cody repository
uses: oprypin/find-latest-tag@v1.1.2
id: cody
with:
repository: sourcegraph/cody
prefix: vscode-

- name: Hash tag name
uses: pplanel/hash-calculator-action@v1.3.2
id: cody-hash
with:
input: ${{ steps.cody.outputs.tag }}

- name: Cache agent
id: cache-agent
uses: actions/cache@v4
with:
path: src/Cody.VisualStudio/Agent
key: ${{ runner.os }}-agent-${{ steps.cody-hash.outputs.digest }}

- name: Build agent if needed (tag ${{ steps.cody.outputs.tag }})
if: ${{ steps.cache-agent.outputs.cache-hit != 'true' }}
shell: pwsh
run: ./agent/buildAgent.ps1 -version ${{ steps.cody.outputs.tag }}

- name: Build extension (${{ env.Configuration }})
run: msbuild src/Cody.sln -t:Build -restore -verbosity:minimal -property:Configuration=${{ env.Configuration }}

- name: Upload Cody.VisualStudio.vsix artifact
uses: actions/upload-artifact@v4
with:
name: Cody.VisualStudio.vsix
path: src/Cody.VisualStudio/bin/${{ env.Configuration }}/Cody.VisualStudio.vsix
retention-days: 20

#Running tests

- name: Change Screen Resolution
shell: pwsh
run: Set-DisplayResolution -Width 1920 -Height 1080 -Force

- 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: Common Build Setup
run: |
cd src
dotnet tool restore
corepack enable

- name: Build Cody Agent (main branch)
run: |
cd src
corepack install --global pnpm@8.6.7
dotnet cake --target=BuildCodyAgent --cody-branch=main

- name: Build Extension (Debug)
run: |
cd src
dotnet cake --target=BuildDebug

- name: Tests

- name: Run 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 -l:trx

run: dotnet test src/*Tests/bin/${{ env.Configuration }}/*.Tests.dll --logger:trx --verbosity detailed

- name: Upload screenshots for UI tests
uses: actions/upload-artifact@v4
if: always()
with:
name: UI Tests Screenshots
path: src/Cody.VisualStudio.Tests/bin/Debug/Screenshots
retention-days: 5
path: src/Cody.VisualStudio.Tests/bin/${{ env.Configuration }}/Screenshots
retention-days: 20

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: |
src\TestResults/**/*.xml
src\TestResults/**/*.trx
src\TestResults/**/*.json
files: TestResults/**/*.trx
Loading
Loading