Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into use_munit_cats_effect
Browse files Browse the repository at this point in the history
  • Loading branch information
jatcwang committed Jan 29, 2025
2 parents a8184b6 + e0a3105 commit 66dcd07
Show file tree
Hide file tree
Showing 54 changed files with 1,552 additions and 1,228 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ concurrency:

jobs:
build:
name: Build and Test
name: Test
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-22.04]
scala: [2.12, 2.13, 3]
java: [temurin@11]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- name: Install sbt
uses: sbt/setup-sbt@v1

- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
Expand All @@ -64,25 +64,25 @@ jobs:
run: sbt githubWorkflowCheck

- name: Check formatting
if: matrix.java == 'temurin@11' && matrix.os == 'ubuntu-latest'
if: matrix.java == 'temurin@11' && matrix.os == 'ubuntu-22.04'
run: sbt '++ ${{ matrix.scala }}' scalafmtCheckAll 'project /' scalafmtSbtCheck

- name: Test
run: sbt '++ ${{ matrix.scala }}' freeGen2 test

- name: Check binary compatibility
if: matrix.java == 'temurin@11' && matrix.os == 'ubuntu-latest'
if: matrix.java == 'temurin@11' && matrix.os == 'ubuntu-22.04'
run: sbt '++ ${{ matrix.scala }}' mimaReportBinaryIssues

- name: Generate API documentation
if: matrix.java == 'temurin@11' && matrix.os == 'ubuntu-latest'
if: matrix.java == 'temurin@11' && matrix.os == 'ubuntu-22.04'
run: sbt '++ ${{ matrix.scala }}' doc

- name: Check there are no uncommitted changes in git (to catch generated files that weren't committed)
run: sbt '++ ${{ matrix.scala }}' checkGitNoUncommittedChanges

- name: Check Doc Site (2.13.14 only)
if: matrix.scala == '2.13.14'
- name: Check Doc Site (2.13 only)
if: matrix.scala == '2.13'
run: sbt '++ ${{ matrix.scala }}' docs/makeSite

- name: Make target directories
Expand All @@ -106,18 +106,18 @@ jobs:
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-22.04]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
- name: Install sbt
uses: sbt/setup-sbt@v1

- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
Expand Down Expand Up @@ -190,18 +190,18 @@ jobs:
if: github.event.repository.fork == false && github.event_name != 'pull_request'
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-22.04]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
- name: Install sbt
uses: sbt/setup-sbt@v1

- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
Expand Down
12 changes: 6 additions & 6 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ pull_request_rules:
conditions:
- author=scala-steward
- body~=labels:.*early-semver-patch
- status-success=Build and Test (ubuntu-latest, 2.12, temurin@11)
- status-success=Build and Test (ubuntu-latest, 2.13, temurin@11)
- status-success=Build and Test (ubuntu-latest, 3, temurin@11)
- status-success=Test (ubuntu-22.04, 2.12, temurin@11)
- status-success=Test (ubuntu-22.04, 2.13, temurin@11)
- status-success=Test (ubuntu-22.04, 3, temurin@11)
actions:
merge: {}
- name: Label bench PRs
Expand Down Expand Up @@ -161,9 +161,9 @@ pull_request_rules:
remove: []
- name: merge-when-ci-pass
conditions:
- status-success=Build and Test (ubuntu-latest, 2.12, temurin@11)
- status-success=Build and Test (ubuntu-latest, 2.13, temurin@11)
- status-success=Build and Test (ubuntu-latest, 3, temurin@11)
- status-success=Test (ubuntu-22.04, 2.12, temurin@11)
- status-success=Test (ubuntu-22.04, 2.13, temurin@11)
- status-success=Test (ubuntu-22.04, 3, temurin@11)
- label=merge-on-build-success
actions:
merge: {}
20 changes: 12 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,27 @@ Running the tests or building the documentation site requires connection to the
which you can spin up using docker-compose:

```
docker-compose up -d --force-update
docker compose up -d --force-recreate
```

After that, in SBT you can run `test` to run tests, and `makeSite` to build the doc site
Note: If you're using Apple Silicone Macbooks (M1, M2, etc), you need to enable "Use Rosetta for x86_64/amd64 emulation on Apple Silicon" since there is no ARM64 image for postgis yet.

If you're editing code generation related code, you should reload the SBT project and then run the `freeGen2` SBT task
before compiling or running tests.
With the containers started, SBT you can run `test` to run tests, and `makeSite` to build the doc site.

## Fixing warnings

