示例#1
0
    public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration)
    {
        var buildJob     = configuration.Jobs.First(z => z.Name == "Build");
        var checkoutStep = buildJob.Steps.OfType <CheckoutStep>().Single();

        // For fetch all
        checkoutStep.FetchDepth = 0;
        buildJob.Steps.InsertRange(buildJob.Steps.IndexOf(checkoutStep) + 1, new BaseGitHubActionsStep[] {
            new RunStep("Fetch all history for all tags and branches")
            {
                Run = "git fetch --prune"
            },
            new SetupDotNetStep("Use .NET Core 3.1 SDK")
            {
                DotNetVersion = "3.1.x"
            }
        });

        buildJob.Steps.Add(new UsingStep("Publish Coverage")
        {
            Uses = "codecov/codecov-action@v1",
            With = new Dictionary <string, string>
            {
                ["name"] = "actions-${{ matrix.os }}",
            }
        });

        buildJob.Steps.Add(new UploadArtifactStep("Publish logs")
        {
            Name = "logs",
            Path = "artifacts/logs/",
            If   = "always()"
        });

        buildJob.Steps.Add(new UploadArtifactStep("Publish coverage data")
        {
            Name = "coverage",
            Path = "coverage/",
            If   = "always()"
        });

        buildJob.Steps.Add(new UploadArtifactStep("Publish test data")
        {
            Name = "test data",
            Path = "artifacts/test/",
            If   = "always()"
        });

        buildJob.Steps.Add(new UploadArtifactStep("Publish NuGet Packages")
        {
            Name = "nuget",
            Path = "artifacts/nuget/",
            If   = "always()"
        });

        return(configuration);
    }
示例#2
0
    public static RocketSurgeonGitHubActionsConfiguration CiIgnoreMiddleware(RocketSurgeonGitHubActionsConfiguration configuration)
    {
        ((RocketSurgeonsGithubActionsJob)configuration.Jobs[0]).Steps = new List <GitHubActionsStep>
        {
            new RunStep("N/A")
            {
                Run = "echo \"No build required\""
            }
        };

        return(configuration.IncludeRepositoryConfigurationFiles());
    }
示例#3
0
    public static RocketSurgeonGitHubActionsConfiguration CiMiddleware(RocketSurgeonGitHubActionsConfiguration configuration)
    {
        configuration
        .ExcludeRepositoryConfigurationFiles()
        .AddNugetPublish()
        .Jobs.OfType <RocketSurgeonsGithubActionsJob>()
        .First(z => z.Name == "Build")
        .UseDotNetSdks("3.1", "6.0")
        .AddNuGetCache()
        // .ConfigureForGitVersion()
        .ConfigureStep <CheckoutStep>(step => step.FetchDepth = 0)
        .PublishLogs <Pipeline>()
        .FailFast = false;

        return(configuration);
    }
    public static RocketSurgeonGitHubActionsConfiguration CiIgnoreMiddleware(
        RocketSurgeonGitHubActionsConfiguration configuration
        )
    {
        foreach (var item in configuration.DetailedTriggers.OfType <RocketSurgeonGitHubActionsVcsTrigger>())
        {
            item.IncludePaths = LocalConstants.PathsIgnore;
        }

        configuration.Jobs.RemoveAt(1);
        ((RocketSurgeonsGithubActionsJob)configuration.Jobs[0]).Steps = new List <GitHubActionsStep>
        {
            new RunStep("N/A")
            {
                Run = "echo \"No build required\""
            }
        };

        return(configuration);
    }
