Skip to content
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
170 changes: 131 additions & 39 deletions .github/workflows/createrelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

- name: Publish API
if: ${{ github.event.release.prerelease == false }}
run: dotnet publish "MessagingService\MessagingService.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained
run: dotnet publish "MessagingService\MessagingService.csproj" --configuration Release --output publishOutput -r linux-x64 --self-contained

- name: Build Release Package
run: |
Expand All @@ -79,67 +79,159 @@
dotnet nuget push Nugets/MessagingService.IntegrationTesting.Helpers.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.PRIVATEFEED_APIKEY }} --source ${{ secrets.PRIVATEFEED_URL }} --skip-duplicate

deploystaging:
runs-on: stagingserver
runs-on: [stagingserver, linux]
needs: buildlinux
environment: staging
name: "Deploy to Staging"

steps:
- name: Download the artifact
uses: actions/download-artifact@v4.1.8
with:
name: messagingservice

- name: Remove existing Windows service
name: securityservice
path: /tmp/securityservice # Download to a temporary directory

- name: Remove existing service (if applicable)
run: |
$serviceName = "Transaction Processing - Messaging Service"
# Check if the service exists
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
Stop-Service -Name $serviceName
sc.exe delete $serviceName
}

SERVICE_NAME="securityservice"
if systemctl is-active --quiet "$SERVICE_NAME"; then
echo "Stopping existing service..."
sudo systemctl stop "$SERVICE_NAME"
fi
if systemctl is-enabled --quiet "$SERVICE_NAME"; then
echo "Disabling existing service..."
sudo systemctl disable "$SERVICE_NAME"
fi
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
echo "Removing existing service unit file..."
sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
sudo systemctl daemon-reload
fi

- name: Unzip the files
run: |
Expand-Archive -Path messagingservice.zip -DestinationPath "C:\txnproc\transactionprocessing\messagingservice" -Force

- name: Install as a Windows service
sudo mkdir -p /opt/txnproc/transactionprocessing/securityservice
sudo unzip -o /tmp/securityservice/securityservice.zip -d /opt/txnproc/transactionprocessing/securityservice

# IMPORTANT: Add a step to ensure the .NET runtime is installed on the server
# This assumes it's not already there. If your base image already has it, you can skip this.
- name: Install .NET Runtime
run: |
# Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0)
# and if you need the SDK or just the runtime.
# This uses Microsoft's package repository for the latest versions.
wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install -y aspnetcore-runtime-9.0

- name: Install and Start as a Linux service
run: |
$serviceName = "Transaction Processing - Messaging Service"
$servicePath = "C:\txnproc\transactionprocessing\messagingservice\MessagingService.exe"

New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Messaging Service" -DisplayName "Transaction Processing - Messaging Service" -StartupType Automatic
Start-Service -Name $serviceName
SERVICE_NAME="securityservice"
# The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/securityservice"
DLL_NAME="SecurityService.dll" # Your application's DLL
SERVICE_DESCRIPTION="Transaction Processing - Security Service"

# Create a systemd service file
echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
# IMPORTANT: Use 'dotnet' to run your DLL
echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service

# Reload systemd, enable, and start the service
sudo systemctl daemon-reload
sudo systemctl enable "$SERVICE_NAME"
sudo systemctl start "$SERVICE_NAME"
sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification

deployproduction:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
runs-on: productionserver
runs-on: [productionserver, linux]
needs: [buildlinux, deploystaging]
environment: production
name: "Deploy to Production"

steps:
- name: Download the artifact
uses: actions/download-artifact@v4.1.8
with:
name: messagingservice

- name: Remove existing Windows service
name: securityservice
path: /tmp/securityservice # Download to a temporary directory

- name: Remove existing service (if applicable)
run: |
$serviceName = "Transaction Processing - Messaging Service"
# Check if the service exists
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
Stop-Service -Name $serviceName
sc.exe delete $serviceName
}

SERVICE_NAME="securityservice"
if systemctl is-active --quiet "$SERVICE_NAME"; then
echo "Stopping existing service..."
sudo systemctl stop "$SERVICE_NAME"
fi
if systemctl is-enabled --quiet "$SERVICE_NAME"; then
echo "Disabling existing service..."
sudo systemctl disable "$SERVICE_NAME"
fi
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
echo "Removing existing service unit file..."
sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
sudo systemctl daemon-reload
fi

- name: Unzip the files
run: |
Expand-Archive -Path messagingservice.zip -DestinationPath "C:\txnproc\transactionprocessing\messagingservice" -Force

- name: Install as a Windows service
sudo mkdir -p /opt/txnproc/transactionprocessing/securityservice
sudo unzip -o /tmp/securityservice/securityservice.zip -d /opt/txnproc/transactionprocessing/securityservice

# IMPORTANT: Add a step to ensure the .NET runtime is installed on the server
# This assumes it's not already there. If your base image already has it, you can skip this.
- name: Install .NET Runtime
run: |
# Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0)
# and if you need the SDK or just the runtime.
# This uses Microsoft's package repository for the latest versions.
wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install -y aspnetcore-runtime-9.0