To improve code quality and bug, we enable many stricter scala compiler flags via the
[sbt-tpolecat](https://github.com/typelevel/sbt-tpolecat) plugin and in CI all warnings will be treated as errors.

For a more pleasant development experience, we default to `tpolecatDevMode` so warnings do not cause compilation errors.
You can use the sbt command `tpolecatCiMode` to enable strict mode and help catch any warnings you missed.

## Caveats when working on the code

## Avoiding internal cyclic module dependencies

For end users, doobie provides the aliases for high and low level APIs
such as `doobie.hi.HC`, `doobie.free.FPS`.
such as `doobie.hi.HC`, `doobie.free.FPS`.
Due to how the module depends on one another, internally in doobie we cannot use
these aliases because it'll lead to cyclic module dependencies and cause runtime errors.

Expand Down Expand Up @@ -49,6 +56,3 @@ To update the doc site, check out the tag first.
git checkout v1.2.3
sbt docs/publishMicrosite
```



39 changes: 24 additions & 15 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ import org.typelevel.sbt.tpolecat.{DevMode, CiMode}

// Library versions all in one place, for convenience and sanity.
lazy val catsVersion = "2.12.0"
lazy val catsEffectVersion = "3.5.6"
lazy val catsEffectVersion = "3.5.7"
lazy val circeVersion = "0.14.10"
lazy val fs2Version = "3.11.0"
lazy val h2Version = "1.4.200"
lazy val hikariVersion = "6.2.1" // N.B. Hikari v4 introduces a breaking change via slf4j v2
lazy val kindProjectorVersion = "0.11.2"
lazy val mysqlVersion = "9.1.0"
lazy val mysqlVersion = "9.2.0"
lazy val log4catsVersion = "2.7.0"
lazy val postGisVersion = "2024.1.0"
lazy val postgresVersion = "42.7.4"
lazy val refinedVersion = "0.11.2"
lazy val refinedVersion = "0.11.3"
lazy val scalaCheckVersion = "1.15.4"
lazy val scalatestVersion = "3.2.18"
lazy val munitVersion = "1.0.2"
lazy val munitVersion = "1.0.4"
lazy val shapelessVersion = "2.3.12"
lazy val silencerVersion = "1.7.1"
lazy val specs2Version = "4.20.7"
lazy val scala212Version = "2.12.19"
lazy val scala213Version = "2.13.14"
lazy val specs2Version = "4.20.9"
lazy val scala212Version = "2.12.20"
lazy val scala213Version = "2.13.15"
lazy val scala3Version = "3.3.4"
// scala-steward:off
lazy val slf4jVersion = "1.7.36"
Expand All @@ -33,6 +33,7 @@ lazy val weaverVersion = "0.8.4"
ThisBuild / tlBaseVersion := "1.0"
ThisBuild / tlCiReleaseBranches := Seq("main") // publish snapshots on `main`
ThisBuild / tlCiScalafmtCheck := true
//ThisBuild / scalaVersion := scala212Version
ThisBuild / scalaVersion := scala213Version
//ThisBuild / scalaVersion := scala3Version
ThisBuild / crossScalaVersions := Seq(scala212Version, scala213Version, scala3Version)
Expand Down Expand Up @@ -68,8 +69,8 @@ ThisBuild / githubWorkflowBuildPostamble ++= Seq(
),
WorkflowStep.Sbt(
commands = List("docs/makeSite"),
name = Some(s"Check Doc Site ($scala213Version only)"),
cond = Some(s"matrix.scala == '$scala213Version'")
name = Some(s"Check Doc Site (2.13 only)"),
cond = Some(s"matrix.scala == '2.13'")
)
)

Expand Down Expand Up @@ -98,9 +99,12 @@ lazy val compilerFlags = Seq(
Compile / doc / scalacOptions --= Seq(
"-Xfatal-warnings"
),
// Test / scalacOptions --= Seq(
// "-Xfatal-warnings"
// ),
// Disable warning when @nowarn annotation isn't suppressing a warning
// to simplify cross-building
// because 2.12 @nowarn doesn't actually do anything.. https://github.com/scala/bug/issues/12313
scalacOptions ++= Seq(
"-Wconf:cat=unused-nowarn:s"
),
scalacOptions ++= (if (tlIsScala3.value)
// Handle irrefutable patterns in for comprehensions
Seq("-source:future", "-language:adhocExtensions")
Expand Down Expand Up @@ -249,8 +253,7 @@ lazy val core = project
).filterNot(_ => tlIsScala3.value) ++ Seq(
"org.tpolecat" %% "typename" % "1.1.0",
"com.h2database" % "h2" % h2Version % "test",
"org.postgresql" % "postgresql" % postgresVersion % "test",
"org.mockito" % "mockito-core" % "5.12.0" % Test
"org.postgresql" % "postgresql" % postgresVersion % "test"
),
Compile / unmanagedSourceDirectories += {
val sourceDir = (Compile / sourceDirectory).value
Expand Down Expand Up @@ -493,7 +496,12 @@ lazy val bench = project
.enablePlugins(NoPublishPlugin)
.enablePlugins(AutomateHeaderPlugin)
.enablePlugins(JmhPlugin)
.dependsOn(core, postgres)
.settings(
libraryDependencies ++= (if (scalaVersion.value == scala212Version)
Seq("org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0")
else Seq.empty)
)
.dependsOn(core, postgres, hikari)
.settings(doobieSettings)

lazy val docs = project
Expand Down Expand Up @@ -539,6 +547,7 @@ lazy val docs = project
"scalaVersion" -> scalaVersion.value
),
mdocIn := baseDirectory.value / "src" / "main" / "mdoc",
mdocExtraArguments ++= Seq("--no-link-hygiene"),
Compile / paradox / sourceDirectory := mdocOut.value,
makeSite := makeSite.dependsOn(mdoc.toTask("")).value
)
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.1'
version: "3.1"

services:
postgres:
Expand All @@ -16,9 +16,8 @@ services:
limits:
memory: 500M


mysql:
image: mysql:8.0-debian
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: world
Expand Down
8 changes: 8 additions & 0 deletions init/postgres/test-db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ create extension postgis;
create extension hstore;
create type myenum as enum ('foo', 'bar', 'invalid');

create schema other_schema;

set search_path to other_schema;

create type other_enum as enum ('a', 'b');

set search_path to public;

--
-- The sample data used in the world database is Copyright Statistics
-- Finland, http://www.stat.fi/worldinfigures.
Expand Down
Loading

0 comments on commit 66dcd07

Please sign in to comment.