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 IntegrationTest project #100

Merged
merged 5 commits into from
Dec 17, 2023
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
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Exclude everything
*

# Include the src folder
!src
!README.md

# Exclude build-related folders within src/Husky
src/Husky/bin/
src/Husky/obj/
src/Husky/nupkg/
Empty file added .gitmodules
Empty file.
48 changes: 48 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This dockerfile is used in the integration tests

# Use the official .NET SDK image as a base
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
ARG RESOURCE_REAPER_SESSION_ID="00000000-0000-0000-0000-000000000000"
LABEL "org.testcontainers.resource-reaper-session"=$RESOURCE_REAPER_SESSION_ID

# Set the working directory
WORKDIR /app

# Copy the .csproj file to the container
COPY src/Husky/Husky.csproj ./

ENV HUSKY=0

# Copy the remaining files to the container
COPY . ./

# Restore dependencies
RUN dotnet restore /app/src/Husky

# Build the application
RUN dotnet build --no-restore -c Release -f net8.0 /app/src/Husky

# Create a NuGet package
RUN dotnet pack --no-build --no-restore -c Release -o out /app/src/Husky/Husky.csproj -p:TargetFrameworks=net8.0

# Use the same .NET SDK image for the final stage
FROM mcr.microsoft.com/dotnet/sdk:8.0
ARG RESOURCE_REAPER_SESSION_ID="00000000-0000-0000-0000-000000000000"
LABEL "org.testcontainers.resource-reaper-session"=$RESOURCE_REAPER_SESSION_ID

# Set the working directory
WORKDIR /app

# Install Git
RUN apt-get update && \
apt-get install -y git

# Copy the NuGet package from the build-env to the runtime image
COPY --from=build-env /app/out/*.nupkg /app/nupkg/

# Install Husky tool and add the global tools path to the PATH
RUN dotnet tool install -g --no-cache --add-source /app/nupkg/ husky \
&& echo "export PATH=\$PATH:/root/.dotnet/tools" >> ~/.bashrc

# Set the entry point to a simple shell
ENTRYPOINT ["/bin/bash"]
9 changes: 8 additions & 1 deletion Husky.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
#
#
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Husky", "src\Husky\Husky.csproj", "{12AB4B33-47A6-49D5-872A-5BA6DD634E9C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{302A5F25-CB44-4ED0-A65E-06C04648D211}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HuskyTest", "tests\HuskyTest\HuskyTest.csproj", "{57EE798B-0FE0-42A4-BDB9-D168109D3E7D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HuskyIntegrationTests", "tests\HuskyIntegrationTests\HuskyIntegrationTests.csproj", "{FAF049CD-6E45-4A66-A88F-C2EB007DFCC3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,8 +23,13 @@ Global
{57EE798B-0FE0-42A4-BDB9-D168109D3E7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57EE798B-0FE0-42A4-BDB9-D168109D3E7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57EE798B-0FE0-42A4-BDB9-D168109D3E7D}.Release|Any CPU.Build.0 = Release|Any CPU
{FAF049CD-6E45-4A66-A88F-C2EB007DFCC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FAF049CD-6E45-4A66-A88F-C2EB007DFCC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FAF049CD-6E45-4A66-A88F-C2EB007DFCC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FAF049CD-6E45-4A66-A88F-C2EB007DFCC3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{57EE798B-0FE0-42A4-BDB9-D168109D3E7D} = {302A5F25-CB44-4ED0-A65E-06C04648D211}
{FAF049CD-6E45-4A66-A88F-C2EB007DFCC3} = {302A5F25-CB44-4ED0-A65E-06C04648D211}
EndGlobalSection
EndGlobal
31 changes: 31 additions & 0 deletions tests/HuskyIntegrationTests/HuskyIntegrationTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>
<PackageReference Include="Testcontainers" Version="3.6.0" />
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Folder Include="TestProjectBase\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"husky": {
"version": "0.6.3",
"commands": [
"husky"
]
}
}
}
Loading
Loading