@zio.dev/zio-sbt 0.4.0-alpha.8 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.md +145 -13
  2. package/package.json +1 -1
package/index.md CHANGED
@@ -3,7 +3,7 @@ id: index
3
3
  title: "ZIO SBT"
4
4
  ---
5
5
 
6
- _ZIO SBT_ is an sbt plugin for ZIO projects. It provides high-level SBT utilities that simplify the development of ZIO applications.
6
+ _ZIO SBT_ contains multiple sbt plugins that are useful for ZIO projects. It provides high-level SBT utilities that simplify the development of ZIO applications.
7
7
 
8
8
  [![Production Ready](https://img.shields.io/badge/Project%20Stage-Production%20Ready-brightgreen.svg)](https://github.com/zio/zio/wiki/Project-Stages) ![CI Badge](https://github.com/zio/zio-sbt/workflows/CI/badge.svg) [![Sonatype Releases](https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.zio/zio-sbt-website_2.12.svg?label=Sonatype%20Release)](https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-sbt-website_2.12/) [![Sonatype Snapshots](https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.zio/zio-sbt-website_2.12.svg?label=Sonatype%20Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-sbt-website_2.12/) [![javadoc](https://javadoc.io/badge2/dev.zio/zio-sbt-docs_2.12/javadoc.svg)](https://javadoc.io/doc/dev.zio/zio-sbt-docs_2.12) [![ZIO SBT](https://img.shields.io/github/stars/zio/zio-sbt?style=social)](https://github.com/zio/zio-sbt)
9
9
 
@@ -12,15 +12,68 @@ _ZIO SBT_ is an sbt plugin for ZIO projects. It provides high-level SBT utilitie
12
12
  Add the following lines to your `plugin.sbt` file:
13
13
 
14
14
  ```scala
15
- addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.4.0-alpha.8")
15
+ addSbtPlugin("dev.zio" % "zio-sbt-ecosystem" % "0.4.0")
16
+ addSbtPlugin("dev.zio" % "zio-sbt-ci" % "0.4.0")
17
+ addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.4.0")
16
18
  ```
17
19
 
18
- Then you can enable it by using the following code in your `build.sbt` file:
20
+ Then you can enable them by using the following code in your `build.sbt` file:
19
21
 
20
22
  ```scala
21
- enablePlugins(WebsitePlugin)
23
+ enablePlugins(
24
+ ZioSbtWebsitePlugin,
25
+ ZioSbtEcosystemPlugin,
26
+ ZioSbtCiPlugin
27
+ )
22
28
  ```
23
29
 
30
+ ## ZIO SBT Ecosystem
31
+
32
+ ZIO SBT Ecosystem plugin is an sbt plugin that provides a set of sbt settings and tasks that are very common and useful for configuring and managing ZIO projects. It is designed help developers to quickly set up a new ZIO project with a minimal amount of effort.
33
+
34
+ This pluging provides the following settings with default values:
35
+
36
+ - scala212
37
+ - scala213
38
+ - scala3
39
+
40
+ The default values are the latest stable versions of Scala 2.12, 2.13, and Scala 3. All of these settings are of type `String` and can be overridden by the user.
41
+
42
+ By having these settings, then we can use them in other sbt settings. For example, we can use them to define the `crossScalaVersions` setting:
43
+
44
+ ```scala
45
+ crossScalaVersions := Seq(scala212.value, scala213.value, scala3.value)
46
+ ```
47
+
48
+ There are also some other settings that are useful for configuring the projects:
49
+
50
+ - `stdSettings`— a set of standard settings which are common for every ZIO project, which includes configuring:
51
+ - silencer plugin
52
+ - kind projector plugin
53
+ - cross project plugin
54
+ - scalafix plugin
55
+ - java target platform
56
+ - `enableZIO`- a set of ZIO related settings such as enabling zio streams and ZIO test framework.
57
+ - `jsSettings`, `nativeSettings`- common platform specific settings for Scala.js and Scala Native.
58
+
59
+ It also provides some helper methods that are useful for configuring a compiler option for a specific Scala version:
60
+
61
+ - `optionsOn`
62
+ - `optionsOnExcept`
63
+ - `optionsOnOrElse`
64
+ - `addOptionsOn`
65
+ - `addOptionsOnOrElse`
66
+ - `addOptionsOnExcept`
67
+
68
+ And the same for adding a dependency for a specific Scala version:
69
+
70
+ - `dependenciesOn`
71
+ - `dependenciesOnExcept`
72
+ - `dependenciesOnOrElse`
73
+ - `addDependenciesOn`
74
+ - `addDependenciesOnExcept`
75
+ - `addDependenciesOnOrElse`
76
+
24
77
  ## ZIO SBT Website
25
78
 
26
79
  ZIO SBT Website is an SBT plugin that has the following tasks:
@@ -29,7 +82,6 @@ ZIO SBT Website is an SBT plugin that has the following tasks:
29
82
  - `sbt installWebsite`— creates a website for the project inside the `website` directory.
30
83
  - `sbt previewWebsite`— runs a local webserver that serves documentation locally on http://localhost:3000. By changing the documentation inside the `docs` directory, the website will be reloaded with new content.
31
84
  - `sbt publishToNpm`— publishes documentation inside the `docs` directory to the npm registry.
32
- - `sbt generateGithubWorkflow`— generates GitHub workflow which publishes documentation for each library release.
33
85
  - `sbt generateReadme`— generate README.md file from `docs/index.md` and sbt setting keys.
34
86
 
35
87
  ## ZIO SBT CI Plugin
@@ -45,7 +97,7 @@ ZIO SBT CI plugin generates a default GitHub workflow that includes common CI ta
45
97
  To use ZIO SBT CI plugin, add the following lines to your `plugins.sbt` file:
46
98
 
47
99
  ```scala
48
- addSbtPlugin("dev.zio" % "zio-sbt-ci" % "0.4.0-alpha.8")
100
+ addSbtPlugin("dev.zio" % "zio-sbt-ci" % "0.4.0")
49
101
 
50
102
  resolvers ++= Resolver.sonatypeOssRepos("public")
51
103
  ```
@@ -62,25 +114,70 @@ Now you can generate a Github workflow by running the following command:
62
114
  sbt ciGenerateGithubWorkflow
63
115
  ```
64
116
 
65
- The `ciTargetScalaVersions` setting key is used to define a mapping of project names to the Scala versions that should be used for testing phase of continuous integration (CI).
117
+ This will generate a GitHub workflow file inside the `.github/workflows` directory, named `ci.yml`. The workflow file contains following default Jobs:
118
+
119
+ - Build
120
+ - Lint
121
+ - Test
122
+ - Update Readme
66
123
 
67
124
  > **Note:**
68
125
  >
69
126
  > To use this plugin, we also need to install [ZIO Assistant](https://github.com/apps/zio-assistant) bot.
70
127
 
71
- In the example provided, `ciTargetScalaVersions` is defined at the `ThisBuild` level, meaning that the setting will apply to all projects within the build. The setting defines a Map where the key is the name of the current project, obtained by calling the `id` method on the `thisProject` setting, and the value is a sequence of Scala versions obtained from the `crossScalaVersions` of each submodule setting.
128
+ ## Testing Strategies
129
+
130
+ ### Default Testing Strategy
131
+
132
+ The default testing strategy for ZIO SBT CI plugin is to run `sbt +test` on Corretto Java 11, 17 and 21. So this will generate the following job:
133
+
134
+ ```yaml
135
+ test:
136
+ name: Test
137
+ runs-on: ubuntu-latest
138
+ continue-on-error: false
139
+ strategy:
140
+ fail-fast: false
141
+ matrix:
142
+ java: ['11', '17', '21']
143
+ steps:
144
+ - name: Install libuv
145
+ run: sudo apt-get update && sudo apt-get install -y libuv1-dev
146
+ - name: Setup Scala
147
+ uses: actions/setup-java@v3.13.0
148
+ with:
149
+ distribution: corretto
150
+ java-version: ${{ matrix.java }}
151
+ check-latest: true
152
+ - name: Cache Dependencies
153
+ uses: coursier/cache-action@v6
154
+ - name: Git Checkout
155
+ uses: actions/checkout@v4.1.1
156
+ with:
157
+ fetch-depth: '0'
158
+ - name: Test
159
+ run: sbt +test
160
+ ```
161
+
162
+ The `sbt +test` command will run the `test` task for all submodules in the project against all Scala versions defined in the `crossScalaVersions` setting.
163
+
164
+ ### Concurrent Testing Strategy
72
165
 
73
- By default, sbt will run the test task for each project in the build using the default `ThisBuild / crossScalaVersion` (not implemented yet). However, this may not be sufficient for projects that need to be tested against multiple Scala versions, such as libraries or frameworks that support different versions of Scala. In such cases, the `ciTargetScalaVersions` setting can be used to define the Scala versions supported by each submodule.
166
+ In some cases, we may have multiple submodules in our project and we want to test them concurrently using GitHub Actions matrix strategy.
74
167
 
75
- For example, suppose we have a project with the name "submoduleA" and we want to test it against Scala `2.11.12` and `2.12.17`, and for the "submoduleB" we want to test it against Scala `2.12.17` and `2.13.10` and `3.2.2`, We can define the `ciTargetScalaVersions` setting as follows:
168
+ The `ciTargetScalaVersions` setting key is used to define a mapping of project names to the Scala versions that should be used for testing phase of continuous integration (CI).
169
+
170
+ For example, suppose we have a project with the name "submoduleA" and we want to test it against Scala `2.12.20`, and for the "submoduleB" we want to test it against Scala `2.12.20` and `2.13.17` and `3.3.7`, We can define the `ciTargetScalaVersions` setting as follows:
76
171
 
77
172
  ```scala
78
173
  ThisBuild / ciTargetScalaVersions := Map(
79
- "submoduleA" -> Seq("2.11.12", "2.12.17"),
80
- "submoduleB" -> Seq("2.12.17", "2.13.10", "3.2.2")
174
+ "submoduleA" -> Seq("2.12.20"),
175
+ "submoduleB" -> Seq("2.12.20", "2.13.17", "3.3.7")
81
176
  )
82
177
  ```
83
178
 
179
+ In the example provided, `ciTargetScalaVersions` is defined at the `ThisBuild` level, meaning that the setting will apply to all projects within the build. The setting defines a Map where the key is the name of the current project, obtained by calling the `id` method on the `thisProject` setting, and the value is a sequence of Scala versions obtained from the `crossScalaVersions` of each submodule setting.
180
+
84
181
  To simplify this process, we can populate the versions using each submodule's crossScalaVersions setting as follows:
85
182
 
86
183
  ```scala
@@ -94,4 +191,39 @@ The above code can be simplified further by using `targetScalaVersionsFor` helpe
94
191
 
95
192
  ```scala
96
193
  ThisBuild / ciTargetScalaVersions := targetScalaVersionsFor(submoduleA, submoduleB).value
97
- ```
194
+ ```
195
+
196
+ This will generate the following job:
197
+
198
+ ```yaml
199
+ test:
200
+ name: Test
201
+ runs-on: ubuntu-latest
202
+ continue-on-error: false
203
+ strategy:
204
+ fail-fast: false
205
+ matrix:
206
+ java: ['11', '17', '21']
207
+ scala-project:
208
+ - ++2.12.20 submoduleA
209
+ - ++2.12.20 submoduleB
210
+ - ++2.13.17 submoduleB
211
+ - ++3.3.7 submoduleB
212
+ steps:
213
+ - name: Install libuv
214
+ run: sudo apt-get update && sudo apt-get install -y libuv1-dev
215
+ - name: Setup Scala
216
+ uses: actions/setup-java@v3.10.0
217
+ with:
218
+ distribution: corretto
219
+ java-version: ${{ matrix.java }}
220
+ check-latest: true
221
+ - name: Cache Dependencies
222
+ uses: coursier/cache-action@v6
223
+ - name: Git Checkout
224
+ uses: actions/checkout@v4.1.1
225
+ with:
226
+ fetch-depth: '0'
227
+ - name: Test
228
+ run: sbt ${{ matrix.scala-project }}/test
229
+ ```
package/package.json CHANGED
@@ -2,5 +2,5 @@
2
2
  "name": "@zio.dev/zio-sbt",
3
3
  "description": "ZIO SBT Documentation",
4
4
  "license": "Apache-2.0",
5
- "version": "0.4.0-alpha.8"
5
+ "version": "0.4.0"
6
6
  }