Skip to content

Commit

Permalink
Consolidate Actions.Core dependencies (#13)
Browse files Browse the repository at this point in the history
* Consolidate Environment Keys

* Further consolidate Environment variables

Add missing variables from https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
  • Loading branch information
fredrikhr committed May 7, 2024
1 parent cd0149a commit e9c34d3
Show file tree
Hide file tree
Showing 11 changed files with 326 additions and 160 deletions.
1 change: 1 addition & 0 deletions samples/Actions.Core.Sample/Actions.Core.Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />

<ProjectReference Include="..\..\src\Actions.Core\Actions.Core.csproj" />
<ProjectReference Include="..\..\src\Actions.Octokit\Actions.Octokit.csproj" />
</ItemGroup>
</Project>
6 changes: 5 additions & 1 deletion src/Actions.Core/Actions.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
<BasedOn>@actions/core</BasedOn>
</PropertyGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);ACTIONS_CORE_ENVIRONMENTVARIABLES_PUBLIC</DefineConstants>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Actions.Octokit\Actions.Octokit.csproj" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Actions.Core/Commands/IFileCommandIssuer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal interface IFileCommandIssuer
/// Asynchronous I/O that issues a command that corresponds to the
/// given <paramref name="commandSuffix"/>, with the given <paramref name="message"/> value.
/// </summary>
/// <param name="commandSuffix">The command suffix as found in <see cref="Octokit.EnvironmentVariables.Suffixes"/></param>
/// <param name="commandSuffix">The command suffix as found in <see cref="EnvironmentVariables.Suffixes"/></param>
/// <param name="message">An arbitrary message value</param>
/// <param name="typeInfo">The JSON type info used to serialize.</param>
/// <returns>A task that represents the asynchronous operation of writing the message to file.</returns>
Expand Down
296 changes: 296 additions & 0 deletions src/Actions.Core/EnvironmentVariables/Keys.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
// Copyright (c) David Pine. All rights reserved.
// Licensed under the MIT License.

namespace Actions.Octokit.EnvironmentVariables;
namespace Actions.Core.EnvironmentVariables;

/// <summary>
/// A collection of environment variable prefixes, used with corresponding <see cref="Suffixes"/>.
/// </summary>
[SuppressMessage(
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Naming",
"CA1707:Identifiers should not contain underscores",
Justification = "These values correspond to environment variables and I want them to match exactly.")]
public static class Prefixes
#if ACTIONS_CORE_ENVIRONMENTVARIABLES_PUBLIC
public
#endif
static class Prefixes
{
/// <summary>
/// The environment variable key prefix: <c>GITHUB_</c>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// Copyright (c) David Pine. All rights reserved.
// Licensed under the MIT License.

namespace Actions.Octokit.EnvironmentVariables;
namespace Actions.Core.EnvironmentVariables;

/// <summary>
/// A collection of environment variable suffixes, used with corresponding <see cref="Prefixes"/>.
/// </summary>
public static class Suffixes
#if ACTIONS_CORE_ENVIRONMENTVARIABLES_PUBLIC
public
#endif
static class Suffixes
{
/// <summary>
/// The environment variable key suffix: <c>ENV</c>.
Expand Down
6 changes: 3 additions & 3 deletions src/Actions.Core/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
global using static System.Environment;
global using static System.IO.Path;

global using static Actions.Octokit.EnvironmentVariables.Keys;
global using static Actions.Octokit.EnvironmentVariables.Prefixes;
global using static Actions.Octokit.EnvironmentVariables.Suffixes;
global using static Actions.Core.EnvironmentVariables.Keys;
global using static Actions.Core.EnvironmentVariables.Prefixes;
global using static Actions.Core.EnvironmentVariables.Suffixes;
6 changes: 6 additions & 0 deletions src/Actions.Octokit/Actions.Octokit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@
<ItemGroup>
<InternalsVisibleTo Include="Octokit.Sandbox" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Actions.Core\EnvironmentVariables\*.cs">
<LinkBase>EnvironmentVariables</LinkBase>
</Compile>
</ItemGroup>
</Project>
147 changes: 0 additions & 147 deletions src/Actions.Octokit/EnvironmentVariables/Keys.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Actions.Octokit/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
global using GitHub.Octokit.Client;
global using Microsoft.Extensions.DependencyInjection;
global using static System.Environment;
global using static Actions.Octokit.EnvironmentVariables.Keys;
global using static Actions.Core.EnvironmentVariables.Keys;
4 changes: 2 additions & 2 deletions tests/Actions.Core.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
global using Actions.Core.Tests.Output;
global using Actions.Core.Workflows;

global using Actions.Octokit.EnvironmentVariables;
global using Actions.Core.EnvironmentVariables;

global using Microsoft.Extensions.DependencyInjection;

global using Xunit;

global using static Actions.Octokit.EnvironmentVariables.Keys;
global using static Actions.Core.EnvironmentVariables.Keys;

0 comments on commit e9c34d3

Please sign in to comment.