Skip to content

Commit

Permalink
How I like to use Danger post
Browse files Browse the repository at this point in the history
  • Loading branch information
David Brunow committed Apr 22, 2024
1 parent ee36d67 commit bf7cf15
Show file tree
Hide file tree
Showing 667 changed files with 702 additions and 685 deletions.
1 change: 1 addition & 0 deletions Sources/BrunowOrg/Documentation.docc/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ In the past I've generated this site with a static site generator called Magneto

### Most Recent Posts

- <doc:04-22-how-i-like-to-use-danger>
- <doc:04-21-ci-tooling>
- <doc:11-30-follow-up-snapshot-testing-xcode-cloud-sonoma>
- <doc:10-21-here-be-dragons-snapshot-testing-edition>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ with a flexible plugin architecture, but I find that limiting that flexibility
makes it more ergonomic.

@Metadata {
@Available("Brunow", introduced: "2024.03.31")
@Available("Brunow", introduced: "2024.04.22")
@PageColor(purple)
@PageImage(
purpose: card,
source: "exampleDangerReport",
alt: "Screenshot of a comment on a GitHub pull request made by a GitHub Action using Danger Swift."
)
}

## Overview

Danger is a tool that connects your CI build systems to your pull requests. This
provides an excellent developer experience where, most of the time, they can
provides an excellent developer experience where (most of the time) they can
know whether a pull request is in a healthy state by looking at a comment
directly on that pull request.

