diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 00000000..c498eb1f --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,62 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: .NET + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + permissions: + contents: write + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0 + with: + versionSpec: '5.x' + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + - name: Determine Version + id: gitversion # id to later be referenced + uses: gittools/actions/gitversion/execute@v0 + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --no-restore --configuration Release --property:Version=${{ steps.gitversion.outputs.nuGetVersionV2 }} + + - name: Test + run: dotnet test --no-build --configuration Release --verbosity normal + + - name: Publish Package to Nuget + if: github.event_name != 'pull_request' + run: | + rm -rf nuget/ + dotnet pack --no-build --configuration Release --property:Version=${{ steps.gitversion.outputs.nuGetVersionV2 }} --output nuget + dotnet nuget push nuget/*.nupkg -k '${{ secrets.NUGET_API_KEY }}' --skip-duplicate -s https://api.nuget.org/v3/index.json + + - name: Create Release + if: github.event_name != 'pull_request' + id: create_release + uses: actions/create-release@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: v${{ steps.gitversion.outputs.nuGetVersionV2 }} + release_name: v${{ steps.gitversion.outputs.nuGetVersionV2 }} + body: | + Release ${{ steps.gitversion.outputs.nuGetVersionV2 }} + draft: false + prerelease: false \ No newline at end of file diff --git a/.nuke b/.nuke deleted file mode 100644 index 00ce20b9..00000000 Binary files a/.nuke and /dev/null differ diff --git a/Build.ps1 b/Build.ps1 deleted file mode 100644 index b938d4b7..00000000 --- a/Build.ps1 +++ /dev/null @@ -1,54 +0,0 @@ -[CmdletBinding()] -Param( - [switch]$NoInit, - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] - [string[]]$BuildArguments -) - -Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { $host.SetShouldExit(1) } -$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent - -########################################################################### -# CONFIGURATION -########################################################################### - -$DotNetChannel = "2.0" -$BuildProjectFile = "$PSScriptRoot\.\build\.build.csproj" - -$TempDirectory = "$PSScriptRoot\.tmp" - -$DotNetScriptUrl = "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1" -$DotNetDirectory = "$TempDirectory\dotnet-win" -$DotNetFile = "$DotNetDirectory\dotnet.exe" -$env:DOTNET_EXE = $DotNetFile - -$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 -$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 -$env:NUGET_XMLDOC_MODE = "skip" - -########################################################################### -# PREPARE BUILD -########################################################################### - -function ExecSafe([scriptblock] $cmd) { - & $cmd - if ($LastExitCode -ne 0) { throw "The following call failed with exit code $LastExitCode. '$cmd'" } -} - -if (!$NoInit) { - md -force $DotNetDirectory > $null - - $DotNetScriptFile = "$TempDirectory\dotnet-install.ps1" - if (!(Test-Path $DotNetScriptFile)) { (New-Object System.Net.WebClient).DownloadFile($DotNetScriptUrl, $DotNetScriptFile) } - ExecSafe { & $DotNetScriptFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } - - ExecSafe { & $DotNetFile restore $BuildProjectFile } -} - -ExecSafe { & $DotNetFile build $BuildProjectFile --no-restore } - -########################################################################### -# EXECUTE BUILD -########################################################################### - -ExecSafe { & $DotNetFile run --project $BuildProjectFile --no-build -- $BuildArguments } diff --git a/DateTimeExtensions.sln b/DateTimeExtensions.sln index ecf16bc0..764b56e7 100644 --- a/DateTimeExtensions.sln +++ b/DateTimeExtensions.sln @@ -21,8 +21,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EB805547-455 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0F8CA42F-760A-4A42-BD0F-0AC9900B6712}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = ".build", "build\.build.csproj", "{8BB0AD48-A370-405F-B295-03D7F1811375}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DateTimeExtensions", "src\DateTimeExtensions\DateTimeExtensions.csproj", "{650FA9EC-03BE-43AF-87FF-9632856E31EE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DateTimeExtensions.Tests", "tests\DateTimeExtensions.Tests\DateTimeExtensions.Tests.csproj", "{2BB0401A-4DCA-4D59-B15D-6C895304D2AF}" @@ -33,8 +31,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8BB0AD48-A370-405F-B295-03D7F1811375}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8BB0AD48-A370-405F-B295-03D7F1811375}.Release|Any CPU.ActiveCfg = Release|Any CPU {650FA9EC-03BE-43AF-87FF-9632856E31EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {650FA9EC-03BE-43AF-87FF-9632856E31EE}.Debug|Any CPU.Build.0 = Debug|Any CPU {650FA9EC-03BE-43AF-87FF-9632856E31EE}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 40cea258..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,41 +0,0 @@ -version: '{build}' - -pull_requests: - do_not_increment_build_number: true - -branches: - only: - - master - -os: Visual Studio 2017 - -configuration: Release - -build_script: -- ps: .\Build.ps1 -Target Pack - -test: off - -nuget: - disable_publish_on_pr: true - -artifacts: -- path: artifacts\**\*.nupkg - name: NuGet - -deploy: -- provider: NuGet - name: ci - server: https://www.myget.org/F/datetimeextensions/api/v2/package - api_key: - secure: YcG+jkipdRz1ahroGCiCndKtgEcRaVtEzQYSNp5Mx5ULWPpZZ/MvwMsggLCYZ3bH - skip_symbols: true - on: - branch: master -- provider: NuGet - name: production - api_key: - secure: olWt58dVh65SDbzUsuaZv3lZefz8xcnZ62g5tZJDwPLGUlfKquZuow/j/LX5LiuY - on: - branch: master - appveyor_repo_tag: true diff --git a/build.sh b/build.sh deleted file mode 100644 index b4d22847..00000000 --- a/build.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env bash - -NOINIT=0 -BUILD_ARGUMENTS=() -for i in "$@"; do - case $(echo $1 | awk '{print tolower($0)}') in - -noinit) NOINIT=1;; - *) BUILD_ARGUMENTS+=("$1") ;; - esac - shift -done - -set -eo pipefail -SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) - -########################################################################### -# CONFIGURATION -########################################################################### - -DOTNET_CHANNEL="2.0" -BUILD_PROJECT_FILE="$SCRIPT_DIR/./build/.build.csproj" - -TEMP_DIRECTORY="$SCRIPT_DIR/.tmp" - -DOTNET_SCRIPT_URL="https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh" -DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" -DOTNET_FILE="$DOTNET_DIRECTORY/dotnet" -export DOTNET_EXE="$DOTNET_FILE" - -export DOTNET_CLI_TELEMETRY_OPTOUT=1 -export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 -export NUGET_XMLDOC_MODE="skip" - -########################################################################### -# PREPARE BUILD -########################################################################### - -if ! ((NOINIT)); then - mkdir -p "$DOTNET_DIRECTORY" - - DOTNET_SCRIPT_FILE="$TEMP_DIRECTORY/dotnet-install.sh" - if [ ! -f "$DOTNET_SCRIPT_FILE" ]; then curl -Lsfo "$DOTNET_SCRIPT_FILE" $DOTNET_SCRIPT_URL; chmod +x "$DOTNET_SCRIPT_FILE"; fi - "$DOTNET_SCRIPT_FILE" --install-dir "$DOTNET_DIRECTORY" --channel 2.0 --no-path - - "$DOTNET_FILE" restore "$BUILD_PROJECT_FILE" -fi - -"$DOTNET_FILE" build "$BUILD_PROJECT_FILE" --no-restore - -########################################################################### -# EXECUTE BUILD -########################################################################### - -"$DOTNET_FILE" run --project "$BUILD_PROJECT_FILE" --no-build -- ${BUILD_ARGUMENTS[@]} diff --git a/build/.build.csproj b/build/.build.csproj deleted file mode 100644 index 610da542..00000000 --- a/build/.build.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - Exe - netcoreapp2.0 - false - - - false - CS0649;CS0169 - 40 - C:\Users\Alsay\Desktop\DateTimeExtensions\Backup\build\ - 2.0 - - - - - - \ No newline at end of file diff --git a/build/.build.csproj.dotsettings b/build/.build.csproj.dotsettings deleted file mode 100644 index 919ea6bf..00000000 --- a/build/.build.csproj.dotsettings +++ /dev/null @@ -1,52 +0,0 @@ - - False - Implicit - Implicit - ExpressionBody - NEVER - WRAP_IF_LONG - True - False - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - True - True - True - True - True - True - True - True - True - True - True - json - metadata - True - NUKE tool metadata - True - getFileNameWithoutExtension() - -1 - 0 - True - - - True - InCSharpProjectFile - True - { - "$schema": "./_schema.json#", - "name": "$name$", - "customExecutable": true, - "tasks": [ - { - "settingsClass": { - "properties": [ - { - $END$ - } - ] - } - } - ] -} diff --git a/build/Build.cs b/build/Build.cs deleted file mode 100644 index f7fa4828..00000000 --- a/build/Build.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Linq; -using Nuke.Common; -using Nuke.Common.Git; -using Nuke.Common.Tools.GitVersion; -using static Nuke.Common.Tools.DotNet.DotNetTasks; -using static Nuke.Common.IO.FileSystemTasks; -using static Nuke.Common.IO.PathConstruction; -using static Nuke.Common.EnvironmentInfo; -using System.IO; -using Nuke.Common.Tools.DotNet; -using Nuke.Common.CI.AppVeyor; - -class Build : NukeBuild -{ - // Console application entry. Also defines the default target. - public static int Main () => Execute(x => x.Test); - - // Auto-injection fields: - // [GitVersion] readonly GitVersion GitVersion; - // - Semantic versioning. Must have 'GitVersion.CommandLine' referenced. - // [GitRepository] readonly GitRepository GitRepository; - // - Parses origin, branch name and head from git config. - // [Parameter] readonly string MyGetApiKey; - // - Returns command-line arguments and environment variables. - - public bool IsTagged => AppVeyor.Instance?.RepositoryTag ?? false; - - int Revision => AppVeyor.Instance?.BuildNumber ?? 1; - - public string RevisionString => IsTagged ? null : $"rev{Revision:D4}"; - - public string ArtifactsDirectory => RootDirectory / "artifacts"; - - public string OutputDirectory => RootDirectory / ".output"; - - Target Clean => _ => _ - .Executes(() => - { - EnsureCleanDirectory(OutputDirectory); - EnsureCleanDirectory(ArtifactsDirectory); - }); - - Target Restore => _ => _ - .DependsOn(Clean) - .Executes(() => - { - DotNetRestore(); - }); - - Target Compile => _ => _ - .DependsOn(Restore) - .Executes(() => - { - DotNetBuild(s => s - .SetVersionSuffix(RevisionString)); - }); - - Target Pack => _ => _ - .DependsOn(Compile, Test) - .Executes(() => - { - DotNetPack(s => s - .SetOutputDirectory(ArtifactsDirectory) - .SetProject(RootDirectory / "src" / "DateTimeExtensions") - .SetVersionSuffix(RevisionString)); - }); - - Target Test => _ => _ - .DependsOn(Compile) - .Executes(() => - { - DotNetTest(s => s - .SetProjectFile(RootDirectory / "tests" / "DateTimeExtensions.Tests")); - }); -} diff --git a/src/DateTimeExtensions/DateTimeExtensions.csproj b/src/DateTimeExtensions/DateTimeExtensions.csproj index 8d3344b8..8dd76b4f 100644 --- a/src/DateTimeExtensions/DateTimeExtensions.csproj +++ b/src/DateTimeExtensions/DateTimeExtensions.csproj @@ -3,7 +3,7 @@ This project is a merge of several common DateTime operations on the form of extensions to System.DateTime, including natural date difference text (precise and human rounded), holidays and working days calculations on several culture locales. Feedback will be much appreciated. DateTime Extensions Joao Matos Silva - netstandard2.0;net461 + netstandard2.0 DateTimeExtensions DateTimeExtensions Natural;Date;Time;Relative;Calendar;Holiday;Workingday;DateTime @@ -18,28 +18,7 @@ https://github.com/joaomatossilva/DateTimeExtensions/raw/master/assets/datetimeextensions-60-logo.png true $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - 40 - C:\Users\Alsay\Desktop\DateTimeExtensions\Backup\src\DateTimeExtensions\ - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - True @@ -53,11 +32,7 @@ HolidayNames.Designer.cs - diff --git a/tests/DateTimeExtensions.Tests/DateTimeExtensions.Tests.csproj b/tests/DateTimeExtensions.Tests/DateTimeExtensions.Tests.csproj index 8e8d887c..c099f23e 100644 --- a/tests/DateTimeExtensions.Tests/DateTimeExtensions.Tests.csproj +++ b/tests/DateTimeExtensions.Tests/DateTimeExtensions.Tests.csproj @@ -1,28 +1,25 @@  - netcoreapp2.0;net461 + net6.0 + disable + disable DateTimeExtensions.Tests DateTimeExtensions.Tests - true - $(PackageTargetFallback);dnxcore50;portable-net461+win8 - 1.1.1 - false - false - false - 40 - C:\Users\Alsay\Desktop\DateTimeExtensions\Backup\tests\DateTimeExtensions.Tests\ - 2.0 + + false + true + - + - - + + + + + - - - \ No newline at end of file diff --git a/tests/DateTimeExtensions.Tests/Properties/AssemblyInfo.cs b/tests/DateTimeExtensions.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 34f78e22..00000000 --- a/tests/DateTimeExtensions.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("DateTimeExtensions.Tests")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c3ea657c-2733-41ff-a1d0-0eea23fc426b")] diff --git a/tests/DateTimeExtensions.Tests/TestResult.xml b/tests/DateTimeExtensions.Tests/TestResult.xml deleted file mode 100644 index a489d2b2..00000000 --- a/tests/DateTimeExtensions.Tests/TestResult.xml +++ /dev/null @@ -1,265 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/DateTimeExtensions.Tests/packages.config b/tests/DateTimeExtensions.Tests/packages.config deleted file mode 100644 index 8f334ce8..00000000 --- a/tests/DateTimeExtensions.Tests/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/tests/DateTimeExtensions.xTests/DateTimeExtensions.xTests.csproj b/tests/DateTimeExtensions.xTests/DateTimeExtensions.xTests.csproj deleted file mode 100644 index c9debe2a..00000000 --- a/tests/DateTimeExtensions.xTests/DateTimeExtensions.xTests.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - net7.0 - enable - enable - - false - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - diff --git a/tests/DateTimeExtensions.xTests/RomanianTests.cs b/tests/DateTimeExtensions.xTests/RomanianTests.cs deleted file mode 100644 index 2ce03131..00000000 --- a/tests/DateTimeExtensions.xTests/RomanianTests.cs +++ /dev/null @@ -1,79 +0,0 @@ -using DateTimeExtensions.NaturalText; -using DateTimeExtensions.WorkingDays; -using DateTimeExtensions.WorkingDays.CultureStrategies; -using System.IO; -using DateTimeExtensions.Export; - -namespace DateTimeExtensions.xTests -{ - public class RomanianTests - { - private NaturalTextCultureInfo ro_ci = new NaturalTextCultureInfo("ro-RO"); - private WorkingDayCultureInfo dateTimeCulture = new WorkingDayCultureInfo("ro-RO"); - - private DateTime fromTime = new DateTime(2016, 6, 21, 10, 28, 0); - - - [Fact] - public void Test1() - { - //var toTime = fromTime.AddHours(2).AddMinutes(45); - - //var naturalText = fromTime.ToNaturalText(toTime, false, ro_ci); - - //Assert.NotNull(naturalText); - //Assert.NotEmpty(naturalText); - //Assert.Equal("2 ore", naturalText); - - var toTime = fromTime.AddSeconds(6).AddMinutes(5).AddHours(4).AddDays(3).AddMonths(2).AddYears(2); - - var naturalText = fromTime.ToExactNaturalText(toTime, ro_ci); - - Assert.NotNull(naturalText); - Assert.NotEmpty(naturalText); - Assert.Equal("2 ani, 2 luni, 3 zile, 4 ore, 5 minute, 6 secunde", naturalText); - } - - [Fact] - public void Test2() - { - var holidaysStrategy = dateTimeCulture.LocateHolidayStrategy(dateTimeCulture.Name, null); - - Assert.Equal(typeof(RomanianHolidayStrategy), holidaysStrategy.GetType()); - var workingDaysStrategy = dateTimeCulture.LocateWorkingDayOfWeekStrategy(dateTimeCulture.Name, null); - Assert.Equal(typeof(DefaultWorkingDayOfWeekStrategy), workingDaysStrategy.GetType()); - } - - [Fact] - public void Test3() - { - var holiday = RomanianHolidayStrategy.ChildrensDay; - var day = new DateTime(2022, 6, 1); - TestHoliday(holiday, day); - } - - [Fact] - public void Test4() - { - var orthodoxEaster = ChristianOrthodoxHolidays.Easter; - var easter_2022 = orthodoxEaster.GetInstance(2022); - var easter_2023 = orthodoxEaster.GetInstance(2023); - var easter_2024 = orthodoxEaster.GetInstance(2024); - var easter_2025 = orthodoxEaster.GetInstance(2025); - - TextWriter textwriter = new StringWriter(); - var exporter = ExportHolidayFormatLocator.LocateByType(ExportType.OfficeHolidays); - exporter.Export(dateTimeCulture, 2024, textwriter); - var s = textwriter.ToString(); - Assert.NotNull(s); - } - - private void TestHoliday(Holiday holiday, DateTime dateOnGregorian) - { - var holidayInstance = holiday.GetInstance(dateOnGregorian.Year); - Assert.True(holidayInstance.HasValue); - Assert.Equal(dateOnGregorian, holidayInstance.Value); - Assert.True(holiday.IsInstanceOf(dateOnGregorian)); - } - } -} \ No newline at end of file diff --git a/tests/DateTimeExtensions.xTests/Usings.cs b/tests/DateTimeExtensions.xTests/Usings.cs deleted file mode 100644 index 8c927eb7..00000000 --- a/tests/DateTimeExtensions.xTests/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using Xunit; \ No newline at end of file