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

Migrating to GH actions #317

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 0 additions & 13 deletions .circleci/config.yml

This file was deleted.

99 changes: 99 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: CI

on:
push:
branches:
- master
- ci-gh-action-migration # For testing GitHub Action Workflows
pull_request:

jobs:
build:
runs-on: ubuntu-latest
env:
DOTNET_NO_GLOBAL: 'true' # Ignore global.json
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: display git info about the checkout stuff
run: git rev-parse --abbrev-ref HEAD

- name: Set up JDK 15
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '15'

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
5.0.200

- name: Install .NET tools
run: |
dotnet tool install -g dotnet-sonarscanner -v:m

- name: Add .NET tools to PATH
run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'

- name: Execute GitVersion
id: gitversion
uses: gittools/actions/gitversion/[email protected]

- name: Restore dependencies
run: dotnet restore --disable-parallel --ignore-failed-sources

- name: Run code formatting check
run: dotnet format --check

- name: Patch csproj files with version
run: |
find . -name '*.csproj' -exec sed -i 's/<Version>.*<\/Version>/<Version>${{ steps.gitversion.outputs.NuGetVersion }}<\/Version>/g' {} +

- name: SonarScanner begin
run: |
dotnet sonarscanner begin \
/d:sonar.host.url=https://sonarcloud.io \
/d:sonar.login=$SONAR_TOKEN \
/k:mariotoffia_FluentDocker \
/o:mariotoffia \
/v:"${{ steps.gitversion.outputs.NuGetVersion }}" \
/d:sonar.cs.opencover.reportsPaths="./output/coverage.opencover.xml" \
/d:sonar.coverage.exclusions="**Tests*.cs"
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Build
run: dotnet build FluentDocker.sln --configuration Release --no-restore --verbosity minimal /p:Version=${{ steps.gitversion.outputs.NuGetVersion }}

- name: Test
run: dotnet test --settings coverletArgs.runsettings --filter TestCategory=CI -f netcoreapp3.1

- name: SonarScanner end
run: dotnet sonarscanner end /d:sonar.login=$SONAR_TOKEN
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Package NuGet
run: dotnet pack FluentDocker.sln --configuration Release -o output /p:Version=${{ steps.gitversion.outputs.NuGetVersion }}

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: NuGet Packages
path: ./output/*.nupkg

# Deployment step conditioned to run only on master branch
- name: Deploy to NuGet
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
run: echo "Deploying to NuGet..."
#run: dotnet nuget push ./output/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<Version>1.0.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
Expand Down
4 changes: 2 additions & 2 deletions Ductus.FluentDocker.Tests/Ductus.FluentDocker.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net461</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -10,7 +10,7 @@
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
<PackageReference Include="Npgsql" Version="5.0.7" />
<PackageReference Include="Npgsql" Version="8.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Ductus.FluentDocker.Model.Builders;
using Ductus.FluentDocker.Model.Common;
using Ductus.FluentDocker.Model.Containers;
using Ductus.FluentDocker.Services;
using Ductus.FluentDocker.Services;
using Ductus.FluentDocker.Services.Extensions;
using Ductus.FluentDocker.Tests.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down
2 changes: 1 addition & 1 deletion Ductus.FluentDocker.XUnit/Ductus.FluentDocker.XUnit.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<Version>1.0.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
Expand Down
41 changes: 41 additions & 0 deletions Ductus.FluentDocker/Commands/Images.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Collections.Generic;
using Ductus.FluentDocker.Executors;
using Ductus.FluentDocker.Executors.Parsers;
using Ductus.FluentDocker.Extensions;
using Ductus.FluentDocker.Model.Common;
using Ductus.FluentDocker.Model.Containers;
using Ductus.FluentDocker.Model.Images;

namespace Ductus.FluentDocker.Commands
{
public static class Images
{
/// <summary>
/// List images. TODO: Not implemented - DO NOT USE THIS METHOD!!
/// </summary>
public static CommandResponse<IList<DockerRmImageRowResponse>> Rm(
this DockerUri host,
ICertificatePaths certificates = null,
bool force = false, bool prune = false,
params string[] imageId)
{

// TODO: Need to implement executor properly.
var options = "";

if (!prune) {
options = "--no-prune";
}

if (force) {
options += "--force";
}

return
new ProcessExecutor<ImageRmResponseParser, IList<DockerRmImageRowResponse>>(
"docker".ResolveBinary(),
$"{host.RenderBaseArgs(certificates)} images rm {options} {string.Join(" ", imageId)}").Execute();
}

}
}
2 changes: 1 addition & 1 deletion Ductus.FluentDocker/Ductus.FluentDocker.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net461</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<Version>1.0.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
Expand Down
41 changes: 41 additions & 0 deletions Ductus.FluentDocker/Executors/Parsers/ImageRmResponseParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Collections.Generic;
using Ductus.FluentDocker.Model.Containers;
using Ductus.FluentDocker.Model.Images;
using Ductus.FluentDocker.Extensions;
using System;

namespace Ductus.FluentDocker.Executors.Parsers
{
public sealed class ImageRmResponseParser : IProcessResponseParser<IList<DockerRmImageRowResponse>>
{
public CommandResponse<IList<DockerRmImageRowResponse>> Response { get; private set; }
public IProcessResponse<IList<DockerRmImageRowResponse>> Process(ProcessExecutionResult response)
{
if (response.ExitCode != 0)
{
Response = response.ToErrorResponse((IList<DockerRmImageRowResponse>)new List<DockerRmImageRowResponse>());
return this;
}

var list = new List<DockerRmImageRowResponse>();
foreach (var row in response.StdOutAsArray)
{
var items = row.Split(new string[]{": "},1,StringSplitOptions.RemoveEmptyEntries);
if (items.Length != 2)
{
continue;
}


list.Add(new DockerRmImageRowResponse
{
Id = items[1].Contains("sha") ? items[1].ToPlainId() : items[1],
Command = items[0]
});
}

Response = response.ToResponse(true, string.Empty, (IList<DockerRmImageRowResponse>)list);
return this;
}
}
}
8 changes: 8 additions & 0 deletions Ductus.FluentDocker/Model/Images/DockerImageRmRowResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Ductus.FluentDocker.Model.Images
{
public sealed class DockerRmImageRowResponse
{
public string Id { get; set; }
public string Command { get; set; }
}
}
26 changes: 0 additions & 26 deletions Examples/.vscode/launch.json

This file was deleted.

6 changes: 0 additions & 6 deletions Examples/.vscode/settings.json

This file was deleted.

24 changes: 0 additions & 24 deletions Examples/.vscode/tasks.json

This file was deleted.

9 changes: 0 additions & 9 deletions Examples/DockerInDockerLinux/DockerInDockerLinux.csproj

This file was deleted.

12 changes: 0 additions & 12 deletions Examples/DockerInDockerLinux/Dockerfile

This file was deleted.

22 changes: 0 additions & 22 deletions Examples/DockerInDockerLinux/Program.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Examples/DockerInDockerLinux/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions Examples/DockerInDockerLinux/build.sh

This file was deleted.

3 changes: 0 additions & 3 deletions Examples/DockerInDockerLinux/run.sh

This file was deleted.

Loading
Loading