Skip to content

Commit

Permalink
Allow host to be built without webpanel
Browse files Browse the repository at this point in the history
- Allows for a speedup when just building ReleaseNotes in CI
  • Loading branch information
Cyberboss committed Aug 18, 2023
1 parent 4ed9761 commit a165d39
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
22 changes: 15 additions & 7 deletions .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ jobs:
run: dotnet restore

- name: Build ReleaseNotes
run: dotnet build -c Release tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj
run: |
export TGS_HOST_NO_WEBPANEL=true
dotnet build -c Release tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj
- name: Build Changelog (Incremental)
run: |
Expand Down Expand Up @@ -1223,7 +1225,9 @@ jobs:
run: dotnet restore

- name: Build ReleaseNotes
run: dotnet build -c Release tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj
run: |
export TGS_HOST_NO_WEBPANEL=true
dotnet build -c Release tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj
- name: Run ReleaseNotes Check
run: dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --winget-template-check ${{ steps.get-sha.outputs.pr_template_sha }}
Expand Down Expand Up @@ -1387,7 +1391,9 @@ jobs:
run: dotnet restore

- name: Build ReleaseNotes
run: dotnet build -c Release tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj
run: |
export TGS_HOST_NO_WEBPANEL=true
dotnet build -c Release tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj
- name: Run ReleaseNotes with --ensure-release
run: dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --ensure-release
Expand All @@ -1414,9 +1420,6 @@ jobs:
cd build/package/winget
dotnet tool restore
- name: Build ReleaseNotes
run: dotnet build -c Release tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj

# We need to rebuild the installer.exe so it can be properly signed
- name: Restore
run: dotnet restore
Expand All @@ -1427,6 +1430,9 @@ jobs:
- name: Build Service
run: dotnet build -c Release src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj

- name: Build ReleaseNotes
run: dotnet build -c Release tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj

- name: Prepare Artifacts
shell: powershell
run: build/package/winget/prepare_installer_input_artifacts.ps1
Expand Down Expand Up @@ -1653,7 +1659,9 @@ jobs:
uses: actions/checkout@v3

- name: Build ReleaseNotes
run: dotnet build -c Release tools/Tgstation.Server.ReleaseNotes
run: |
$Env:TGS_HOST_NO_WEBPANEL=true
dotnet build -c Release tools/Tgstation.Server.ReleaseNotes
- name: Execute Push Script
shell: powershell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ public sealed class ControlPanelConfiguration
/// <summary>
/// If the control panel is enabled.
/// </summary>
public bool Enable { get; set; }
public bool Enable
#if NO_WEBPANEL
{
get => false;
set => _ = value;
}
#else
{
get;
set;
}
#endif

/// <summary>
/// If any origin is allowed for CORS requests. This overrides <see cref="AllowedOrigins"/>.
Expand Down
4 changes: 4 additions & 0 deletions src/Tgstation.Server.Host/Core/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,11 @@ public void Configure(
});
}
else
#if NO_WEBPANEL
logger.LogTrace("Web control panel was not included in TGS build!");
#else
logger.LogTrace("Web control panel disabled!");
#endif

// Do not cache a single thing beyond this point, it's all API
applicationBuilder.UseDisabledClientCache();
Expand Down
8 changes: 6 additions & 2 deletions src/Tgstation.Server.Host/Tgstation.Server.Host.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
<DefineConstants>$(DefineConstants);WATCHDOG_FREE_RESTART</DefineConstants>
</PropertyGroup>

<Target Name="ClientInstall" BeforeTargets="ResolveAssemblyReferences" Inputs="../../build/ControlPanelVersion.props" Outputs="$(NpmInstallStampFile)">
<PropertyGroup Condition="'$(TGS_HOST_NO_WEBPANEL)' == 'true'">
<DefineConstants>$(DefineConstants);NO_WEBPANEL</DefineConstants>
</PropertyGroup>

<Target Condition="'$(TGS_HOST_NO_WEBPANEL)' != 'true'" Name="ClientInstall" BeforeTargets="ResolveAssemblyReferences" Inputs="../../build/ControlPanelVersion.props" Outputs="$(NpmInstallStampFile)">
<Message Text="Pulling web control panel..." Importance="high" />
<RemoveDir Directories="ClientApp" />
<Exec Command="git clone https://github.com/tgstation/tgstation-server-webpanel --branch v$(TgsControlPanelVersion) --depth 1 ClientApp" />
Expand All @@ -28,7 +32,7 @@
<Touch Files="$(NpmInstallStampFile)" AlwaysCreate="true" />
</Target>

<Target Name="NpmBuild" BeforeTargets="BeforeBuild" DependsOnTargets="ClientInstall" Inputs="../../build/ControlPanelVersion.props" Outputs="wwwroot\index.html">
<Target Condition="'$(TGS_HOST_NO_WEBPANEL)' != 'true'" Name="NpmBuild" BeforeTargets="BeforeBuild" DependsOnTargets="ClientInstall" Inputs="../../build/ControlPanelVersion.props" Outputs="wwwroot\index.html">
<Message Text="Building web control panel..." Importance="high" />
<Exec WorkingDirectory="ClientApp" Command="npx --yes yarn run msbuild" />
</Target>
Expand Down

0 comments on commit a165d39

Please sign in to comment.