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

Fixes #192 #193

Merged
merged 1 commit into from
Feb 24, 2020
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
13 changes: 12 additions & 1 deletion Content/Console/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ let isEmptyChange = function
| Changelog.Change.Custom (_, s) ->
String.IsNullOrWhiteSpace s.CleanedText

let isChangelogEmpty () =
let isEmpty =
(latestEntry.Changes |> Seq.forall isEmptyChange)
|| latestEntry.Changes |> Seq.isEmpty
if isEmpty then failwith "No changes in CHANGELOG. Please add your changes under a heading specified in https://keepachangelog.com/"

let allReleaseChecks () =
isReleaseBranchCheck ()
isChangelogEmpty ()

let mkLinkReference (newVersion : SemVerInfo) (changelog : Changelog.Changelog) =
if changelog.Entries |> List.isEmpty then
// No actual changelog entries yet: link reference will just point to the Git tag
Expand Down Expand Up @@ -465,7 +475,7 @@ let createPackages _ =
)

let gitRelease _ =
isReleaseBranchCheck ()
allReleaseChecks ()

let releaseNotesGitCommitFormat = latestEntry.ToString()

Expand All @@ -481,6 +491,7 @@ let gitRelease _ =
Target.deactivateBuildFailure "RevertChangelog"

let githubRelease _ =
allReleaseChecks ()
let token =
match Environment.environVarOrDefault "GITHUB_TOKEN" "" with
| s when not (String.IsNullOrWhiteSpace s) -> s
Expand Down
18 changes: 15 additions & 3 deletions Content/Library/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ let isEmptyChange = function
| Changelog.Change.Custom (_, s) ->
String.IsNullOrWhiteSpace s.CleanedText

let isChangelogEmpty () =
let isEmpty =
(latestEntry.Changes |> Seq.forall isEmptyChange)
|| latestEntry.Changes |> Seq.isEmpty
if isEmpty then failwith "No changes in CHANGELOG. Please add your changes under a heading specified in https://keepachangelog.com/"

let allReleaseChecks () =
isReleaseBranchCheck ()
isChangelogEmpty ()


let mkLinkReference (newVersion : SemVerInfo) (changelog : Changelog.Changelog) =
if changelog.Entries |> List.isEmpty then
// No actual changelog entries yet: link reference will just point to the Git tag
Expand Down Expand Up @@ -498,7 +509,7 @@ let sourceLinkTest _ =
)

let publishToNuget _ =
isReleaseBranchCheck ()
allReleaseChecks ()
Paket.push(fun c ->
{ c with
ToolType = ToolType.CreateLocalTool()
Expand All @@ -510,7 +521,7 @@ let publishToNuget _ =
Target.deactivateBuildFailure "RevertChangelog"

let gitRelease _ =
isReleaseBranchCheck ()
allReleaseChecks ()

let releaseNotesGitCommitFormat = latestEntry.ToString()

Expand All @@ -524,6 +535,7 @@ let gitRelease _ =
Git.Branches.pushTag "" "origin" tag

let githubRelease _ =
allReleaseChecks ()
let token =
match Environment.environVarOrDefault "GITHUB_TOKEN" "" with
| s when not (String.IsNullOrWhiteSpace s) -> s
Expand Down Expand Up @@ -577,7 +589,7 @@ let watchDocs _ =
DocsTool.watch ()

let releaseDocs ctx =
isReleaseBranchCheck ()
isReleaseBranchCheck () // Docs changes don't need a full release to the library

Git.Staging.stageAll docsDir
Git.Commit.exec "" (sprintf "Documentation release of version %s" latestEntry.NuGetVersion)
Expand Down
17 changes: 15 additions & 2 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ let isEmptyChange = function
| Changelog.Change.Custom (_, s) ->
String.IsNullOrWhiteSpace s.CleanedText

let isChangelogEmpty () =
let isEmpty =
(latestEntry.Changes |> Seq.forall isEmptyChange)
|| latestEntry.Changes |> Seq.isEmpty
if isEmpty then failwith "No changes in CHANGELOG. Please add your changes under a heading specified in https://keepachangelog.com/"

let allReleaseChecks () =
isReleaseBranchCheck ()
isChangelogEmpty ()

let mkLinkReference (newVersion : SemVerInfo) (changelog : Changelog.Changelog) =
if changelog.Entries |> List.isEmpty then
// No actual changelog entries yet: link reference will just point to the Git tag
Expand Down Expand Up @@ -355,6 +365,7 @@ let ``integration tests`` ctx =
}) proj)

let publish _ =
allReleaseChecks ()
Paket.push(fun c ->
{ c with
ToolType = ToolType.CreateLocalTool()
Expand All @@ -364,7 +375,7 @@ let publish _ =
)

let ``git release`` _ =
isReleaseBranchCheck ()
allReleaseChecks ()

let releaseNotesGitCommitFormat = latestEntry.ToString()

Expand All @@ -379,6 +390,8 @@ let ``git release`` _ =


let ``github release`` _ =
allReleaseChecks ()

let token =
match Environment.environVarOrDefault "GITHUB_TOKEN" "" with
| s when not (String.IsNullOrWhiteSpace s) -> s
Expand All @@ -402,7 +415,7 @@ let ``watch docs`` _ =
DocsTool.watch ()

let ``release docs`` ctx =
isReleaseBranchCheck ()
isReleaseBranchCheck () // Docs changes don't need a full release to the library

Git.Staging.stageAll docsDir
Git.Commit.exec "" (sprintf "Documentation release of version %s" latestEntry.NuGetVersion)
Expand Down
34 changes: 33 additions & 1 deletion tests/MiniScaffold.Tests/Asserts.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ open System.IO
open Expecto
open Infrastructure

module Array =
let insert v i (l : 'a array) =
let newArray = Array.zeroCreate (l.Length + 1)
let mutable newPointer = 0
l
|> Array.iteri(fun j y ->
if i = j then
newArray.[newPointer] <- v
newPointer <- newPointer + 1
newArray.[newPointer] <- y
newPointer <- newPointer + 1
else
newArray.[newPointer] <- y
newPointer <- newPointer + 1
)
newArray



module Assert =
open System

Expand Down Expand Up @@ -128,7 +147,7 @@ module Effect =
match lines |> Array.tryFindIndex (fun line -> line.Contains "let gitRelease") with
| None -> ()
| Some startIdx ->
let mutable i = startIdx+1
let mutable i = startIdx + 1
let mutable keepGoing = true
while keepGoing && i < Array.length lines do
if lines.[i].StartsWith("let githubRelease") then
Expand Down Expand Up @@ -160,6 +179,18 @@ module Effect =
let ``set environment variable`` name value (d : DirectoryInfo) =
Environment.SetEnvironmentVariable(name, value)

let ``add change to CHANGELOG`` (d : DirectoryInfo) =
let changelog = Path.combine d.FullName "CHANGELOG.md"
let lines = File.ReadAllLines changelog
match lines |> Array.tryFindIndex (fun line -> line.Contains "## [Unreleased]") with
| None -> ()
| Some startIdx ->
let newLines =
lines
|> Array.insert "### Changed" (startIdx + 1)
|> Array.insert "- This is a test change from (@TheAngryByrd)" (startIdx + 2)
newLines |> File.writeNew changelog

let ``setup for release tests`` (d : DirectoryInfo) =
``git init`` d
``git commit all`` "Initial commit" d
Expand All @@ -169,3 +200,4 @@ module Effect =
// We don't want to actually release anything during integration tests!
``set environment variable`` "NUGET_KEY" "" d
``set environment variable`` "GITHUB_TOKEN" "" d
``add change to CHANGELOG`` d