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

Merge main back into develop #225

Merged
merged 3 commits into from
May 29, 2024
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
11 changes: 6 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
interval: weekly
reviewers:
- SMI/reviewers
- package-ecosystem: nuget
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
interval: weekly
open-pull-requests-limit: 99
target-branch: develop
reviewers:
- tznind
- jas88
- SMI/reviewers
41 changes: 41 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "CodeQL"

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
schedule:
- cron: "22 19 * * 4"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ csharp ]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{ matrix.language }}"
22 changes: 14 additions & 8 deletions .github/workflows/testpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ jobs:
steps:
- name: Disable disk flush
run: sudo apt-get install -y libeatmydata1
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
dotnet-version: |
6.0.x
7.0.x
- name: Start MySQL for testing
run: sudo systemctl start mysql.service
- name: Test
run: |
dotnet test "./BadMedicine.Dicom.Tests/BadMedicine.Dicom.Tests.csproj" -nologo -c Release
curl https://raw.githubusercontent.com/HicServices/DicomTypeTranslation/master/Templates/CT.it > ./CT.it
dotnet test "./BadMedicine.Dicom.Tests/BadMedicine.Dicom.Tests.csproj" --nologo -c Release
curl -sL https://raw.githubusercontent.com/SMI/DicomTypeTranslation/master/Templates/CT.it > ./CT.it
cp BadDicom/BadDicom.template.yaml BadDicom.yaml
dotnet run --project BadDicom/BadDicom.csproj -- ./ 50000 10 CT
sed -i "s/Batches: 1/Batches: 5/g" ./BadDicom.yaml
Expand All @@ -27,18 +29,22 @@ jobs:
run: |
mkdir -p dist
dotnet pack ./BadMedicine.Dicom/BadMedicine.Dicom.csproj -c Release -p:IncludeSymbols=true -p:Version=$(grep AssemblyInformationalVersion SharedAssemblyInfo.cs | cut -d'"' -f2) -nologo
for platform in linux win
for platform in linux-x64 win-x64 osx-{arm64,x64}
do
dotnet publish BadDicom/BadDicom.csproj -c Release -r $platform-x64 -o $platform-x64 --self-contained true -nologo -v q -p:PublishSingleFile=true -p:DebugType=embedded -p:GenerateDocumentationFile=false
dotnet publish BadDicom/BadDicom.csproj -c Release -r $platform -o $platform --self-contained true -nologo -v q -p:PublishSingleFile=true -p:DebugType=embedded -p:GenerateDocumentationFile=false
done
zip -9r dist/baddicom-win-x64-v$(grep AssemblyInformationalVersion SharedAssemblyInfo.cs | cut -d'"' -f2).zip ./win-x64
tar czf dist/baddicom-linux-x64-v$(grep AssemblyInformationalVersion SharedAssemblyInfo.cs | cut -d'"' -f2).tar.gz ./linux-x64
for platform in linux-x64 win-x64 osx-{arm64,x64}
do
tar cJf dist/baddicom-${platform}-v$(grep AssemblyInformationalVersion SharedAssemblyInfo.cs | cut -d'"' -f2).tar.xz ./$platform
done
ls -lh dist
- name: Nuget push
if: contains(github.ref,'refs/tags/')
run: |
dotnet nuget push ./BadMedicine.Dicom/bin/Release/HIC.BadMedicine.Dicom.*.nupkg -k ${{ secrets.NUGET_KEY }} --skip-duplicate -s https://api.nuget.org/v3/index.json
- name: Upload release binaries
uses: svenstaro/upload-release-action@2.3.0
uses: svenstaro/upload-release-action@2.7.0
if: contains(github.ref, 'refs/tags/v')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
5 changes: 0 additions & 5 deletions .lgtm.yml

This file was deleted.

27 changes: 9 additions & 18 deletions BadDicom/BadDicom.csproj
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>

<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<StartupObject></StartupObject>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<StartupObject>BadDicom.Program</StartupObject>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<DebugType>embedded</DebugType>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PublishSingleFile>true</PublishSingleFile>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.NETCore.App" Version="2.2.8" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<None Remove="BadDicom.template.yaml" />
</ItemGroup>
Expand All @@ -42,8 +32,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="HIC.DicomTypeTranslation" Version="4.0.1" />
<PackageReference Include="YamlDotNet" Version="12.0.2" />
<PackageReference Include="HIC.DicomTypeTranslation" Version="4.0.3" />
<PackageReference Include="Vecc.YamlDotNet.Analyzers.StaticGenerator" Version="13.4.0" />
<PackageReference Include="YamlDotNet" Version="13.4.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
Expand Down
14 changes: 8 additions & 6 deletions BadDicom/Configuration/Config.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace BadDicom.Configuration
using YamlDotNet.Serialization;

namespace BadDicom.Configuration;

[YamlSerializable]
internal class Config
{
class Config
{
public TargetDatabase Database { get;set; }
public ExplicitUIDs UIDs { get; set; }
}
public TargetDatabase? Database { get;set; }
public ExplicitUIDs? UIDs { get; set; }
}
8 changes: 8 additions & 0 deletions BadDicom/Configuration/ConfigContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using YamlDotNet.Serialization;

namespace BadDicom.Configuration;

[YamlStaticContext]
public partial class ConfigContext : StaticContext
{
}
89 changes: 45 additions & 44 deletions BadDicom/Configuration/ExplicitUIDs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,56 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using YamlDotNet.Serialization;

namespace BadDicom.Configuration
namespace BadDicom.Configuration;

