diff --git a/CHANGELOG.md b/CHANGELOG.md index d48c6cc..f6f4bdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,28 @@ # Changelog -## Unreleased +## [Unreleased] + +### Added + +* Warnings when the `` property is not set, or when the specified file cannot be found +* Automatic pre-release version bumping when an `Unreleased` section is found, which increments the patch version of the latest release and adds the "-alpha" suffix +* Added a property `` which can be set to `false` to prevent automatic version bumping +* Added an output property `UnreleasedReleaseNotes` containing the contents of the `Unreleased` section +* Added a property `` which controls whether the `BuildDate` `AssemblyAttribute` is written to the assembly, default `true` + +### Changed + +* No longer automatically use a `CHANGELOG.md` file, the path to the changelog must not be specified with the `` property +* Swapped to using the `KeepAChangelogParser` package for parsing ### Fixed * Fix bundled dependencies into the package for net6.0 +* Support for use in Visual Studio + +### Removed + +* Removed the Ionide.KeepAChangelog parser package ## [0.2.0] - 2023.12.05 diff --git a/Directory.Packages.props b/Directory.Packages.props index 03d8250..56d35f8 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -21,5 +21,6 @@ + \ No newline at end of file diff --git a/README.md b/README.md index 4566c2c..aff40d3 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# Ionide.KeepAChangelog +# Ionide.KeepAChangelog.Tasks -This project implements a Changelog parser according to the spec at KeepAChangelog. It also provides MSBuild tasks and targets to automate the setting of **Versions** and **Package Release Notes** for your NuGet packages, so that the Changelogs are your source of truth. +This project provides MSBuild tasks and targets to automate the setting of **Versions** and **Package Release Notes** for your NuGet packages from changelogs meeting the spec at [KeepAChangelog](https://keepachangelog.com), so that the Changelogs are your source of truth. -When configured, this package will set the `Version`, `PackageVersion`, and `PackageReleaseNotes` of your packable project with the matching data from the latest Changelog release, as well as adding AssemblyMetadata for the `BuildDate` in the `YYYY-mm-dd` format. +When configured, this package will set the `Version`, `PackageVersion`, and `PackageReleaseNotes` of your packable project with the matching data from the latest Changelog release, or calculated from the unreleased section, as well as adding AssemblyMetadata for the `BuildDate` in the `YYYY-mm-dd` format. ## Installation @@ -69,7 +69,14 @@ If your changelog has multiple versions, the latest one will be used. ## Customization -There's really only one property that matters for these targets, and that's `ChangelogFile`. This needs to point to the Changelog file you want to read, but it defaults to `CHANGELOG.md` in the root of a given project in case you want to adhere to defaults. +There's really only one property that matters for these targets, and that's `ChangelogFile`. This needs to point to the Changelog file you want to read, and a warning will be emitted if you try to package your project without having set this. + + +| Property | Type | Default Value | Description | +| - | - |---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| ChangelogFile | string | - | Points to the changelog file to parse. Note that the value is relative to the _project_ root by default, so a repository-wide changelog would require this property be set to a different value, for example in a Directory.Build.props file | +| GenerateVersionForUnreleasedChanges | boolean | true | If set, the assembly/package version and release notes will be set from Unreleased changes, if any are present. | +| GenerateAssemblyBuildDateAttribute | boolean | true | If set, an assembly metadata attribute named "BuildDate" will be generated with the date (YYYY-MM-DD) of the parsed release. | ## API @@ -77,12 +84,13 @@ When the task runs, it writes several output items and properties: |Name|Type|Description| |----|----|-----------| -| UnreleasedChangelog | UnreleasedChangelogData option | If present, there was an 'Unreleased' section in the Changelog. This structure will contain the sections present. | +| UnreleasedChangelog | ReleaseChangelogData option | If present, there was an 'Unreleased' section in the Changelog. This structure will contain the sections present, as well as an auto-incremented version number for this release. | +| UnreleasedReleaseNotes | string option | If present, contains the concatenated list of all Changelog sections for the Unreleased section of the Changelog. This is a convenience property so that you don't have to String.Join all the lines in the `ReleaseChangelogData` structure yourself! | | CurrentReleaseChangelog | ReleaseChangelogData option | If present, there was at least one released logged in the Changelog. This structure will contain the details of each one. | -| AllReleasedChangelogs | ReleaseChangelogData list | Contains the ordered list of all released in the ChangelogFile, descending. | +| AllReleasedChangelogs | ReleaseChangelogData list | Contains the ordered list of all releases in the ChangelogFile, descending. | | LatestReleaseNotes | string option | If present, contains the concatenated list of all Changelog sections for the latest release. This is a convenience property so that you don't have to String.Join all the lines in the `ReleaseChangelogData` yourself! | -### ChangelogData +### ReleaseChangelogData This TaskItem has metadata for each of the known sections of a Changelog: @@ -95,14 +103,7 @@ This TaskItem has metadata for each of the known sections of a Changelog: In each case, the value of the metadata is the newline-concatenated list of all of the Changelog Entries for that section. -### UnreleasedChangelogData - -This structure is a `ChangelogData` with an `Identity` of `"Unreleased"`. - -### ReleaseChangelogData - -This structure is the same as `ChangelogData`, but it contains two more items of metadata: - +In addition, * the `Identity` of the `TaskItem` is the Semantic Version of the release * the `Date` of the `TaskItem` is the `YYYY-MM-DD`-formatted date of the release diff --git a/src/Library.fs b/src/Library.fs index a48d7c6..beca480 100644 --- a/src/Library.fs +++ b/src/Library.fs @@ -4,6 +4,7 @@ open System open System.Globalization open System.Runtime.CompilerServices open System.Text +open FsToolkit.ErrorHandling.Operator.Result open Microsoft.Build.Utilities open Microsoft.Build.Framework open System.IO @@ -86,6 +87,9 @@ type ParseChangeLogs() = [] member val UnreleasedChangelog: ITaskItem = null with get, set + [] + member val UnreleasedReleaseNotes: string = null with get, set + [] member val CurrentReleaseChangelog: ITaskItem = null with get, set @@ -104,7 +108,8 @@ type ParseChangeLogs() = let! changelog = this.ParseChangelog file do! this.ReadUnreleasedSection changelog - do! this.ProcessReleases changelog + let latestRelease = this.ProcessReleases changelog + do! this.UpdateUnreleasedVersion latestRelease return true } @@ -128,36 +133,54 @@ type ParseChangeLogs() = Error() member this.ReadUnreleasedSection(changelog: Changelog) = - match changelog.SectionUnreleased with - | null -> Ok() - | unreleased -> - this.UnreleasedChangelog <- unreleased.ToTaskItem() + let unreleasedSection = changelog.SectionUnreleased + + match unreleasedSection.MarkdownTitle with + | "" -> Ok() + | _ -> + this.UnreleasedChangelog <- unreleasedSection.ToTaskItem() + this.UnreleasedReleaseNotes <- unreleasedSection.SubSectionCollection.ToMarkdown() Ok() member this.ProcessReleases(changelog: Changelog) = let releases = changelog.SectionCollection.Unwrapped() |> Seq.sortByDescending _.version - |> Seq.toArray + |> Seq.toList - let latestRelease = releases |> (fun x -> x[0]) + match releases with + | [] -> None + | latestRelease :: _ -> + let mapped = + releases + |> List.map (fun x -> + let taskItem = TaskItem(x.version.ToString()) + taskItem.SetMetadata("Date", x.date.ToString("yyyy-MM-dd")) - let mapped = - releases - |> Array.map (fun x -> - let taskItem = TaskItem(x.version.ToString()) - taskItem.SetMetadata("Date", x.date.ToString("yyyy-MM-dd")) + for (key, value) in x.collection.ToTaskItemMetadata() do + taskItem.SetMetadata(key, value) - for (key, value) in x.collection.ToTaskItemMetadata() do - taskItem.SetMetadata(key, value) + taskItem :> ITaskItem + ) + |> Array.ofList - taskItem :> ITaskItem - ) + this.CurrentReleaseChangelog <- mapped[0] + this.AllReleasedChangelogs <- mapped + this.LatestReleaseNotes <- latestRelease.collection.ToMarkdown() + Some(latestRelease.version) - this.CurrentReleaseChangelog <- mapped[0] - this.AllReleasedChangelogs <- mapped - this.LatestReleaseNotes <- latestRelease.collection.ToMarkdown() - Ok() + member this.UpdateUnreleasedVersion(latestVersion: SemVersion option) = + let latestVersion = latestVersion |> Option.defaultValue (SemVersion(0, 0, 0)) + + match this.UnreleasedChangelog with + | null -> Ok() + | _ -> + let newUnreleased = + latestVersion.WithPrereleaseParsedFrom "alpha" + |> _.WithPatch(latestVersion.Patch + 1) + + this.UnreleasedChangelog.ItemSpec <- newUnreleased.ToString() + Ok() /// /// Helper method to log an error with the given log data. diff --git a/src/build/Core.targets b/src/build/Core.targets index 671f75c..456533b 100644 --- a/src/build/Core.targets +++ b/src/build/Core.targets @@ -18,23 +18,35 @@ + - + + %(CurrentReleaseChangelog.Identity) %(CurrentReleaseChangelog.Identity) @(LatestReleaseNotes) + <_ReleaseDate>%(CurrentReleaseChangelog.Date) + + + + %(UnreleasedChangelog.Identity) + %(UnreleasedChangelog.Identity) + @(UnreleasedReleaseNotes) + <_ReleaseDate>%(UnreleasedChangelog.Date) + - - + + <_Parameter1>BuildDate - <_Parameter2>%(CurrentReleaseChangelog.Date) + <_Parameter2>$(_ReleaseDate) diff --git a/src/build/Ionide.KeepAChangelog.Tasks.props b/src/build/Ionide.KeepAChangelog.Tasks.props new file mode 100644 index 0000000..38b8b1c --- /dev/null +++ b/src/build/Ionide.KeepAChangelog.Tasks.props @@ -0,0 +1,8 @@ + + + + true + + true + + diff --git a/src/buildMultiTargeting/Ionide.KeepAChangelog.Tasks.props b/src/buildMultiTargeting/Ionide.KeepAChangelog.Tasks.props new file mode 100644 index 0000000..cee0af5 --- /dev/null +++ b/src/buildMultiTargeting/Ionide.KeepAChangelog.Tasks.props @@ -0,0 +1,3 @@ + + + diff --git a/tests/IntegrationTests.fs b/tests/IntegrationTests.fs index 19ab843..29f241c 100644 --- a/tests/IntegrationTests.fs +++ b/tests/IntegrationTests.fs @@ -1,6 +1,9 @@ module Tests.IntegrationTests open System.IO +open System.IO.Compression +open System.Reflection +open System.Runtime.InteropServices open System.Threading.Tasks open Ionide.KeepAChangelog.Tasks.Test open Microsoft.VisualStudio.TestTools.UnitTesting @@ -11,46 +14,80 @@ open Workspace open Helpers module Utils = - let packAndGetPackageProperties projectName = - let packageCache = VirtualWorkspace.``test-package-cache``.``.`` + let packAndGetPackagePropertiesWithExtraArg projectName (extraArg: string option) = + task { - if Directory.Exists packageCache then - Directory.Delete(packageCache, true) + let packageCache = VirtualWorkspace.``test-package-cache``.``.`` - Directory.CreateDirectory packageCache |> ignore + // Force restoring of the latest package by clearing the local packages directory + if Directory.Exists packageCache then + Directory.Delete(packageCache, true) - Command.Run( - "dotnet", - CmdLine.empty - |> CmdLine.appendPrefix "restore" projectName - |> CmdLine.appendPrefix "--packages" VirtualWorkspace.``test-package-cache``.``.`` - |> CmdLine.toString, - workingDirectory = Workspace.fixtures.``.`` - ) + Directory.CreateDirectory packageCache |> ignore - Command.ReadAsync( - "dotnet", - CmdLine.empty - |> CmdLine.appendPrefix "pack" projectName - |> CmdLine.appendPrefix "-c" "Release" - |> CmdLine.append "--no-restore" - |> CmdLine.appendRaw "--getProperty:Version" - |> CmdLine.appendRaw "--getProperty:PackageVersion" - |> CmdLine.appendRaw "--getProperty:PackageReleaseNotes" - |> CmdLine.toString, - workingDirectory = Workspace.fixtures.``.`` - ) + // Read improves the error logging when the command fails + let! _, _ = + Command.ReadAsync( + "dotnet", + CmdLine.empty + |> CmdLine.appendPrefix "restore" projectName + |> CmdLine.appendPrefix "--packages" VirtualWorkspace.``test-package-cache``.``.`` + |> CmdLine.toString, + workingDirectory = Workspace.fixtures.``.`` + ) -[] -type IntegrationTests() = + let extraArg = extraArg |> Option.defaultValue "" - member val testPackageVersion = null with get, set + return! + Command.ReadAsync( + "dotnet", + CmdLine.empty + |> CmdLine.appendPrefix "pack" projectName + |> CmdLine.appendPrefix "-c" "Release" + |> CmdLine.append "--no-restore" + |> CmdLine.appendIfNotNullOrEmpty extraArg + |> CmdLine.appendRaw "--getProperty:Version" + |> CmdLine.appendRaw "--getProperty:PackageVersion" + |> CmdLine.appendRaw "--getProperty:PackageReleaseNotes" + |> CmdLine.toString, + workingDirectory = Workspace.fixtures.``.`` + ) + } + + let packAndGetPackageProperties projectName = + packAndGetPackagePropertiesWithExtraArg projectName None - member this.AddPackageReference(projectName: string) = - let suffix = projectName.Replace(".fsproj", "") + let getAssemblyInfoFromNupkg (projectName: string) version = + let projectName = Path.GetFileNameWithoutExtension projectName - this.testPackageVersion <- $"0.0.1-test-{suffix}" + let packageFile = + Path.Combine(VirtualWorkspace.fixtures.bin.Release.``.``, $"{projectName}.{version}.nupkg") + + File.Exists(packageFile).Should().BeTrue() |> ignore + + use zip = ZipFile.OpenRead(packageFile) + use zipStream = zip.Entries |> Seq.find (_.Name.EndsWith(".dll")) |> _.Open() + use assemblyStream = new MemoryStream() + zipStream.CopyTo assemblyStream + + let runtimeAssemblies = + Directory.GetFiles(RuntimeEnvironment.GetRuntimeDirectory(), "*.dll") + + use mlc = new MetadataLoadContext(PathAssemblyResolver runtimeAssemblies) + let assembly = mlc.LoadFromStream assemblyStream + + assembly.CustomAttributes + |> Seq.tryPick (fun attr -> + match attr.ConstructorArguments |> Seq.map _.Value.ToString() |> Seq.toArray with + | [| "BuildDate"; date |] -> Some date + | _ -> None + ) +[] +type IntegrationTests() = + [] + member this.Initialize() = + this.testPackageVersion <- $"0.0.1-test" // Create a package to be used in the tests // I didn't find a way to test the MSBuild tasks execution using MSBuild only // So each fsproj, will use a package reference to the package created here @@ -65,24 +102,30 @@ type IntegrationTests() = workingDirectory = Workspace.``..``.``.`` ) - Command.Run( - "dotnet", - CmdLine.empty - |> CmdLine.appendPrefix "add" projectName - |> CmdLine.appendPrefix "package" "Ionide.KeepAChangelog.Tasks" - // |> CmdLine.appendPrefix "--source" VirtualWorkspace.``test-nupkgs``.``.`` - |> CmdLine.appendPrefix "--version" $"[{this.testPackageVersion}]" - |> CmdLine.toString, - workingDirectory = Workspace.fixtures.``.`` - ) + member val testPackageVersion = null with get, set + + member this.AddPackageReference(projectName: string) : Task = + task { + let! struct (_, _) = + Command.ReadAsync( + "dotnet", + CmdLine.empty + |> CmdLine.appendPrefix "add" projectName + |> CmdLine.appendPrefix "package" "Ionide.KeepAChangelog.Tasks" + // |> CmdLine.appendPrefix "--source" VirtualWorkspace.``test-nupkgs``.``.`` + |> CmdLine.appendPrefix "--version" $"[{this.testPackageVersion}]" + |> CmdLine.toString, + workingDirectory = Workspace.fixtures.``.`` + ) + + () + } [] member this.``works for absolute path with keep a changelog``() : Task = task { let projectName = "WorksForAbsolutePathWithKeepAChangelog.fsproj" - this.AddPackageReference projectName - let! struct (stdout, _) = Utils.packAndGetPackageProperties projectName stdout @@ -98,6 +141,9 @@ type IntegrationTests() = """ ) |> ignore + + let buildDate = Utils.getAssemblyInfoFromNupkg projectName "0.1.0" + buildDate.Should().BeSome().WhoseValue.Should().Be("2022-01-13") |> ignore } [] @@ -105,10 +151,13 @@ type IntegrationTests() = task { let projectName = "WorksForRelativePathWithKeepAChangelog.fsproj" - this.AddPackageReference projectName + do! this.AddPackageReference projectName let! struct (stdout, _) = Utils.packAndGetPackageProperties projectName + let buildDate = Utils.getAssemblyInfoFromNupkg projectName "0.1.0" + buildDate.Should().BeSome().WhoseValue.Should().Be("2022-01-13") |> ignore + stdout .Should() .BeLineEndingEquivalent( @@ -129,7 +178,7 @@ type IntegrationTests() = task { let projectName = "FailIfChangelogNotSpecified.fsproj" - this.AddPackageReference projectName + do! this.AddPackageReference projectName let! struct (stdout, _) = Utils.packAndGetPackageProperties projectName @@ -153,7 +202,7 @@ type IntegrationTests() = task { let projectName = "FailIfChangelogDoesNotExist.fsproj" - this.AddPackageReference projectName + do! this.AddPackageReference projectName let! struct (stdout, _) = Utils.packAndGetPackageProperties projectName @@ -171,3 +220,84 @@ type IntegrationTests() = ) |> ignore } + + [] + member this.``generates a pre-release version if changelog has unreleased section``() : Task = + task { + let projectName = "WorksForUnreleased.fsproj" + + do! this.AddPackageReference projectName + + let! struct (stdout, _) = Utils.packAndGetPackageProperties projectName + + stdout + .Should() + .BeLineEndingEquivalent( + """{ + "Properties": { + "Version": "0.1.1-alpha", + "PackageVersion": "0.1.1-alpha", + "PackageReleaseNotes": "### Removed\n\n- A test removal line\n- And another removal" + } +} +""" + ) + |> ignore + + let buildDate = Utils.getAssemblyInfoFromNupkg projectName "0.1.1-alpha" + buildDate.Should().BeNone() |> ignore + } + + [] + member this.``ignores a pre-release version if changelog has unreleased section but disabled``() : Task = + task { + let projectName = "WorksForUnreleasedWhenIgnored.fsproj" + + do! this.AddPackageReference projectName + + let! struct (stdout, _) = Utils.packAndGetPackageProperties projectName + + let buildDate = Utils.getAssemblyInfoFromNupkg projectName "0.1.0" + buildDate.Should().BeSome().WhoseValue.Should().Be("2022-01-13") |> ignore + + stdout + .Should() + .BeLineEndingEquivalent( + """{ + "Properties": { + "Version": "0.1.0", + "PackageVersion": "0.1.0", + "PackageReleaseNotes": "### Added\n\n- Created the package\n\n### Changed\n\n- Changed something in the package\n- Updated the target framework" + } +} +""" + ) + |> ignore + } + + [] + member this.``doesn't write the build date if disabled``() : Task = + task { + let projectName = "IgnoresBuildDateIfConfigured.fsproj" + + do! this.AddPackageReference projectName + + let! struct (stdout, _) = Utils.packAndGetPackageProperties projectName + + stdout + .Should() + .BeLineEndingEquivalent( + """{ + "Properties": { + "Version": "0.1.0", + "PackageVersion": "0.1.0", + "PackageReleaseNotes": "### Added\n\n- Created the package\n\n### Changed\n\n- Changed something in the package\n- Updated the target framework" + } +} +""" + ) + |> ignore + + let buildDate = Utils.getAssemblyInfoFromNupkg projectName "0.1.0" + buildDate.Should().BeNone() |> ignore + } diff --git a/tests/Ionide.KeepAChangelog.Tasks.Test.fsproj b/tests/Ionide.KeepAChangelog.Tasks.Test.fsproj index bc17ce0..40e7a6d 100644 --- a/tests/Ionide.KeepAChangelog.Tasks.Test.fsproj +++ b/tests/Ionide.KeepAChangelog.Tasks.Test.fsproj @@ -25,6 +25,7 @@ + @@ -33,6 +34,7 @@ + diff --git a/tests/UnitTests.fs b/tests/UnitTests.fs index 43a096e..90fa427 100644 --- a/tests/UnitTests.fs +++ b/tests/UnitTests.fs @@ -92,7 +92,7 @@ type UnitTests() = myTask.BuildEngine <- this.context.BuildEngine.Object let success = myTask.Execute() - %success.Should().BeTrue "Should have successfully parsed the changelog data" + %success.Should().BeTrue("Should have successfully parsed the changelog data") %myTask.AllReleasedChangelogs.Length.Should().Be(9, "Should have 9 versions") %myTask.CurrentReleaseChangelog.ItemSpec @@ -112,24 +112,93 @@ type UnitTests() = |> Seq.cast |> _.Should().Contain("Date", "Should have date metadata")) + %myTask.UnreleasedChangelog.ItemSpec + .Should() + .Be("0.1.9-alpha", "Should have the alpha prefix from a patch release") + + %(myTask.UnreleasedChangelog.MetadataNames + |> Seq.cast + |> _.Should().Contain("Removed", "Should have removed metadata")) + [] member this.``task produces expected markdown``() = - let myTask = ParseChangeLogs(ChangelogFile = Workspace.changelogs.``CHANGELOG.md``) + let myTask = + ParseChangeLogs(ChangelogFile = Workspace.changelogs.``CHANGELOG_detailed.md``) myTask.BuildEngine <- this.context.BuildEngine.Object let success = myTask.Execute() - %success.Should().BeTrue "Should have successfully parsed the changelog data" + %success.Should().BeTrue("Should have successfully parsed the changelog data") %myTask.LatestReleaseNotes .Should() .BeLineEndingEquivalent( - """### Added + """### Changed -- Created the package +- Minor packaging fix for non-Core MSBuild versions""" + ) -### Changed + %myTask.UnreleasedReleaseNotes + .Should() + .BeLineEndingEquivalent( + """### Removed -- Changed something in the package -- Updated the target framework""" +- A test removal line +- And another removal""" ) + + [] + member this.``task correctly processes a changelog with no unreleased``() = + let myTask = ParseChangeLogs(ChangelogFile = Workspace.changelogs.``CHANGELOG.md``) + + myTask.BuildEngine <- this.context.BuildEngine.Object + + let success = myTask.Execute() + %success.Should().BeTrue("Should have successfully parsed the changelog data") + + %myTask.CurrentReleaseChangelog.ItemSpec + .Should() + .Be("0.1.0", "It is the latest release") + + %myTask.LatestReleaseNotes.Should().NotBeNull().And.NotBeEmpty() + + %myTask.AllReleasedChangelogs + .Should() + .HaveLength(1, "There is only a single release section") + + %myTask.UnreleasedChangelog.Should().BeNull("There is no unreleased section") + %myTask.UnreleasedReleaseNotes.Should().BeNull("There is no unreleased section") + + [] + member this.``task correctly processes a changelog with only unreleased``() = + let myTask = + ParseChangeLogs(ChangelogFile = Workspace.changelogs.``CHANGELOG_unreleased.md``) + + myTask.BuildEngine <- this.context.BuildEngine.Object + + let success = myTask.Execute() + %success.Should().BeTrue("Should have successfully parsed the changelog data") + %myTask.CurrentReleaseChangelog.Should().BeNull("There are no released sections") + %myTask.LatestReleaseNotes.Should().BeNull("There are no released sections") + %myTask.AllReleasedChangelogs.Should().BeNull("There are no released sections") + + %myTask.UnreleasedChangelog.ItemSpec + .Should() + .Be("0.0.1-alpha", "There is no previous version, so it starts from 0.0.0") + + %myTask.UnreleasedReleaseNotes.Should().NotBeNull().And.NotBeEmpty() + + [] + member this.``task correctly processes a changelog with only introduction``() = + let myTask = + ParseChangeLogs(ChangelogFile = Workspace.changelogs.``CHANGELOG_empty.md``) + + myTask.BuildEngine <- this.context.BuildEngine.Object + + let success = myTask.Execute() + %success.Should().BeTrue("Should have successfully parsed the changelog data") + %myTask.CurrentReleaseChangelog.Should().BeNull("There are no released sections") + %myTask.LatestReleaseNotes.Should().BeNull("There are no released sections") + %myTask.AllReleasedChangelogs.Should().BeNull("There are no released sections") + %myTask.UnreleasedChangelog.Should().BeNull("There is no unreleased section") + %myTask.UnreleasedReleaseNotes.Should().BeNull("There is no unreleased section") diff --git a/tests/Workspace.fs b/tests/Workspace.fs index af668b6..eb38323 100644 --- a/tests/Workspace.fs +++ b/tests/Workspace.fs @@ -10,5 +10,8 @@ type VirtualWorkspace = """ test-nupkgs/ test-package-cache/ +fixtures/ + bin/ + Release/ """ > diff --git a/tests/changelogs/CHANGELOG.md b/tests/changelogs/CHANGELOG.md index 9d447ad..5f396c8 100644 --- a/tests/changelogs/CHANGELOG.md +++ b/tests/changelogs/CHANGELOG.md @@ -1,12 +1,5 @@ # Changelog -## [Unreleased] - -### Removed - -- A test removal line -- And another removal - ## [0.1.0] - 2022-01-13 ### Added diff --git a/tests/changelogs/CHANGELOG_detailed.md b/tests/changelogs/CHANGELOG_detailed.md index 8bc7ed5..dc25472 100644 --- a/tests/changelogs/CHANGELOG_detailed.md +++ b/tests/changelogs/CHANGELOG_detailed.md @@ -1,5 +1,12 @@ # Changelog +## [Unreleased] + +### Removed + +- A test removal line +- And another removal + ## [0.1.8] - 2022-03-31 ### Changed diff --git a/tests/changelogs/CHANGELOG_empty.md b/tests/changelogs/CHANGELOG_empty.md new file mode 100644 index 0000000..3f46209 --- /dev/null +++ b/tests/changelogs/CHANGELOG_empty.md @@ -0,0 +1,3 @@ +# Changelog + +Some notes in the header but no sections diff --git a/tests/changelogs/CHANGELOG_unreleased.md b/tests/changelogs/CHANGELOG_unreleased.md new file mode 100644 index 0000000..ccf8ee6 --- /dev/null +++ b/tests/changelogs/CHANGELOG_unreleased.md @@ -0,0 +1,9 @@ +# Changelog + +## [Unreleased] + +### Removed + +- A test removal line +- And another removal + diff --git a/tests/fixtures/CHANGELOG.md b/tests/fixtures/CHANGELOG.md index 9d447ad..5f396c8 100644 --- a/tests/fixtures/CHANGELOG.md +++ b/tests/fixtures/CHANGELOG.md @@ -1,12 +1,5 @@ # Changelog -## [Unreleased] - -### Removed - -- A test removal line -- And another removal - ## [0.1.0] - 2022-01-13 ### Added diff --git a/tests/fixtures/CHANGELOG_KeepAChangelog.md b/tests/fixtures/CHANGELOG_KeepAChangelog.md index 5c2288c..54aa7d4 100644 --- a/tests/fixtures/CHANGELOG_KeepAChangelog.md +++ b/tests/fixtures/CHANGELOG_KeepAChangelog.md @@ -1,7 +1,5 @@ # Changelog -## [Unreleased] - ## [0.1.0] - 2022-01-13 ### Added diff --git a/tests/fixtures/CHANGELOG_unreleased.md b/tests/fixtures/CHANGELOG_unreleased.md new file mode 100644 index 0000000..9d447ad --- /dev/null +++ b/tests/fixtures/CHANGELOG_unreleased.md @@ -0,0 +1,19 @@ +# Changelog + +## [Unreleased] + +### Removed + +- A test removal line +- And another removal + +## [0.1.0] - 2022-01-13 + +### Added + +- Created the package + +### Changed + +- Changed something in the package +- Updated the target framework diff --git a/tests/fixtures/FailIfChangelogDoesNotExist.fsproj b/tests/fixtures/FailIfChangelogDoesNotExist.fsproj index dd1973a..55da178 100644 --- a/tests/fixtures/FailIfChangelogDoesNotExist.fsproj +++ b/tests/fixtures/FailIfChangelogDoesNotExist.fsproj @@ -11,7 +11,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/fixtures/FailIfChangelogNotSpecified.fsproj b/tests/fixtures/FailIfChangelogNotSpecified.fsproj index b9a3b85..a088c30 100644 --- a/tests/fixtures/FailIfChangelogNotSpecified.fsproj +++ b/tests/fixtures/FailIfChangelogNotSpecified.fsproj @@ -7,7 +7,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/fixtures/IgnoresBuildDateIfConfigured.fsproj b/tests/fixtures/IgnoresBuildDateIfConfigured.fsproj new file mode 100644 index 0000000..7201cc9 --- /dev/null +++ b/tests/fixtures/IgnoresBuildDateIfConfigured.fsproj @@ -0,0 +1,22 @@ + + + + + net6.0 + + + + CHANGELOG_unreleased.md + false + false + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/tests/fixtures/NuGet.config b/tests/fixtures/NuGet.config index f7113cd..4049062 100644 --- a/tests/fixtures/NuGet.config +++ b/tests/fixtures/NuGet.config @@ -3,6 +3,17 @@ - + + + + + + + + + + + + diff --git a/tests/fixtures/WorksForAbsolutePathWithKeepAChangelog.fsproj b/tests/fixtures/WorksForAbsolutePathWithKeepAChangelog.fsproj index 41ff699..51b0a62 100644 --- a/tests/fixtures/WorksForAbsolutePathWithKeepAChangelog.fsproj +++ b/tests/fixtures/WorksForAbsolutePathWithKeepAChangelog.fsproj @@ -10,8 +10,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/fixtures/WorksForRelativePathWithKeepAChangelog.fsproj b/tests/fixtures/WorksForRelativePathWithKeepAChangelog.fsproj index 7e033d0..a63abc6 100644 --- a/tests/fixtures/WorksForRelativePathWithKeepAChangelog.fsproj +++ b/tests/fixtures/WorksForRelativePathWithKeepAChangelog.fsproj @@ -10,8 +10,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/fixtures/WorksForUnreleased.fsproj b/tests/fixtures/WorksForUnreleased.fsproj new file mode 100644 index 0000000..20340e0 --- /dev/null +++ b/tests/fixtures/WorksForUnreleased.fsproj @@ -0,0 +1,20 @@ + + + + + net6.0 + + + + CHANGELOG_unreleased.md + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/tests/fixtures/WorksForUnreleasedWhenIgnored.fsproj b/tests/fixtures/WorksForUnreleasedWhenIgnored.fsproj new file mode 100644 index 0000000..b96c793 --- /dev/null +++ b/tests/fixtures/WorksForUnreleasedWhenIgnored.fsproj @@ -0,0 +1,21 @@ + + + + + net6.0 + + + + CHANGELOG_unreleased.md + false + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/tests/packages.lock.json b/tests/packages.lock.json index 0dcf2b7..441fd8c 100644 --- a/tests/packages.lock.json +++ b/tests/packages.lock.json @@ -111,6 +111,12 @@ "resolved": "12.0.0", "contentHash": "ptxlWtxC8vM6Y6e3h9ZTxBBkOWnWrm/Sa1HT+2i1xcXY3Hx2hmKDZP5RShPf8Xr9D+ivlrXNy57ktzyH8kyt+Q==" }, + "System.Reflection.MetadataLoadContext": { + "type": "Direct", + "requested": "[8.0.1, )", + "resolved": "8.0.1", + "contentHash": "c/hiLzoMeYWnoTsdeRY2o0Vbadfedt0b4ZawQ+qDr1BIoYBQo3ASei0Pyiz00n9pHBlfWXiUVy90tOWBEgJ8/Q==" + }, "Castle.Core": { "type": "Transitive", "resolved": "5.1.1",