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

Add tests workflow #36

Merged
merged 14 commits into from
Sep 18, 2024
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
3 changes: 3 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [ ] The pull request is targeting the `dev` branch.
- [ ] All [tests](https://github.com/jfrog/jfrog-visual-studio-extension/actions/workflows/tests.yml) passed. If this feature is not already covered by the tests, I added new tests.
-----
44 changes: 44 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Run Tests

on:
push:
pull_request:
type: [ labeled ]

jobs:
build:
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1
with:
vs-version: 'latest'

- name: Cache NuGet packages # optimizing the build process
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj') }}
restore-keys: nuget-${{ runner.os }}-

- name: Restore dependencies
run: |
dotnet restore
nuget restore

- name: Download JFrog CLI executable
env:
JFROG_CLI_VERSION: '2.67.0' # jfrog cli version can be changed here
run: .\JFrogVSExtension\Resources\DownloadJfrogCli.ps1
shell: pwsh

- name: Build VSIX Project # build the vsix project using multi-core compilation and parallel builds
run: msbuild JFrogVSExtension.sln /p:Configuration=Release /p:Platform="Any CPU" /p:BuildInParallel=true /m

- name: Run MSTest Project # run tests in release mode with logs presentation
run: dotnet test --no-build --configuration Release --logger "console;verbosity=detailed" ./UnitTestJfrogVSExtension/bin/Release/UnitTestJfrogVSExtension.dll

10 changes: 10 additions & 0 deletions JFrogVSExtension.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 17.1.32407.343
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JFrogVSExtension", "JFrogVSExtension\JFrogVSExtension.csproj", "{6443B797-2478-4A1D-BECA-28E24C1F1F41}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestJfrogVSExtension", "UnitTestJfrogVSExtension\UnitTestJfrogVSExtension.csproj", "{DB770B26-1629-45D0-8526-8902F83731B2}"
kerenr-jfrog marked this conversation as resolved.
Show resolved Hide resolved
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +23,14 @@ Global
{6443B797-2478-4A1D-BECA-28E24C1F1F41}.Release|Any CPU.Build.0 = Release|Any CPU
{6443B797-2478-4A1D-BECA-28E24C1F1F41}.Release|x86.ActiveCfg = Release|x86
{6443B797-2478-4A1D-BECA-28E24C1F1F41}.Release|x86.Build.0 = Release|x86
{DB770B26-1629-45D0-8526-8902F83731B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB770B26-1629-45D0-8526-8902F83731B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB770B26-1629-45D0-8526-8902F83731B2}.Debug|x86.ActiveCfg = Debug|Any CPU
{DB770B26-1629-45D0-8526-8902F83731B2}.Debug|x86.Build.0 = Debug|Any CPU
{DB770B26-1629-45D0-8526-8902F83731B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB770B26-1629-45D0-8526-8902F83731B2}.Release|Any CPU.Build.0 = Release|Any CPU
{DB770B26-1629-45D0-8526-8902F83731B2}.Release|x86.ActiveCfg = Release|Any CPU
{DB770B26-1629-45D0-8526-8902F83731B2}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
33 changes: 33 additions & 0 deletions JFrogVSExtension/Resources/DownloadJfrogCli.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Check if the JFROG_CLI_VERSION environment variable is set, if not using latest version
if ($env:JFROG_CLI_VERSION) {
Write-Output "Downloading Jfrog CLI version: $env:JFROG_CLI_VERSION"
} else {
Write-Error "Error: JFROG_CLI_VERSION environment variable is not set."
exit 1
}

# Define the URL for the JFrog CLI executable
$jfrogCliUrl = "https://releases.jfrog.io/artifactory/jfrog-cli/v2-jf/$($env:JFROG_CLI_VERSION)/jfrog-cli-windows-amd64/jf.exe"

# Define the destination path for the downloaded file
$destinationPath = Join-Path (Get-Location).Path "JFrogVSExtension/Resources/jfrog.exe"

# Download the JFrog CLI executable
Invoke-WebRequest -Uri $jfrogCliUrl -OutFile $destinationPath -Verbose


# Verify the file was downloaded successfully
if (Test-Path -Path $destinationPath) {
kerenr-jfrog marked this conversation as resolved.
Show resolved Hide resolved
Write-Output "JFrog CLI v$env:JFROG_CLI_VERSION successfully downloaded to: $destinationPath"
$downloadedVersion = & $destinationPath --version

if ($downloadedVersion -eq "jf version $env:JFROG_CLI_VERSION"){
Write-Output "Successfully downloaded Jfrog CLI version $env:JFROG_CLI_VERSION."
} else {
Write-Error "Version does not match the environment variable. Expected: $env:JFROG_CLI_VERSION, Got: $downloadedVersion"
exit 1
}

} else {
Write-Error "Failed to download JFrog CLI to: $destinationPath"
}
18 changes: 18 additions & 0 deletions UnitTestJfrogVSExtension/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics;

namespace UnitTestJfrogVSExtension
{
[TestClass]
public class UnitTest1
{
public TestContext TestContext { get; set; }

[TestMethod]
public void TestMethod1()
{
TestContext.WriteLine("Success!!!");
}
}
}
60 changes: 60 additions & 0 deletions UnitTestJfrogVSExtension/UnitTestJfrogVSExtension.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DB770B26-1629-45D0-8526-8902F83731B2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UnitTestJfrogVSExtension</RootNamespace>
<AssemblyName>UnitTestJfrogVSExtension</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter">
<Version>2.2.10</Version>
</PackageReference>
<PackageReference Include="MSTest.TestFramework">
<Version>2.2.10</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Loading