- name: Install and Start as a Linux service
run: |
$serviceName = "Transaction Processing - Messaging Service"
$servicePath = "C:\txnproc\transactionprocessing\messagingservice\MessagingService.exe"

New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Messaging Service" -DisplayName "Transaction Processing - Messaging Service" -StartupType Automatic
Start-Service -Name $serviceName
SERVICE_NAME="securityservice"
# The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/securityservice"
DLL_NAME="SecurityService.dll" # Your application's DLL
SERVICE_DESCRIPTION="Transaction Processing - Security Service"

# Create a systemd service file
echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
# IMPORTANT: Use 'dotnet' to run your DLL
echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service

# Reload systemd, enable, and start the service
sudo systemctl daemon-reload
sudo systemctl enable "$SERVICE_NAME"
sudo systemctl start "$SERVICE_NAME"
sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification
4 changes: 2 additions & 2 deletions MessagingService.Client/MessagingService.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClientProxyBase" Version="2025.6.1" />
<PackageReference Include="ClientProxyBase" Version="2025.6.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Shared.Results" Version="2025.6.1" />
<PackageReference Include="Shared.Results" Version="2025.6.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
<PackageReference Include="Shared.EventStore" Version="2025.6.1" />
<PackageReference Include="Shared.EventStore" Version="2025.6.2" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Shared" Version="2025.6.1" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2025.6.1" />
<PackageReference Include="Shared" Version="2025.6.2" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2025.6.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

<ItemGroup>
<PackageReference Include="Grpc.Net.Client" Version="2.71.0" />
<PackageReference Include="Shared" Version="2025.6.1" />
<PackageReference Include="Shared.EventStore" Version="2025.6.1" />
<PackageReference Include="Shared" Version="2025.6.2" />
<PackageReference Include="Shared.EventStore" Version="2025.6.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Shared.IntegrationTesting" Version="2025.6.1" />
<PackageReference Include="Shared.IntegrationTesting" Version="2025.6.2" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion MessagingService.IntegrationTests/Common/DockerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public class DockerHelper : global::Shared.IntegrationTesting.DockerHelper
/// <param name="testingContext">The testing context.</param>
public DockerHelper()
{
this.TestingContext = new TestingContext();
this.TestingContext = new TestingContext();
this.TestId = Guid.NewGuid();
}

#endregion
Expand Down
1 change: 1 addition & 0 deletions MessagingService.IntegrationTests/Common/GenericSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
[BeforeScenario]
public async Task StartSystem()
{

// Initialise a logger
String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", "");
NlogLogger logger = new NlogLogger();
logger.Initialise(LogManager.GetLogger(scenarioName), scenarioName);
LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly);

Check warning on line 36 in MessagingService.IntegrationTests/Common/GenericSteps.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

'LogManager.AddHiddenAssembly(Assembly)' is obsolete: 'Replaced by LogManager.Setup().SetupLogFactory(setup => setup.AddCallSiteHiddenAssembly(assembly)). Marked obsolete on NLog 5.3'

DockerServices dockerServices = DockerServices.SqlServer | DockerServices.MessagingService | DockerServices.EventStore | DockerServices.SecurityService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClientProxyBase" Version="2025.6.1" />
<PackageReference Include="ClientProxyBase" Version="2025.6.2" />
<PackageReference Include="Ductus.FluentDocker" Version="2.10.59" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
<PackageReference Include="Reqnroll.Tools.MsBuild.Generation" Version="2.4.1" />
Expand All @@ -16,7 +16,7 @@
<PackageReference Include="Reqnroll.NUnit" Version="2.4.1" />
<PackageReference Include="SecurityService.Client" Version="2025.5.1" />
<PackageReference Include="SecurityService.IntegrationTesting.Helpers" Version="2025.5.1" />
<PackageReference Include="Shared.IntegrationTesting" Version="2025.6.1" />
<PackageReference Include="Shared.IntegrationTesting" Version="2025.6.2" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -30,15 +30,20 @@
<ProjectReference Include="..\MessagingService.IntegrationTesting.Helpers\MessagingService.IntegrationTesting.Helpers.csproj" />
</ItemGroup>

<ItemGroup>
<!--<ItemGroup>
<Compile Update="Email\SendEmail.feature.cs">
<DesignTime>True</DesignTime>
</Compile>
<Compile Update="SMS\SendSMS.feature.cs">
<DesignTime>True</DesignTime>
</Compile>
</ItemGroup>-->
<ItemGroup>
<None Update="**\*.feature">
<Generator>ReqnrollSingleFileGenerator</Generator>
<LastGenOutput>%(Filename).feature.cs</LastGenOutput>
</None>
</ItemGroup>

<ItemGroup>
<None Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Shared.DomainDrivenDesign" Version="2025.6.1" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2025.6.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="Grpc.Net.Client" Version="2.71.0" />
<PackageReference Include="Shared.EventStore" Version="2025.6.1" />
<PackageReference Include="Shared.EventStore" Version="2025.6.2" />
</ItemGroup>

<ItemGroup>
Expand Down
50 changes: 0 additions & 50 deletions MessagingService/MessagingService - Backup (1).csproj

This file was deleted.

Loading
Loading