Skip to content

Commit

Permalink
Merge pull request #5 from hughesjs/setup-cicd
Browse files Browse the repository at this point in the history
Added CICI
  • Loading branch information
hughesjs authored May 6, 2024
2 parents 7035fb1 + 6722440 commit 5dfb5cb
Show file tree
Hide file tree
Showing 17 changed files with 223 additions and 27 deletions.
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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:
- "*"
36 changes: 36 additions & 0 deletions .github/workflows/code-ql.yml
Original file line number Diff line number Diff line change
@@ -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
84 changes: 84 additions & 0 deletions .github/workflows/dotnet-cd.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
20 changes: 20 additions & 0 deletions .github/workflows/dotnet-ci.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 = """
<built>
<shipyard>Blohm & Voss</shipyard>
<shipyard>Blohm &amp; Voss</shipyard>
<launchingdate>
<datetime>1943-06-14</datetime>
</launchingdate>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -23,6 +23,6 @@ public void CanReadDcAlarm()
DiveComputerAlarm dcAlarm = serializer.Deserialize<DiveComputerAlarm>(Xml);
dcAlarm.PeriodInSeconds.ShouldBe(10.0f);
dcAlarm.AlarmType.ShouldBe(1);
dcAlarm.Acknowledge.ShouldBeNull();
dcAlarm.Acknowledge.ShouldNotBeNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using UniversalDiveDataFormat.ExtensionMethods;
using UniversalDiveDataFormat.Models;

namespace UniversalDiveDataFormat.Tests;
namespace UniversalDiveDataFormat.Tests.Models;

public class ExposureToAltitudeTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using UniversalDiveDataFormat.ExtensionMethods;
using UniversalDiveDataFormat.Models;

namespace UniversalDiveDataFormat.Tests;
namespace UniversalDiveDataFormat.Tests.Models;

public class GlobalAlarmsTests
{
Expand Down
23 changes: 23 additions & 0 deletions src/UniversalDiveDataFormat.Tests/Models/LaunchingDateTests.cs
Original file line number Diff line number Diff line change
@@ -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 = """
<launchingdate>
<datetime>1943-06-14</datetime>
</launchingdate>
""";

[Fact]
public void CanReadLaunchingDate()
{
XmlSerializer serializer = new(typeof(LaunchingDate));
LaunchingDate launchingDate = serializer.Deserialize<LaunchingDate>(Xml);
launchingDate.DateTime.ShouldBe(new(1943, 6, 14));
}
}
Original file line number Diff line number Diff line change
@@ -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 = """
<setdcalarmtime>
<datetime>T14:37:00</datetime>
<datetime>2022-01-01T14:37:00</datetime>
<dcalarm>
<!-- duration 10 seconds -->
<period>10.0</period>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using UniversalDiveDataFormat.ExtensionMethods;
using UniversalDiveDataFormat.Models;

namespace UniversalDiveDataFormat.Tests;
namespace UniversalDiveDataFormat.Tests.Models;

public class SetDiveComputerDecoModelTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -13,7 +13,7 @@ public class ShipDimensionTests
<beam>12.6</beam>
<draught>5.7</draught>
<displacement>123456.7</displacement>
<tonnage>170000.0</tonnag>
<tonnage>170000.0</tonnage>
</shipdimension>
""";

Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -13,7 +13,7 @@ public class WreckTests
<shiptype>tanker</shiptype>
<nationality>German</nationality>
<built>
<shipyard>Blohm & Voss</shipyard>
<shipyard>Blohm &amp; Voss</shipyard>
<launchingdate>
<datetime>1943-06-14</datetime>
</launchingdate>
Expand All @@ -25,7 +25,7 @@ public class WreckTests
<displacement>123456.7</displacement>
</shipdimension>
<sunk>
<datetime>1985-05-24T15:46</datetime>
<datetime>1985-05-24T15:46:00</datetime>
</sunk>
<notes>
<!-- here additional remarks and/or photos, videos of the wreck -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.4.2"/>
Expand Down
4 changes: 2 additions & 2 deletions src/UniversalDiveDataFormat/Models/LaunchingDate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
6 changes: 6 additions & 0 deletions src/UniversalDiveDataFormat/Services/UddfDeserializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace UniversalDiveDataFormat.Services;

public class UddfDeserializer
{

}
16 changes: 10 additions & 6 deletions src/UniversalDiveDataFormat/UniversalDiveDataFormat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.1</Version>
<Title>UniversalDiveDataFormat</Title>
<Authors />
<PackageProjectUrl>https://github.com/hughesjs/UniversalDiveDataFormat</PackageProjectUrl>
<PackageLicenseExpression>Unlicense</PackageLicenseExpression>
<RepositoryUrl>https://github.com/hughesjs/UniversalDiveDataFormat.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<Reference Include="Shouldly">
<HintPath>..\..\..\..\.nuget\packages\shouldly\4.2.1\lib\net5.0\Shouldly.dll</HintPath>
</Reference>
<Reference Include="xunit.core">
<HintPath>..\..\..\..\.nuget\packages\xunit.extensibility.core\2.4.2\lib\netstandard1.1\xunit.core.dll</HintPath>
</Reference>
<None Include="..\..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

</Project>

0 comments on commit 5dfb5cb

Please sign in to comment.