Skip to content

Commit 3db8a7e

Browse files
authored
Add blog post about Scala Steward (#1057)
Add blog post about Scala Steward
2 parents 81aed0b + 0c4d074 commit 3db8a7e

File tree

1 file changed

+169
-0
lines changed

1 file changed

+169
-0
lines changed
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
---
2+
layout: blog-detail
3+
post-type: blog
4+
by: Frank S. Thomas
5+
title: "Keep your projects up-to-date with Scala Steward"
6+
---
7+
8+
I'm excited to announce version 0.3 of [Scala Steward][scala-steward] and to introduce it
9+
to the Scala community! Scala Steward is a robot that helps you keep dependencies,
10+
sbt, and sbt plugins up-to-date by automatically creating pull requests on GitHub, GitLab,
11+
or Bitbucket that bump outdated version numbers.
12+
13+
## How to use it
14+
15+
You can use it with any public Scala project on GitHub that uses sbt simply by adding it
16+
to [this file][repos] and then wait for the first pull requests to come in a few hours
17+
later. Over 500 projects are already using this public instance of Scala Steward which
18+
I'm running as a free service for the whole Scala OSS ecosystem. Since Sep 9, 2018,
19+
when Scala Steward created [its first pull request][first_pr], it has created more than
20+
[11 900 pull requests][created_prs] of which over [8 300][merged_prs] are already merged!
21+
22+
Here is a screenshot of one of Scala Steward's pull requests:
23+
![screenshot of a Scala Steward pull request](https://user-images.githubusercontent.com/141252/60855361-e48b4200-a1f2-11e9-8173-1a53eacffd92.png)
24+
25+
Receiving automatic pull requests that bump versions of dependencies reduces maintenance
26+
if your code compiles without warnings and errors with the new version. In many cases, it
27+
is enough to review the changelog of the new version and to check that your automated
28+
tests pass before merging such pull requests. If you are adventurous, you can even let
29+
[Scala Steward's pull requests be merged automatically][auto-merge].
30+
31+
[scala-steward]: https://scala-steward.org
32+
[repos]: https://github.com/fthomas/scala-steward/blob/master/repos.md
33+
[first_pr]: https://github.com/fthomas/datapackage/pull/1
34+
[created_prs]: https://github.com/search?o=desc&q=author%3Ascala-steward+is%3Apr&s=created&type=Issues
35+
[merged_prs]: https://github.com/search?o=desc&q=author%3Ascala-steward+is%3Amerged+sort%3Aupdated-desc&s=created&type=Issues
36+
[auto-merge]: https://github.com/fthomas/scala-steward/blob/master/docs/faq.md#how-can-scala-stewards-prs-be-merged-automatically
37+
38+
## Running your own instance
39+
40+
You can also run your own instance of Scala Steward for your private repositories and
41+
join the [companies][community] that are already doing this. Unfortunately this isn’t
42+
[well documented][docs-running] yet. Improving the documentation would make a great
43+
first contribution after you have figured out how to set it up.
44+
45+
[community]: https://github.com/fthomas/scala-steward#community
46+
[docs-running]: https://github.com/fthomas/scala-steward/blob/master/docs/running.md
47+
48+
## Automatic code migrations with Scalafix
49+
50+
What if a new version of your dependencies contains breaking changes so that your
51+
code does not compile without errors or warnings anymore? In these cases automatic
52+
version bumps only notify you of a new version and make you aware that human
53+
intervention is needed to fix errors and warnings and to adapt the code to the new
54+
version.
55+
56+
Fortunately, we can improve on this situation by combining Scala Steward with the
57+
excellent [Scalafix][scalafix] tool. Scalafix is a refactoring and linting tool that
58+
allows to rewrite code based on user-supplied rules. You can read more about Scalafix
59+
[here][scalafix-blog1] and [here][scalafix-blog2]. Scalafix rules can also be used
60+
for version migrations to help users updating to new versions and some
61+
libraries (like [Cats](https://github.com/typelevel/cats/tree/v1.6.1/scalafix),
62+
[FS2](https://github.com/functional-streams-for-scala/fs2/tree/v1.0.5/scalafix), or
63+
[http4s](https://github.com/http4s/http4s/tree/v0.20.3/scalafix)) are already
64+
providing such migrations. With Scala Steward, we now have the possibility to apply
65+
Scalafix migrations automatically to create
66+
[pull requests like this][scalafix-example-pr]:
67+
68+
```diff
69+
diff --git a/build.sbt b/build.sbt
70+
--- a/build.sbt
71+
+++ b/build.sbt
72+
libraryDependencies := List(
73+
- "org.typelevel" %% "cats-core" % "0.9.0"
74+
+ "org.typelevel" %% "cats-core" % "1.6.1"
75+
)
76+
77+
diff --git a/src/main/scala/cats_1_0_0.scala b/src/main/scala/cats.scala
78+
--- a/src/main/scala/cats.scala
79+
+++ b/src/main/scala/cats.scala
80+
object cats {
81+
- (Option(1) |@| Option(2) |@| Option(3)).map(_ + _ + _)
82+
+ (Option(1), Option(2), Option(3)).mapN(_ + _ + _)
83+
}
84+
```
85+
86+
Besides bumping the Cats version number, the Scalafix migration took care of the
87+
breaking changes that were introduced between Cats 0.9.0 and Cats 1.0.0 and updated
88+
the code so that it compiles cleanly with the new version. These automatic
89+
migrations have the potential to significantly reduce maintenance costs of version
90+
updates that contain breaking changes or deprecations.
91+
92+
[scalafix]: https://scalacenter.github.io/scalafix/
93+
[scalafix-blog1]: https://www.scala-lang.org/blog/2016/10/24/scalafix.html
94+
[scalafix-blog2]: https://www.scala-lang.org/blog/2018/11/16/scalafix-scalameta.html
95+
[scalafix-example-pr]: https://github.com/fthomas/scalafix-test/pull/9/files
96+
97+
## Get involved
98+
99+
Scalafix migrations are great but we haven't yet solved the problem of writing them
100+
automatically for version updates. **:-)** That means there are plenty of opportunities
101+
for new contributors to help library maintainers writing Scalafix migrations. And by
102+
integrating them into Scala Steward, their value is amplified by the number of
103+
projects that use Scala Steward. Even small contributions can already benefit a
104+
large chunk of the Scala ecosystem.
105+
106+
After you have written a Scalafix migration for your favorite library,
107+
Scala Steward needs to be made aware that it exists and for which version update it
108+
should be applied. Instructions for adding them to Scala Steward and more details about
109+
the Scalafix integration in Scala Steward can be found [here][scalafix-migrations].
110+
Once the migration has been added and the new version of the library is released, you
111+
can enjoy watching Scala Steward creating pull requests with changes from your Scalafix
112+
migration!
113+
114+
There are also enough opportunities to [improve Scala Steward itself][scala-steward-issues].
115+
The Scalafix integration, for example, has only been added recently and is still rough around
116+
the edges.
117+
118+
[scalafix-migrations]: https://github.com/fthomas/scala-steward/blob/master/docs/scalafix-migrations.md
119+
[scala-steward-issues]: https://github.com/fthomas/scala-steward/issues
120+
[scala-steward-contributors]: https://github.com/fthomas/scala-steward#contributors
121+
122+
## Recap
123+
124+
Scala Steward:
125+
126+
* Can create automatic pull requests that bump dependency versions. This saves a lot of time.
127+
* In addition to the version bumps, it can migrate the code with Scalafix.
128+
* You can help the whole Scala ecosystem by writing Scalafix migrations.
129+
130+
[Try out Scala Steward][quickstart] now!
131+
132+
[quickstart]: https://github.com/fthomas/scala-steward#quick-start-guide
133+
134+
## Credits
135+
136+
Scala Steward wouldn't exist without Roman Timushev's great [sbt-updates][sbt-updates]
137+
which is an integral part of Scala Steward. A special shout-out also goes to
138+
[@impurepics][@impurepics] who created the cute and iconic logo!
139+
140+
And many thanks to the 20+ contributors who made Scala Steward to what it is today:
141+
Alex,
142+
Arulselvan Madhavan,
143+
Bayram Kiran,
144+
Cédric Chantepie,
145+
Christopher Davenport,
146+
Dale Wijnand,
147+
Daniel Pfeiffer,
148+
David Francoeur,
149+
Fabian,
150+
Filipe Regadas,
151+
Jakub Kozłowski,
152+
JCollier,
153+
Jeff Martin,
154+
kenji yoshida,
155+
Mark Canlas,
156+
Michael Wizner,
157+
Philippus Baalman,
158+
Piotr Gabara,
159+
Renato Cavalcanti,
160+
sullis,
161+
TATSUNO Yasuhiro,
162+
Thomas Heslin, and
163+
Thomas Kaliakos.
164+
165+
I'd also like to thank Andrea Magnorsky, David Francoeur, Lars Hupel,
166+
Seth Tisue, and Yifan Xing for proofreading this post.
167+
168+
[sbt-updates]: https://github.com/rtimush/sbt-updates
169+
[@impurepics]: https://twitter.com/impurepics/

0 commit comments

Comments
 (0)