Expand All @@ -29,8 +34,8 @@ of that, there are Danger runners written in Kotlin and Swift which hand off the
bulk of the work to Danger JS but allow for Dangerfiles, the file which define
what Danger should do, written in languages that will be more familiar to
mobile developers. I prefer to use Danger Kotlin when building CI for Android or
other Java-based projects, and Danger Swift when building CI for Apple
platforms because I find it is easier to get folks involved in CI code when it
other Java-based projects and Danger Swift when building CI for Apple
platforms, because I find it is easier to get folks involved in CI code when it
is in a language they use every day. It is also more likely that folks in a
specific community will create plugins for Danger that you could find useful –
folks using Danger Swift will be more likely to create plugins around Xcode and
Expand Down Expand Up @@ -85,16 +90,20 @@ if (!hasChangelog) {
```

This simple example checks to see if the `changelog.md` file has been modified
as part of the pull request, and if not, adds a warning to the pull request
letting the developer know that they need to update the change log.
as part of the pull request and, if not, adds a warning to the pull request
letting the developer know that they need to update the changelog. Providing
that feedback through this automation means that a contributor to a repo can
quickly learn what changes they need to make to meet the standards of that repo.
Plus, the maintainer of the repo can focus on things only humans can do, like
making sure that the pull request follows their architectural guidelines.

At the beginning of every Dangerfile, the Danger library must be imported. Let's
talk about how that works next.

### The Danger Swift Library

The Danger Swift library is what powers the different things you can do in a
Dangerfile. The library is built of the core Danger functionality plus any
Dangerfile. The library is built with the core Danger functionality plus any
plugins that you've chosen to integrate. The documentation recommends
integrating Danger into your workflow by
[adding Danger Swift and any related plugins to your `Package.swift` file](https://danger.systems/swift/guides/about_the_dangerfile#swift-package-manager-more-performant).
Expand Down Expand Up @@ -148,8 +157,11 @@ and run the runner and library:
* I don't like to mix tooling and my app's dependencies
* I don't always want to use SPM
* I don't want to re-build Danger on every run
* The recommended approach is invasive to my project, requiring me to add a folder that will not be used
* Due to the invasive nature of the recommended approach, applying the same Danger configurations across multiple repos, and keeping those configurations in sync, creates a lot of manual overhead
* The recommended approach is invasive to my project, requiring me to add a
folder that will not be used
* Due to the invasive nature of the recommended approach, applying the same
Danger configurations across multiple repos, and keeping those configurations in
sync, it creates a lot of manual overhead
* I like pre-built binaries

What I want is a pre-built executable for the Danger Swift runner, and a
Expand All @@ -173,7 +185,7 @@ swift build -c release --arch arm64 --arch x86_64

Swift builds the `danger-swift` binary and puts it in the
".build/apple/Products/Release/danger-swift" folder so we'll need to copy it
from there to where we need it. All that is simple and straightforward.
from there to where we need it. All of that is simple and straightforward.

#### The Library

Expand All @@ -187,15 +199,15 @@ redistribute the library.
##### Integrating Plugins

Fortunately, Danger Swift has already gone through the process of integrating a
common plugin into the library, SwiftLint, so we can follow the maintainer's
common plugin, SwiftLint, into the library so we can follow the maintainer's
lead and do the same thing for our plugins. There is already a "Plugins" folder
in the "Sources/Danger" folder and adding our plugin there is quite simple – we
just copy the source code folder into the "Plugins" folder and then get the
Danger library to compile again. Doing that requires fixing any naming conflicts
and, while we're in there, we'll fix warnings around importing Danger by
removing any `import Danger` code. Let's walk through an example with a popular
plugin, [DangerSwiftCoverage](https://github.com/f-meloni/danger-swift-coverage),
which gathers code coverage and so it can be posted on pull requests.
copy the source code folder into the "Plugins" folder and then make whatever
changes are need to make the Danger library successfully compile again. Doing
that requires fixing any naming conflicts and, while we're in there, we'll fix
warnings around importing Danger by removing any `import Danger` code. Let's
walk through an example with a popular plugin, [DangerSwiftCoverage](https://github.com/f-meloni/danger-swift-coverage),
which gathers code coverage so it can be posted on pull requests.

1. Fork Danger Swift and clone the fork to your machine
1. Clone DangerSwiftCoverage to your machine
Expand Down Expand Up @@ -254,8 +266,9 @@ because [library evolution](https://www.swift.org/blog/library-evolution/) is
not turned on. This means that when you change the default version of Xcode on a
machine, and therefore change the default version of Swift, you'll need to
rebuild the Danger Swift library. I've worked around this in the past by keeping
an older version of Xcode on the build machines, but it is easy to forget why
you're doing that and inadvertently break things.
an older version of Xcode on the build machines that is only used to run Danger
Swift, but it is easy to forget why you're doing that and inadvertently break
things.

> Note: It might be possible to use library evolution with this libDanger.dylib
and the object files, but I was not able to make it work.
Expand All @@ -282,13 +295,13 @@ I've added a
### Using this Setup

Now that we have an executable binary and a framework, how do we use them in our
CI jobs? Each of them is portable, but we don't really have a good place to
store them. I like to store all of my CI tooling in a centralized place but I'll
go into more detail about that some other time.
CI jobs? Each of them is portable, so we can put them where we need them. I like
to store all of my CI tooling in a centralized place, which I've talked about in
my [previous blog post on CI tooling](<doc:04-21-ci-tooling>).

For now, I'll just say that the `danger-swift` executable and the
Danger.framework library need to be in the same directory when you run
`danger-swift`.
If you don't want to, or can't, use that centralized place, then you need to
make sure that the `danger-swift` executable and the Danger.framework library
are in the same directory when you run `danger-swift`.

Once you have them there, you'll want to do something like this in your CI job:

Expand Down
1 change: 1 addition & 0 deletions Sources/BrunowOrg/Documentation.docc/Posts/2024/2024.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@

## Topics

- <doc:04-22-how-i-like-to-use-danger>
- <doc:04-21-ci-tooling>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/data/documentation/brunow.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/data/documentation/brunow/01-01-celebrations.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"variants":[{"traits":[{"interfaceLanguage":"swift"}],"paths":["\/documentation\/brunow\/01-01-celebrations"]}],"kind":"article","sections":[],"topicSectionsStyle":"detailedGrid","hierarchy":{"paths":[["doc:\/\/Brunow\/documentation\/Brunow","doc:\/\/Brunow\/documentation\/Brunow\/Archive","doc:\/\/Brunow\/documentation\/Brunow\/2016"]]},"abstract":[{"type":"text","text":"Rarity makes things special."}],"metadata":{"modules":[{"name":"Brunow"}],"title":"Celebrations","color":{"standardColorIdentifier":"purple"},"platforms":[{"name":"Brunow","introducedAt":"2016.01.01"}]},"primaryContentSections":[{"kind":"content","content":[{"type":"paragraph","inlineContent":[{"type":"text","text":"Every day cannot be a celebration without losing the meaning behind it. Yet I find myself consistently trying to make my days more than they are. Maybe to fend off boredom, but probably due to overstimulation. When I’m surrounded by novelty and news I tend to try to make my days more exciting than they naturally are."}]},{"inlineContent":[{"text":"We need those slow days, just like we need our celebrations. Figuring out the right balance is the hard part.","type":"text"}],"type":"paragraph"}]}],"schemaVersion":{"minor":3,"patch":0,"major":0},"identifier":{"interfaceLanguage":"swift","url":"doc:\/\/Brunow\/documentation\/Brunow\/01-01-celebrations"},"references":{"doc://Brunow/documentation/Brunow/Archive":{"kind":"article","role":"collectionGroup","abstract":[{"text":"All posts","type":"text"}],"url":"\/documentation\/brunow\/archive","type":"topic","title":"Archive","identifier":"doc:\/\/Brunow\/documentation\/Brunow\/Archive"},"doc://Brunow/documentation/Brunow/2016":{"identifier":"doc:\/\/Brunow\/documentation\/Brunow\/2016","kind":"article","url":"\/documentation\/brunow\/2016","abstract":[],"role":"collectionGroup","title":"2016","type":"topic"},"doc://Brunow/documentation/Brunow":{"url":"\/documentation\/brunow","title":"Brunow","kind":"symbol","type":"topic","role":"collection","identifier":"doc:\/\/Brunow\/documentation\/Brunow","abstract":[{"type":"text","text":"David Brunow, known as Brunow [ˈbɹunoʊ] to the folks he works with, is a human living on Earth. You might have something in common with him — if you think it is ridiculous that he is talking about himself in the first person here, so does he."}]}}}
{"variants":[{"paths":["\/documentation\/brunow\/01-01-celebrations"],"traits":[{"interfaceLanguage":"swift"}]}],"abstract":[{"text":"Rarity makes things special.","type":"text"}],"hierarchy":{"paths":[["doc:\/\/Brunow\/documentation\/Brunow","doc:\/\/Brunow\/documentation\/Brunow\/Archive","doc:\/\/Brunow\/documentation\/Brunow\/2016"]]},"identifier":{"url":"doc:\/\/Brunow\/documentation\/Brunow\/01-01-celebrations","interfaceLanguage":"swift"},"schemaVersion":{"major":0,"minor":3,"patch":0},"primaryContentSections":[{"content":[{"type":"paragraph","inlineContent":[{"text":"Every day cannot be a celebration without losing the meaning behind it. Yet I find myself consistently trying to make my days more than they are. Maybe to fend off boredom, but probably due to overstimulation. When I’m surrounded by novelty and news I tend to try to make my days more exciting than they naturally are.","type":"text"}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"We need those slow days, just like we need our celebrations. Figuring out the right balance is the hard part."}]}],"kind":"content"}],"metadata":{"color":{"standardColorIdentifier":"purple"},"platforms":[{"name":"Brunow","introducedAt":"2016.01.01"}],"title":"Celebrations","modules":[{"name":"Brunow"}]},"sections":[],"kind":"article","topicSectionsStyle":"detailedGrid","references":{"doc://Brunow/documentation/Brunow/Archive":{"kind":"article","identifier":"doc:\/\/Brunow\/documentation\/Brunow\/Archive","title":"Archive","url":"\/documentation\/brunow\/archive","abstract":[{"type":"text","text":"All posts"}],"type":"topic","role":"collectionGroup"},"doc://Brunow/documentation/Brunow/2016":{"type":"topic","title":"2016","url":"\/documentation\/brunow\/2016","role":"collectionGroup","kind":"article","identifier":"doc:\/\/Brunow\/documentation\/Brunow\/2016","abstract":[]},"doc://Brunow/documentation/Brunow":{"identifier":"doc:\/\/Brunow\/documentation\/Brunow","kind":"symbol","abstract":[{"text":"David Brunow, known as Brunow [ˈbɹunoʊ] to the folks he works with, is a human living on Earth. You might have something in common with him — if you think it is ridiculous that he is talking about himself in the first person here, so does he.","type":"text"}],"type":"topic","url":"\/documentation\/brunow","role":"collection","title":"Brunow"}}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"sections":[],"schemaVersion":{"major":0,"minor":3,"patch":0},"metadata":{"title":"Speaking Up For The Voiceless","modules":[{"name":"Brunow"}],"platforms":[{"introducedAt":"2016.01.01","name":"Brunow"}],"color":{"standardColorIdentifier":"purple"}},"kind":"article","identifier":{"interfaceLanguage":"swift","url":"doc:\/\/Brunow\/documentation\/Brunow\/01-01-speaking-up-for-the-voiceless"},"hierarchy":{"paths":[["doc:\/\/Brunow\/documentation\/Brunow","doc:\/\/Brunow\/documentation\/Brunow\/Archive","doc:\/\/Brunow\/documentation\/Brunow\/2016"]]},"abstract":[{"text":"When simply speaking is brave.","type":"text"}],"variants":[{"paths":["\/documentation\/brunow\/01-01-speaking-up-for-the-voiceless"],"traits":[{"interfaceLanguage":"swift"}]}],"topicSectionsStyle":"detailedGrid","primaryContentSections":[{"kind":"content","content":[{"inlineContent":[{"type":"text","text":"How would you react if you heard someone talking negatively about your friend when she wasn’t around? Would you ignore it and not respond? Or would you stick up for your friend and call them out? Ignoring it would be more polite and you wouldn’t cause a scene — no one wants to cause a scene."}],"type":"paragraph"},{"type":"paragraph","inlineContent":[{"text":"I know what I’d do — I’d defend my friend and, if necessary, cause a scene. She isn’t there and can’t stick up for herself.","type":"text"}]},{"inlineContent":[{"type":"text","text":"What if the person wasn’t a friend? Would you act any differently? What if you heard a gay man being made fun of by strangers just out of his earshot? Would you stick up for him?"}],"type":"paragraph"},{"type":"paragraph","inlineContent":[{"text":"I’d like to think that I would. I’d like to think that I’d put aside social convention and go out of my way to speak up for people that don’t have a voice — whether they can’t be heard or aren’t present to respond.","type":"text"}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"We are all one. We are all friends and we are all family. We’ve got to stick up for each other."}]}]}],"references":{"doc://Brunow/documentation/Brunow":{"url":"\/documentation\/brunow","title":"Brunow","kind":"symbol","type":"topic","role":"collection","identifier":"doc:\/\/Brunow\/documentation\/Brunow","abstract":[{"type":"text","text":"David Brunow, known as Brunow [ˈbɹunoʊ] to the folks he works with, is a human living on Earth. You might have something in common with him — if you think it is ridiculous that he is talking about himself in the first person here, so does he."}]},"doc://Brunow/documentation/Brunow/Archive":{"kind":"article","role":"collectionGroup","abstract":[{"text":"All posts","type":"text"}],"url":"\/documentation\/brunow\/archive","type":"topic","title":"Archive","identifier":"doc:\/\/Brunow\/documentation\/Brunow\/Archive"},"doc://Brunow/documentation/Brunow/2016":{"identifier":"doc:\/\/Brunow\/documentation\/Brunow\/2016","kind":"article","url":"\/documentation\/brunow\/2016","abstract":[],"role":"collectionGroup","title":"2016","type":"topic"}}}
{"sections":[],"variants":[{"paths":["\/documentation\/brunow\/01-01-speaking-up-for-the-voiceless"],"traits":[{"interfaceLanguage":"swift"}]}],"abstract":[{"type":"text","text":"When simply speaking is brave."}],"kind":"article","schemaVersion":{"minor":3,"patch":0,"major":0},"topicSectionsStyle":"detailedGrid","metadata":{"title":"Speaking Up For The Voiceless","color":{"standardColorIdentifier":"purple"},"platforms":[{"name":"Brunow","introducedAt":"2016.01.01"}],"modules":[{"name":"Brunow"}]},"identifier":{"url":"doc:\/\/Brunow\/documentation\/Brunow\/01-01-speaking-up-for-the-voiceless","interfaceLanguage":"swift"},"primaryContentSections":[{"kind":"content","content":[{"inlineContent":[{"type":"text","text":"How would you react if you heard someone talking negatively about your friend when she wasn’t around? Would you ignore it and not respond? Or would you stick up for your friend and call them out? Ignoring it would be more polite and you wouldn’t cause a scene — no one wants to cause a scene."}],"type":"paragraph"},{"type":"paragraph","inlineContent":[{"type":"text","text":"I know what I’d do — I’d defend my friend and, if necessary, cause a scene. She isn’t there and can’t stick up for herself."}]},{"type":"paragraph","inlineContent":[{"text":"What if the person wasn’t a friend? Would you act any differently? What if you heard a gay man being made fun of by strangers just out of his earshot? Would you stick up for him?","type":"text"}]},{"inlineContent":[{"text":"I’d like to think that I would. I’d like to think that I’d put aside social convention and go out of my way to speak up for people that don’t have a voice — whether they can’t be heard or aren’t present to respond.","type":"text"}],"type":"paragraph"},{"inlineContent":[{"type":"text","text":"We are all one. We are all friends and we are all family. We’ve got to stick up for each other."}],"type":"paragraph"}]}],"hierarchy":{"paths":[["doc:\/\/Brunow\/documentation\/Brunow","doc:\/\/Brunow\/documentation\/Brunow\/Archive","doc:\/\/Brunow\/documentation\/Brunow\/2016"]]},"references":{"doc://Brunow/documentation/Brunow/Archive":{"kind":"article","identifier":"doc:\/\/Brunow\/documentation\/Brunow\/Archive","title":"Archive","url":"\/documentation\/brunow\/archive","abstract":[{"type":"text","text":"All posts"}],"type":"topic","role":"collectionGroup"},"doc://Brunow/documentation/Brunow/2016":{"type":"topic","title":"2016","url":"\/documentation\/brunow\/2016","role":"collectionGroup","kind":"article","identifier":"doc:\/\/Brunow\/documentation\/Brunow\/2016","abstract":[]},"doc://Brunow/documentation/Brunow":{"identifier":"doc:\/\/Brunow\/documentation\/Brunow","kind":"symbol","abstract":[{"text":"David Brunow, known as Brunow [ˈbɹunoʊ] to the folks he works with, is a human living on Earth. You might have something in common with him — if you think it is ridiculous that he is talking about himself in the first person here, so does he.","type":"text"}],"type":"topic","url":"\/documentation\/brunow","role":"collection","title":"Brunow"}}}
Loading

0 comments on commit bf7cf15

Please sign in to comment.