/// <summary>
/// Config section for loading explicit UIDs from disk and using those in file creation
/// </summary>
[YamlSerializable]
public class ExplicitUIDs
{
/// <summary>
/// Config section for loading explicit UIDs from disk and using those in file creation
/// Path to a file containing a list of study instance UIDs to use
/// </summary>
public string? StudyInstanceUIDs { get; set; }

/// <summary>
/// Path to a file containing a list of series instance UIDs to use
/// </summary>
public string? SeriesInstanceUIDs { get; set; }

/// <summary>
/// Path to a file containing a list of SOP instance UIDs to use
/// </summary>
public string? SOPInstanceUIDs { get; set; }

/// <summary>
/// Loads the UID files referenced (if they exist) in the configuration
/// and populates <see cref="UIDAllocator"/> with the values.
/// </summary>
public class ExplicitUIDs
public void Load()
{
// unlikely but if someone else has pre queued some stuff, this replaces that
UIDAllocator.StudyUIDs.Clear();
UIDAllocator.SeriesUIDs.Clear();
UIDAllocator.SOPUIDs.Clear();

foreach (var u in GetUIDsFrom(StudyInstanceUIDs))
UIDAllocator.StudyUIDs.Enqueue(u);

foreach (var u in GetUIDsFrom(SeriesInstanceUIDs))
UIDAllocator.SeriesUIDs.Enqueue(u);

foreach (var u in GetUIDsFrom(SOPInstanceUIDs))
UIDAllocator.SOPUIDs.Enqueue(u);
}

private static IEnumerable<string> GetUIDsFrom(string? path)
{
/// <summary>
/// Path to a file containing a list of study instance UIDs to use
/// </summary>
public string StudyInstanceUIDs { get; set; }

/// <summary>
/// Path to a file containing a list of series instance UIDs to use
/// </summary>
public string SeriesInstanceUIDs { get; set; }

/// <summary>
/// Path to a file containing a list of SOP instance UIDs to use
/// </summary>
public string SOPInstanceUIDs { get; set; }

/// <summary>
/// Loads the UID files referenced (if they exist) in the configuration
/// and populates <see cref="UIDAllocator"/> with the values.
/// </summary>
public void Load()
{
// unlikely but if someone else has pre queued some stuff, this replaces that
UIDAllocator.StudyUIDs.Clear();
UIDAllocator.SeriesUIDs.Clear();
UIDAllocator.SOPUIDs.Clear();

foreach (var u in GetUIDsFrom(StudyInstanceUIDs))
UIDAllocator.StudyUIDs.Enqueue(u);

foreach (var u in GetUIDsFrom(SeriesInstanceUIDs))
UIDAllocator.SeriesUIDs.Enqueue(u);

foreach (var u in GetUIDsFrom(SOPInstanceUIDs))
UIDAllocator.SOPUIDs.Enqueue(u);
}

private IEnumerable<string> GetUIDsFrom(string path)
{
if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) return Enumerable.Empty<string>();
if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) return Enumerable.Empty<string>();

return File.ReadLines(StudyInstanceUIDs).Where(l => !string.IsNullOrWhiteSpace(l));
}
return File.ReadLines(path).Where(l => !string.IsNullOrWhiteSpace(l));
}
}
73 changes: 37 additions & 36 deletions BadDicom/Configuration/TargetDatabase.cs
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
using FAnsi;
using YamlDotNet.Serialization;

namespace BadDicom.Configuration
namespace BadDicom.Configuration;

/// <summary>
/// Identify the target database and configuration for generated data
/// </summary>
[YamlSerializable]
public class TargetDatabase
{
/// <summary>
/// Identify the target database and configuration for generated data
/// Which RDBMS the database is (MySQL, Microsoft SQL Server, etc)
/// </summary>
public DatabaseType DatabaseType { get; set; }
/// <summary>
/// The ConnectionString containing the server name, credentials and other parameters for the connection
/// </summary>
public class TargetDatabase
{
/// <summary>
/// Which RDBMS the database is (MySQL, Microsoft SQL Server, etc)
/// </summary>
public DatabaseType DatabaseType { get; set; }
/// <summary>
/// The ConnectionString containing the server name, credentials and other parameters for the connection
/// </summary>
public string ConnectionString { get; set; }
public string? ConnectionString { get; set; }

/// <summary>
/// The name of database
/// </summary>
public string DatabaseName { get; set; }
/// <summary>
/// The name of database
/// </summary>
public string? DatabaseName { get; set; }

/// <summary>
/// The filename of a YAML template file to be used for this database
/// </summary>
public string Template { get; set; }
/// <summary>
/// The filename of a YAML template file to be used for this database
/// </summary>
public string? Template { get; set; }

/// <summary>
/// Pass true to create tables from template that do not have primary key. Do bulk insert
/// then deduplicate final tables and recreate primary key
/// </summary>
public bool MakeDistinct { get; set; }
/// <summary>
/// Pass true to create tables from template that do not have primary key. Do bulk insert
/// then deduplicate final tables and recreate primary key
/// </summary>
public bool MakeDistinct { get; set; }

/// <summary>
/// Set to true to drop and recreate tables described in the Template
/// </summary>
public bool DropTables { get; set; }
/// <summary>
/// Set to true to drop and recreate tables described in the Template
/// </summary>
public bool DropTables { get; set; }

/// <summary>
/// The number of parallel batches to execute (each batch gets the full count of studies
/// then they are merged at the end).
/// </summary>
public int Batches { get; set; } = 1;
}
}
/// <summary>
/// The number of parallel batches to execute (each batch gets the full count of studies
/// then they are merged at the end).
/// </summary>
public int Batches { get; set; } = 1;
}
Loading