示例#5
0
    public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration)
    {
        var buildJob     = configuration.Jobs.First(z => z.Name == "Build");
        var checkoutStep = buildJob.Steps.OfType <CheckoutStep>().Single();

        // For fetch all
        // checkoutStep.FetchDepth = 0;
        buildJob.Steps.InsertRange(buildJob.Steps.IndexOf(checkoutStep) + 1, new BaseGitHubActionsStep[] {
            new RunStep("Fetch all history for all tags and branches")
            {
                Run = "git fetch --prune --unshallow"
            },
            new SetupDotNetStep("Use .NET Core 2.1 SDK")
            {
                DotNetVersion = "2.1.x"
            },
            new SetupDotNetStep("Use .NET Core 3.1 SDK")
            {
                DotNetVersion = "3.1.x"
            },
            new RunStep("🪓 **DOTNET HACK** 🪓")
            {
                Shell = GithubActionShell.Pwsh,
                Run   = @"$version = Split-Path (Split-Path $ENV:DOTNET_ROOT -Parent) -Leaf;
                        $root = Split-Path (Split-Path $ENV:DOTNET_ROOT -Parent) -Parent;
                        $directories = Get-ChildItem $root | Where-Object { $_.Name -ne $version };
                        foreach ($dir in $directories) {
                            $from = $dir.FullName;
                            $to = ""$root/$version"";
                            Write-Host Copying from $from to $to;
                            Copy-Item ""$from\*"" $to -Recurse -Force;
                        }
                        "
            },
        });

        buildJob.Steps.Add(new UsingStep("Publish Coverage")
        {
            Uses = "codecov/codecov-action@v1",
            With = new Dictionary <string, string>
            {
                ["name"]             = "actions-${{ matrix.os }}",
                ["fail_ci_if_error"] = "true",
            }
        });

        buildJob.Steps.Add(new UploadArtifactStep("Publish logs")
        {
            Name = "logs",
            Path = "artifacts/logs/",
            If   = "always()"
        });

        buildJob.Steps.Add(new UploadArtifactStep("Publish coverage data")
        {
            Name = "coverage",
            Path = "coverage/",
            If   = "always()"
        });

        buildJob.Steps.Add(new UploadArtifactStep("Publish test data")
        {
            Name = "test data",
            Path = "artifacts/test/",
            If   = "always()"
        });

        buildJob.Steps.Add(new UploadArtifactStep("Publish NuGet Packages")
        {
            Name = "nuget",
            Path = "artifacts/nuget/",
            If   = "always()"
        });


        /*
         *
         * - publish: "${{ parameters.Artifacts }}/logs/"
         * displayName: Publish Logs
         * artifact: "Logs${{ parameters.Postfix }}"
         * condition: always()
         *
         * - publish: ${{ parameters.Coverage }}
         * displayName: Publish Coverage
         * artifact: "Coverage${{ parameters.Postfix }}"
         * condition: always()
         *
         * - publish: "${{ parameters.Artifacts }}/nuget/"
         * displayName: Publish NuGet Artifacts
         * artifact: "NuGet${{ parameters.Postfix }}"
         * condition: always()
         */
        return(configuration);
    }
示例#6
0
    public static RocketSurgeonGitHubActionsConfiguration CiMiddleware(
        RocketSurgeonGitHubActionsConfiguration configuration
        )
    {
        foreach (var item in configuration.DetailedTriggers.OfType <RocketSurgeonGitHubActionsVcsTrigger>())
        {
            item.ExcludePaths = LocalConstants.PathsIgnore;
        }

        var buildJob = configuration.Jobs.OfType <RocketSurgeonsGithubActionsJob>().First(z => z.Name == "Build");

        buildJob.FailFast = false;
        var checkoutStep = buildJob.Steps.OfType <CheckoutStep>().Single();

        // For fetch all
        checkoutStep.FetchDepth = 0;
        buildJob.Environment["NUGET_PACKAGES"] = "${{ github.workspace }}/.nuget/packages";
        buildJob.Steps.InsertRange(
            buildJob.Steps.IndexOf(checkoutStep) + 1,
            new BaseGitHubActionsStep[]
        {
            new RunStep("Fetch all history for all tags and branches")
            {
                Run = "git fetch --prune"
            },
            new UsingStep("NuGet Cache")
            {
                Uses = "actions/cache@v2",
                With =
                {
                    ["path"] = "${{ github.workspace }}/.nuget/packages",
                    // keep in mind using central package versioning here
                    ["key"] =
                        "${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}-${{ hashFiles('**/Directory.Packages.support.props') }}",
                    ["restore-keys"] = @"|
              ${{ runner.os }}-nuget-"
                }
            },
            new SetupDotNetStep("Use .NET Core 3.1 SDK")
            {
                DotNetVersion = "3.1.x"
            },
            new SetupDotNetStep("Use .NET Core 6.0 SDK")
            {
                DotNetVersion = "6.0.x"
            },
        }
            );

        buildJob.Steps.Add(
            new UsingStep("Publish Coverage")
        {
            Uses = "codecov/codecov-action@v1",
            With = new Dictionary <string, string>
            {
                ["name"] = "actions-${{ matrix.os }}",
            }
        }
            );

        buildJob.Steps.Add(
            new UploadArtifactStep("Publish logs")
        {
            Name = "logs",
            Path = "artifacts/logs/",
            If   = "always()"
        }
            );

        buildJob.Steps.Add(
            new UploadArtifactStep("Publish coverage data")
        {
            Name = "coverage",
            Path = "coverage/",
            If   = "always()"
        }
            );

        buildJob.Steps.Add(
            new UploadArtifactStep("Publish test data")
        {
            Name = "test data",
            Path = "artifacts/test/",
            If   = "always()"
        }
            );

        buildJob.Steps.Add(
            new UploadArtifactStep("Publish NuGet Packages")
        {
            Name = "nuget",
            Path = "artifacts/nuget/",
            If   = "always()"
        }
            );

        buildJob.Steps.Add(
            new UploadArtifactStep("Publish Docs")
        {
            Name = "docs",
            Path = "artifacts/docs/",
            If   = "always()"
        }
            );

        return(configuration);
    }
