diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..791b954 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +version: 2 +updates: + - package-ecosystem: "nuget" # See documentation for possible values + directory: "/src" # Location of package manifests + schedule: + interval: "daily" + groups: + nuget-dependencies: + patterns: + - "*" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + groups: + actions-dependencies: + patterns: + - "*" \ No newline at end of file diff --git a/.github/workflows/code-ql.yml b/.github/workflows/code-ql.yml new file mode 100644 index 0000000..c92c409 --- /dev/null +++ b/.github/workflows/code-ql.yml @@ -0,0 +1,36 @@ +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +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 repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/dotnet-cd.yml b/.github/workflows/dotnet-cd.yml new file mode 100644 index 0000000..23fe50e --- /dev/null +++ b/.github/workflows/dotnet-cd.yml @@ -0,0 +1,84 @@ +name: .NET Continuous Deployment + +on: + push: + branches: [ master ] + paths: + - src/UniversalDiveDataFormat/** + workflow_dispatch: +jobs: + + test: + name: Test Project + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Run tests + run: dotnet test --logger GitHubActions ./src/UniversalDiveDataFormat.sln + + semantic-release: + needs: test + name: Create a Package Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 # Need the full commit history for conventional commit + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Bump version and push tag + id: tag_version + uses: mathieudutour/github-tag-action@v6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Create a GitHub release + uses: ncipollo/release-action@v1 + with: + tag: ${{ steps.tag_version.outputs.new_tag }} + name: Release ${{ steps.tag_version.outputs.new_tag }} + body: ${{ steps.tag_version.outputs.changelog }} + - name: Create Nuget Package + run: dotnet build -c Release ./src/UniversalDiveDataFormat/UniversalDiveDataFormat.csproj && dotnet pack -c Release -p:PackageVersion=${{ steps.tag_version.outputs.new_version }} -o . ./src/UniversalDiveDataFormat/UniversalDiveDataFormat.csproj + - name: Upload Package for Publishing + uses: actions/upload-artifact@v4 + with: + name: PackedLib + path: ./*.nupkg + + + github-publish: + needs: semantic-release + name: Publish to Github + runs-on: ubuntu-latest + steps: + - name: Download built project + uses: actions/download-artifact@v4 + with: + name: PackedLib + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Push Package to GitHub + run: dotnet nuget push --api-key ${{secrets.GITHUB_TOKEN}} --source "https://nuget.pkg.github.com/hughesjs/index.json" *.nupkg + + + nuget-publish: + needs: semantic-release + name: Publish to Nuget + runs-on: ubuntu-latest + steps: + - name: Download built project + uses: actions/download-artifact@v4 + with: + name: PackedLib + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Push Package to Nuget + run: dotnet nuget push --api-key ${{secrets.NUGET_KEY}} --source "https://api.nuget.org/v3/index.json" *.nupkg \ No newline at end of file diff --git a/.github/workflows/dotnet-ci.yml b/.github/workflows/dotnet-ci.yml new file mode 100644 index 0000000..375bafd --- /dev/null +++ b/.github/workflows/dotnet-ci.yml @@ -0,0 +1,20 @@ +name: .NET Continuous Integration + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + +jobs: + test: + name: Test Project + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Run tests + run: dotnet test --logger GitHubActions ./src/UniversalDiveDataFormat.sln \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/Models/BuiltTests.cs b/src/UniversalDiveDataFormat.Tests/Models/BuiltTests.cs similarity index 80% rename from src/UniversalDiveDataFormat/Models/BuiltTests.cs rename to src/UniversalDiveDataFormat.Tests/Models/BuiltTests.cs index 4774942..1c72c35 100644 --- a/src/UniversalDiveDataFormat/Models/BuiltTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/BuiltTests.cs @@ -1,15 +1,15 @@ using System.Xml.Serialization; using Shouldly; using UniversalDiveDataFormat.ExtensionMethods; -using Xunit; +using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Models; +namespace UniversalDiveDataFormat.Tests.Models; public class BuiltTests { private const string Xml = """ - Blohm & Voss + Blohm & Voss 1943-06-14 diff --git a/src/UniversalDiveDataFormat/Models/DiveComputerAlarmTests.cs b/src/UniversalDiveDataFormat.Tests/Models/DiveComputerAlarmTests.cs similarity index 85% rename from src/UniversalDiveDataFormat/Models/DiveComputerAlarmTests.cs rename to src/UniversalDiveDataFormat.Tests/Models/DiveComputerAlarmTests.cs index 795363c..aff945f 100644 --- a/src/UniversalDiveDataFormat/Models/DiveComputerAlarmTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/DiveComputerAlarmTests.cs @@ -1,9 +1,9 @@ using System.Xml.Serialization; using Shouldly; using UniversalDiveDataFormat.ExtensionMethods; -using Xunit; +using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Models; +namespace UniversalDiveDataFormat.Tests.Models; public class DiveComputerAlarmTests { @@ -23,6 +23,6 @@ public void CanReadDcAlarm() DiveComputerAlarm dcAlarm = serializer.Deserialize(Xml); dcAlarm.PeriodInSeconds.ShouldBe(10.0f); dcAlarm.AlarmType.ShouldBe(1); - dcAlarm.Acknowledge.ShouldBeNull(); + dcAlarm.Acknowledge.ShouldNotBeNull(); } } \ No newline at end of file diff --git a/src/UniversalDiveDataFormat.Tests/Models/ExposureToAltitudeTests.cs b/src/UniversalDiveDataFormat.Tests/Models/ExposureToAltitudeTests.cs index bab50ef..66586c0 100644 --- a/src/UniversalDiveDataFormat.Tests/Models/ExposureToAltitudeTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/ExposureToAltitudeTests.cs @@ -3,7 +3,7 @@ using UniversalDiveDataFormat.ExtensionMethods; using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Tests; +namespace UniversalDiveDataFormat.Tests.Models; public class ExposureToAltitudeTests { diff --git a/src/UniversalDiveDataFormat.Tests/Models/GlobalAlarmsTests.cs b/src/UniversalDiveDataFormat.Tests/Models/GlobalAlarmsTests.cs index 8ea52cb..2d9134d 100644 --- a/src/UniversalDiveDataFormat.Tests/Models/GlobalAlarmsTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/GlobalAlarmsTests.cs @@ -3,7 +3,7 @@ using UniversalDiveDataFormat.ExtensionMethods; using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Tests; +namespace UniversalDiveDataFormat.Tests.Models; public class GlobalAlarmsTests { diff --git a/src/UniversalDiveDataFormat.Tests/Models/LaunchingDateTests.cs b/src/UniversalDiveDataFormat.Tests/Models/LaunchingDateTests.cs new file mode 100644 index 0000000..8a3bee3 --- /dev/null +++ b/src/UniversalDiveDataFormat.Tests/Models/LaunchingDateTests.cs @@ -0,0 +1,23 @@ +using System.Xml.Serialization; +using Shouldly; +using UniversalDiveDataFormat.ExtensionMethods; +using UniversalDiveDataFormat.Models; + +namespace UniversalDiveDataFormat.Tests.Models; + +public class LaunchingDateTests +{ + private const string Xml = """ + + 1943-06-14 + + """; + + [Fact] + public void CanReadLaunchingDate() + { + XmlSerializer serializer = new(typeof(LaunchingDate)); + LaunchingDate launchingDate = serializer.Deserialize(Xml); + launchingDate.DateTime.ShouldBe(new(1943, 6, 14)); + } +} \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/Models/SetDiveComputerAlarmTimeTests.cs b/src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerAlarmTimeTests.cs similarity index 85% rename from src/UniversalDiveDataFormat/Models/SetDiveComputerAlarmTimeTests.cs rename to src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerAlarmTimeTests.cs index 6a3b448..5827a2a 100644 --- a/src/UniversalDiveDataFormat/Models/SetDiveComputerAlarmTimeTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerAlarmTimeTests.cs @@ -1,15 +1,15 @@ using System.Xml.Serialization; using Shouldly; using UniversalDiveDataFormat.ExtensionMethods; -using Xunit; +using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Models; +namespace UniversalDiveDataFormat.Tests.Models; public class SetDiveComputerAlarmTimeTests { private const string Xml = """ - T14:37:00 + 2022-01-01T14:37:00 10.0 diff --git a/src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerDecoModelTests.cs b/src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerDecoModelTests.cs index cbdcd1d..68a1e93 100644 --- a/src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerDecoModelTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/SetDiveComputerDecoModelTests.cs @@ -3,7 +3,7 @@ using UniversalDiveDataFormat.ExtensionMethods; using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Tests; +namespace UniversalDiveDataFormat.Tests.Models; public class SetDiveComputerDecoModelTests { diff --git a/src/UniversalDiveDataFormat/Models/ShipDimensionTests.cs b/src/UniversalDiveDataFormat.Tests/Models/ShipDimensionTests.cs similarity index 86% rename from src/UniversalDiveDataFormat/Models/ShipDimensionTests.cs rename to src/UniversalDiveDataFormat.Tests/Models/ShipDimensionTests.cs index 899465b..93e8716 100644 --- a/src/UniversalDiveDataFormat/Models/ShipDimensionTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/ShipDimensionTests.cs @@ -1,9 +1,9 @@ using System.Xml.Serialization; using Shouldly; using UniversalDiveDataFormat.ExtensionMethods; -using Xunit; +using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Models; +namespace UniversalDiveDataFormat.Tests.Models; public class ShipDimensionTests { @@ -13,7 +13,7 @@ public class ShipDimensionTests 12.6 5.7 123456.7 - 170000.0 + 170000.0 """; diff --git a/src/UniversalDiveDataFormat/Models/WreckTests.cs b/src/UniversalDiveDataFormat.Tests/Models/WreckTests.cs similarity index 91% rename from src/UniversalDiveDataFormat/Models/WreckTests.cs rename to src/UniversalDiveDataFormat.Tests/Models/WreckTests.cs index a6871dd..f18e5ac 100644 --- a/src/UniversalDiveDataFormat/Models/WreckTests.cs +++ b/src/UniversalDiveDataFormat.Tests/Models/WreckTests.cs @@ -1,9 +1,9 @@ using System.Xml.Serialization; using Shouldly; using UniversalDiveDataFormat.ExtensionMethods; -using Xunit; +using UniversalDiveDataFormat.Models; -namespace UniversalDiveDataFormat.Models; +namespace UniversalDiveDataFormat.Tests.Models; public class WreckTests { @@ -13,7 +13,7 @@ public class WreckTests tanker German - Blohm & Voss + Blohm & Voss 1943-06-14 @@ -25,7 +25,7 @@ public class WreckTests 123456.7 - 1985-05-24T15:46 + 1985-05-24T15:46:00 diff --git a/src/UniversalDiveDataFormat.Tests/UniversalDiveDataFormat.Tests.csproj b/src/UniversalDiveDataFormat.Tests/UniversalDiveDataFormat.Tests.csproj index 6fee83b..dff3c56 100644 --- a/src/UniversalDiveDataFormat.Tests/UniversalDiveDataFormat.Tests.csproj +++ b/src/UniversalDiveDataFormat.Tests/UniversalDiveDataFormat.Tests.csproj @@ -11,6 +11,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/UniversalDiveDataFormat/Models/LaunchingDate.cs b/src/UniversalDiveDataFormat/Models/LaunchingDate.cs index 5e04631..93f52f5 100644 --- a/src/UniversalDiveDataFormat/Models/LaunchingDate.cs +++ b/src/UniversalDiveDataFormat/Models/LaunchingDate.cs @@ -2,9 +2,9 @@ namespace UniversalDiveDataFormat.Models; -[XmlRoot("LaunchingDate")] +[XmlRoot("launchingdate")] public class LaunchingDate { [XmlElement("datetime")] - public DateTime? DateTime { get; init; } + public DateTime DateTime { get; init; } } \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/Services/UddfDeserializer.cs b/src/UniversalDiveDataFormat/Services/UddfDeserializer.cs new file mode 100644 index 0000000..7ee6a42 --- /dev/null +++ b/src/UniversalDiveDataFormat/Services/UddfDeserializer.cs @@ -0,0 +1,6 @@ +namespace UniversalDiveDataFormat.Services; + +public class UddfDeserializer +{ + +} \ No newline at end of file diff --git a/src/UniversalDiveDataFormat/UniversalDiveDataFormat.csproj b/src/UniversalDiveDataFormat/UniversalDiveDataFormat.csproj index 03f1bb1..b2260e3 100644 --- a/src/UniversalDiveDataFormat/UniversalDiveDataFormat.csproj +++ b/src/UniversalDiveDataFormat/UniversalDiveDataFormat.csproj @@ -5,15 +5,19 @@ latest enable enable + true + 0.0.1 + UniversalDiveDataFormat + + https://github.com/hughesjs/UniversalDiveDataFormat + Unlicense + https://github.com/hughesjs/UniversalDiveDataFormat.git + git + README.md - - ..\..\..\..\.nuget\packages\shouldly\4.2.1\lib\net5.0\Shouldly.dll - - - ..\..\..\..\.nuget\packages\xunit.extensibility.core\2.4.2\lib\netstandard1.1\xunit.core.dll - +