示例#7
0
    public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration)
    {
        var buildJob     = configuration.Jobs.First(z => z.Name == "Build");
        var checkoutStep = buildJob.Steps.OfType <CheckoutStep>().Single();

        // For fetch all
        checkoutStep.FetchDepth = 0;
        buildJob.Steps.InsertRange(
            buildJob.Steps.IndexOf(checkoutStep) + 1, new BaseGitHubActionsStep[] {
            new RunStep("Fetch all history for all tags and branches")
            {
                Run = "git fetch --prune"
            },
            new SetupDotNetStep("Use .NET Core 2.1 SDK")
            {
                DotNetVersion = "2.1.x"
            },
            new SetupDotNetStep("Use .NET Core 3.1 SDK")
            {
                DotNetVersion = "3.1.x"
            },
            new SetupDotNetStep("Use .NET Core 5.0 SDK")
            {
                DotNetVersion = "5.0.x"
            },
        }
            );

        buildJob.Steps.Add(
            new UsingStep("Publish Coverage")
        {
            Uses = "codecov/codecov-action@v1",
            With = new Dictionary <string, string> {
                ["name"]             = "actions-${{ matrix.os }}",
                ["fail_ci_if_error"] = "true",
            }
        }
            );

        buildJob.Steps.Add(
            new UploadArtifactStep("Publish logs")
        {
            Name = "logs",
            Path = "artifacts/logs/",
            If   = "always()"
        }
            );

        buildJob.Steps.Add(
            new UploadArtifactStep("Publish coverage data")
        {
            Name = "coverage",
            Path = "coverage/",
            If   = "always()"
        }
            );

        buildJob.Steps.Add(
            new UploadArtifactStep("Publish test data")
        {
            Name = "test data",
            Path = "artifacts/test/",
            If   = "always()"
        }
            );

        buildJob.Steps.Add(
            new UploadArtifactStep("Publish NuGet Packages")
        {
            Name = "nuget",
            Path = "artifacts/nuget/",
            If   = "always()"
        }
            );


        /*
         *
         * - publish: "${{ parameters.Artifacts }}/logs/"
         * displayName: Publish Logs
         * artifact: "Logs${{ parameters.Postfix }}"
         * condition: always()
         *
         * - publish: ${{ parameters.Coverage }}
         * displayName: Publish Coverage
         * artifact: "Coverage${{ parameters.Postfix }}"
         * condition: always()
         *
         * - publish: "${{ parameters.Artifacts }}/nuget/"
         * displayName: Publish NuGet Artifacts
         * artifact: "NuGet${{ parameters.Postfix }}"
         * condition: always()
         */
        return(configuration);
    }