diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 00000000..bd6f549f --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,85 @@ +name: Validate and test + +on: + pull_request: + push: + branches: + - main + tags-ignore: [ v.* ] + +jobs: + check-code-style: + name: Checks + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves + fetch-depth: 0 + - name: Checkout GitHub merge + if: github.event.pull_request + run: |- + git fetch origin pull/${{ github.event.pull_request.number }}/merge:scratch + git checkout scratch + - name: Set up JDK 11 + uses: olafurpg/setup-scala@v10 + with: + java-version: adopt@1.11.0-9 + - name: Cache Coursier cache + uses: coursier/cache-action@v5 + - name: Code style check and binary-compatibility check + run: |- + cp .jvmopts-ci .jvmopts + sbt scalafmtCheckAll scalafmtSbtCheck headerCheck + + compile-and-test: + name: Compile and test + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Checkout GitHub merge + if: github.event.pull_request + run: |- + git fetch origin pull/${{ github.event.pull_request.number }}/merge:scratch + git checkout scratch + + - name: Set up JDK 11 + uses: olafurpg/setup-scala@v10 + with: + java-version: adopt@1.11.0-9 + + - name: Cache Coursier cache + uses: coursier/cache-action@v5 + + - name: Compile and test + run: sbt test + + test-docs: + name: Docs + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Checkout GitHub merge + if: github.event.pull_request + run: |- + git fetch origin pull/${{ github.event.pull_request.number }}/merge:scratch + git checkout scratch + - name: Set up JDK 11 + uses: olafurpg/setup-scala@v10 + with: + java-version: adopt@1.11.0-9 + - name: Cache Coursier cache + uses: coursier/cache-action@v5 + - name: Test Maven Java + run: |- + cp .jvmopts-ci .jvmopts + sbt docs/paradox + diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..bf3a404e --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,55 @@ +name: Publish + +on: + push: + branches: + - main + tags: ["*"] + +jobs: + sbt: + name: sbt publish + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves + fetch-depth: 0 + - name: Set up JDK 8 + uses: olafurpg/setup-scala@v10 + with: + java-version: adopt@1.8.0-275 + - name: Publish + run: |- + cp .jvmopts-ci .jvmopts + sbt ci-release + env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + + documentation: + name: Documentation + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves + fetch-depth: 0 + - name: Set up JDK 8 + uses: olafurpg/setup-scala@v10 + with: + java-version: adopt@1.8.0-275 + - name: Publish + run: |- + eval "$(ssh-agent -s)" + echo $SCP_SECRET | base64 -d > /tmp/id_rsa + chmod 600 /tmp/id_rsa + ssh-add /tmp/id_rsa + cp .jvmopts-ci .jvmopts + sbt docs/publishRsync + env: + SCP_SECRET: ${{ secrets.SCP_SECRET }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..86acc4d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +.idea* +*.env +*.log +*.iml +target/ +/.target/ +.DS_Store +.cache* +.classpath +.project +.settings +.tmpBin/ +*.sublime-project +/bin/ +ext-lib-src/ +.classpath_nb diff --git a/.jvmopts-ci b/.jvmopts-ci new file mode 100644 index 00000000..66e506de --- /dev/null +++ b/.jvmopts-ci @@ -0,0 +1,5 @@ +# This is used to configure the sbt instance that Travis launches + +-Xms1G +-Xmx1G +-Xss2M \ No newline at end of file diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 00000000..d7ea3a6d --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,47 @@ +version = 3.0.3 + +style = defaultWithAlign + +docstrings.style = Asterisk +indentOperator.preset = spray +maxColumn = 120 +rewrite.rules = [RedundantParens, SortImports, AvoidInfix] +unindentTopLevelOperators = true +align.tokens = [{code = "=>", owner = "Case"}] +align.openParenDefnSite = false +align.openParenCallSite = false +optIn.configStyleArguments = false +danglingParentheses.preset = false +spaces.inImportCurlyBraces = true +newlines.afterCurlyLambda = preserve +rewrite.neverInfix.excludeFilters = [ + and + min + max + until + to + by + eq + ne + "should.*" + "contain.*" + "must.*" + in + ignore + be + taggedAs + thrownBy + synchronized + have + when + size + only + noneOf + oneElementOf + noElementsOf + atLeastOneElementOf + atMostOneElementOf + allElementsOf + inOrderElementsOf + theSameElementsAs +] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..39c84cc2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,83 @@ +# Contributing to Akka Persistence R2DBC + +## General Workflow + +This is the process for committing code into main. + +1. Make sure you have signed the Lightbend CLA, if not, [sign it online](http://www.lightbend.com/contribute/cla). +2. Before starting to work on a feature or a fix, make sure that there is a ticket for your work in the [issue tracker](https://github.com/akka/akka-persistence-r2dbc/issues). If not, create it first. +3. Perform your work according to the [pull request requirements](#pull-request-requirements). +4. When the feature or fix is completed you should open a [Pull Request](https://help.github.com/articles/using-pull-requests) on [GitHub](https://github.com/akka/akka-persistence-r2dbc/pulls). +5. The Pull Request should be reviewed by other maintainers (as many as feasible/practical). Note that the maintainers can consist of outside contributors, both within and outside Lightbend. Outside contributors are encouraged to participate in the review process, it is not a closed process. +6. After the review you should fix the issues (review comments, CI failures) by pushing a new commit for new review, iterating until the reviewers give their thumbs up and CI tests pass. +7. If the branch merge conflicts with its target, rebase your branch onto the target branch. + +In case of questions about the contribution process or for discussion of specific issues please visit the [akka/dev gitter chat](https://gitter.im/akka/dev). + +## Pull Request Requirements + +For a Pull Request to be considered at all it has to meet these requirements: + +1. Pull Request branch should be given a unique descriptive name that explains its intent. +2. Code in the branch should live up to the current code standard: + - Not violate [DRY](http://programmer.97things.oreilly.com/wiki/index.php/Don%27t_Repeat_Yourself). + - [Boy Scout Rule](http://programmer.97things.oreilly.com/wiki/index.php/The_Boy_Scout_Rule) needs to have been applied. +3. Regardless if the code introduces new features or fixes bugs or regressions, it must have comprehensive tests. +4. The code must be well documented (see the [Documentation](#documentation) section below). +5. The commit messages must properly describe the changes, see [further below](#creating-commits-and-writing-commit-messages). +6. Do not use ``@author`` tags since it does not encourage [Collective Code Ownership](http://www.extremeprogramming.org/rules/collective.html). Contributors get the credit they deserve in the release notes. + +If these requirements are not met then the code should **not** be merged into main, or even reviewed - regardless of how good or important it is. No exceptions. + +## Documentation + +Documentation should be written in two forms: + +1. API documentation in the form of scaladoc/javadoc comments on the Scala and Java user API. +2. Guide documentation in [docs](docs/) subproject using [Paradox](https://github.com/lightbend/paradox) documentation tool. This documentation should give a short introduction of how a given connector should be used. + +## External Dependencies + +All the external runtime dependencies for the project, including transitive dependencies, must have an open source license that is equal to, or compatible with, [Apache 2](http://www.apache.org/licenses/LICENSE-2.0). + +This must be ensured by manually verifying the license for all the dependencies for the project: + +1. Whenever a committer to the project changes a version of a dependency (including Scala) in the build file. +2. Whenever a committer to the project adds a new dependency. +3. Whenever a new release is cut (public or private for a customer). + +Every external dependency listed in the build file must have a trailing comment with the license name of the dependency. + +Which licenses are compatible with Apache 2 are defined in [this doc](http://www.apache.org/legal/3party.html#category-a), where you can see that the licenses that are listed under ``Category A`` automatically compatible with Apache 2, while the ones listed under ``Category B`` needs additional action: + +> Each license in this category requires some degree of [reciprocity](http://www.apache.org/legal/3party.html#define-reciprocal); therefore, additional action must be taken in order to minimize the chance that a user of an Apache product will create a derivative work of a reciprocally-licensed portion of an Apache product without being aware of the applicable requirements. + +## Creating Commits And Writing Commit Messages + +Follow these guidelines when creating public commits and writing commit messages. + +1. If your work spans multiple local commits (for example; if you do safe point commits while working in a feature branch or work in a branch for long time doing merges/rebases etc.) then please do not commit it all but rewrite the history by squashing the commits into a single big commit which you write a good commit message for (like discussed in the following sections). For more info read this article: [Git Workflow](http://sandofsky.com/blog/git-workflow.html). Every commit should be able to be used in isolation, cherry picked etc. + +2. First line should be a descriptive sentence what the commit is doing, including the ticket number. It should be possible to fully understand what the commit does—but not necessarily how it does it—by just reading this single line. We follow the “imperative present tense” style for commit messages ([more info here](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)). + + It is **not ok** to only list the ticket number, type "minor fix" or similar. + If the commit is a small fix, then you are done. If not, go to 3. + +3. Following the single line description should be a blank line followed by an enumerated list with the details of the commit. + +4. Add keywords for your commit (depending on the degree of automation we reach, the list may change over time): + * ``Review by @gituser`` - if you want to notify someone on the team. The others can, and are encouraged to participate. + +Example: + + Add eventsByTag query #123 + + * Details 1 + * Details 2 + * Details 3 + +## How To Enforce These Guidelines? + +1. GitHub Actions CI automatically merges the code, builds it, runs the tests and sets Pull Request status accordingly of results in GitHub. +2. [Scalafmt](https://olafurpg.github.io/scalafmt) enforces some of the code style rules. +3. [sbt-header plugin](https://github.com/sbt/sbt-header) manages consistent copyright headers in every source file. diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/build.sbt b/build.sbt new file mode 100644 index 00000000..5aaaa19b --- /dev/null +++ b/build.sbt @@ -0,0 +1,87 @@ +import sbt.Keys.parallelExecution +import xerial.sbt.Sonatype.autoImport.sonatypeProfileName + +inThisBuild( + Seq( + organization := "com.lightbend.akka", + organizationName := "Lightbend Inc.", + homepage := Some(url("https://doc.akka.io/docs/akka-persistence-r2dbc/current")), + scmInfo := Some( + ScmInfo( + url("https://github.com/akka/akka-persistence-r2dbc"), + "https://github.com/akka/akka-persistence-r2dbc.git")), + startYear := Some(2021), + developers += Developer( + "contributors", + "Contributors", + "https://gitter.im/akka/dev", + url("https://github.com/akka/akka-persistence-r2dbc/graphs/contributors")), + licenses := Seq(("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))), + description := "An Akka Persistence backed by SQL database with R2DBC", + // due to the emulator + parallelExecution := false, + // add snapshot repo when Akka version overriden + resolvers ++= + (if (System.getProperty("override.akka.version") != null) + Seq("Akka Snapshots".at("https://oss.sonatype.org/content/repositories/snapshots/")) + else Seq.empty))) + +def common: Seq[Setting[_]] = + Seq( + crossScalaVersions := Seq(Dependencies.Scala213), + scalaVersion := Dependencies.Scala213, + crossVersion := CrossVersion.binary, + scalafmtOnCompile := true, + sonatypeProfileName := "com.lightbend", + // Setting javac options in common allows IntelliJ IDEA to import them automatically + javacOptions in compile ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-target", "1.8"), + headerLicense := Some(HeaderLicense.Custom("""Copyright (C) 2021 Lightbend Inc. """)), + logBuffered in Test := System.getProperty("akka.logBufferedTests", "false").toBoolean, + // show full stack traces and test case durations + testOptions in Test += Tests.Argument("-oDF"), + // -v Log "test run started" / "test started" / "test run finished" events on log level "info" instead of "debug". + // -a Show stack traces and exception class name for AssertionErrors. + testOptions += Tests.Argument(TestFrameworks.JUnit, "-v", "-a"), + projectInfoVersion := (if (isSnapshot.value) "snapshot" else version.value)) + +lazy val dontPublish = Seq(skip in publish := true, publishArtifact in Compile := false) + +lazy val root = (project in file(".")) + .settings(common) + .settings(dontPublish) + .settings( + name := "akka-persistence-r2dbc-root", + publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo")))) + .aggregate(core) + +def suffixFileFilter(suffix: String): FileFilter = new SimpleFileFilter(f => f.getAbsolutePath.endsWith(suffix)) + +lazy val core = (project in file("core")) + .settings(common) + .settings(name := "akka-persistence-r2dbc", libraryDependencies ++= Dependencies.core) + +lazy val docs = project + .in(file("docs")) + .enablePlugins(AkkaParadoxPlugin, ParadoxSitePlugin, PublishRsyncPlugin) + .dependsOn(core) + .settings(common) + .settings(dontPublish) + .settings( + name := "Akka Persistence R2DBC", + crossScalaVersions := Seq(Dependencies.Scala212), + previewPath := (Paradox / siteSubdirName).value, + Paradox / siteSubdirName := s"docs/akka-persistence-r2dbc/${projectInfoVersion.value}", + paradoxGroups := Map("Language" -> Seq("Java", "Scala")), + Compile / paradoxProperties ++= Map( + "project.url" -> "https://doc.akka.io/docs/akka-persistence-r2dbc/current/", + "canonical.base_url" -> "https://doc.akka.io/docs/akka-persistence-r2dbc/current", + "akka.version" -> Dependencies.AkkaVersion, + "extref.akka.base_url" -> s"https://doc.akka.io/docs/akka/${Dependencies.AkkaVersionInDocs}/%s", + "extref.akka-docs.base_url" -> s"https://doc.akka.io/docs/akka/${Dependencies.AkkaVersionInDocs}/%s", + "extref.java-docs.base_url" -> "https://docs.oracle.com/en/java/javase/11/%s", + "scaladoc.scala.base_url" -> s"https://www.scala-lang.org/api/current/", + "scaladoc.akka.base_url" -> s"https://doc.akka.io/api/akka/${Dependencies.AkkaVersion}", + "scaladoc.com.typesafe.config.base_url" -> s"https://lightbend.github.io/config/latest/api/"), + resolvers += Resolver.jcenterRepo, + publishRsyncArtifacts += makeSite.value -> "www/", + publishRsyncHost := "akkarepo@gustav.akka.io") diff --git a/docker/docker-compose-postgres.yml b/docker/docker-compose-postgres.yml new file mode 100644 index 00000000..0aabd6a7 --- /dev/null +++ b/docker/docker-compose-postgres.yml @@ -0,0 +1,9 @@ +version: '2.2' +services: + postgres-db: + image: postgres:latest + ports: + - 5432:5432 + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres diff --git a/docs/src/main/paradox/.htaccess b/docs/src/main/paradox/.htaccess new file mode 100644 index 00000000..1bbde4bd --- /dev/null +++ b/docs/src/main/paradox/.htaccess @@ -0,0 +1,2 @@ +# This file can be used for redirects like: +# RedirectMatch 301 ^/docs/alpakka/([^/]+)/data-transformations/recordio.html https://doc.akka.io/docs/alpakka/$1/data-transformations/simple-codecs.html diff --git a/docs/src/main/paradox/_template/projectSpecificFooter.st b/docs/src/main/paradox/_template/projectSpecificFooter.st new file mode 100644 index 00000000..c4a9441f --- /dev/null +++ b/docs/src/main/paradox/_template/projectSpecificFooter.st @@ -0,0 +1,4 @@ + + diff --git a/docs/src/main/paradox/assets/js/warnOldVersion.js b/docs/src/main/paradox/assets/js/warnOldVersion.js new file mode 100644 index 00000000..39da3c3c --- /dev/null +++ b/docs/src/main/paradox/assets/js/warnOldVersion.js @@ -0,0 +1,23 @@ +function initOldVersionWarnings($, thisVersion, projectUrl) { + if (projectUrl && projectUrl !== "") { + var schemeLessUrl = projectUrl; + if (projectUrl.startsWith("http://")) projectUrl = schemeLessUrl.substring(5); + else if (projectUrl.startsWith("https://")) projectUrl = schemeLessUrl.substring(6); + const url = schemeLessUrl + (schemeLessUrl.endsWith("\/") ? "" : "/") + "paradox.json"; + $.get(url, function (versionData) { + const currentVersion = versionData.version; + if (thisVersion !== currentVersion) { + showVersionWarning(thisVersion, currentVersion, projectUrl); + } + }); + } +} + +function showVersionWarning(thisVersion, currentVersion, projectUrl) { + $('#docs').prepend( + '
' + + '

This documentation regards version ' + thisVersion + ', ' + + 'however the current version is ' + currentVersion + '.

' + + '
' + ); +} \ No newline at end of file diff --git a/docs/src/main/paradox/contributing.md b/docs/src/main/paradox/contributing.md new file mode 100644 index 00000000..300c0bf7 --- /dev/null +++ b/docs/src/main/paradox/contributing.md @@ -0,0 +1,18 @@ +# Contributing + +Please feel free to contribute to Akka Persistence R2DBC and the documentation by reporting issues you identify, or by suggesting changes to the code. +Please refer to our [contributing instructions](https://github.com/akka/akka/blob/main/CONTRIBUTING.md) to learn how it can be done. + +We want Akka to strive in a welcoming and open atmosphere and expect all contributors to respect our [code of conduct](https://www.lightbend.com/conduct). + +## Running the tests + +The tests expect a locally running database. + +It can be started with the docker-comopse file in the docker folder: + +@@snip [docker-compose.yml](/docker/docker-compose-postgres.yml) + +``` +docker-compose -f docker/docker-compose-postgres.yml up +``` diff --git a/docs/src/main/paradox/index.md b/docs/src/main/paradox/index.md new file mode 100644 index 00000000..c36836a1 --- /dev/null +++ b/docs/src/main/paradox/index.md @@ -0,0 +1,13 @@ +# Akka Persistence R2DBC Documentation + +The Akka Persistence R2DBC plugin allows for using SQL database with R2DBC as a backend for Akka Persistence. + +@@toc { depth=2 } + +@@@ index + +* [overview](overview.md) +* [Contributing](contributing.md) + +@@@ + diff --git a/docs/src/main/paradox/overview.md b/docs/src/main/paradox/overview.md new file mode 100644 index 00000000..d8e603a1 --- /dev/null +++ b/docs/src/main/paradox/overview.md @@ -0,0 +1,30 @@ +# Overview + +The Akka Persistence R2DBC plugin allows for using SQL database with R2DBC as a backend for Akka Persistence. + +@@@ warning + +The project is currently under development and there are no guarantees for binary compatibility +and the schema may change. + +@@@ + +## Project Info + +@@project-info{ projectId="core" } + +## Dependencies + +@@dependency [Maven,sbt,Gradle] { + group=com.lightbend.akka + artifact=akka-persistence-r2dbc_$scala.binary.version$ + version=$project.version$ +} + +This plugin depends on Akka 2.6.x and note that it is important that all `akka-*` +dependencies are in the same version, so it is recommended to depend on them explicitly to avoid problems +with transient dependencies causing an unlucky mix of versions. + +@@dependencies{ projectId="core" } + + diff --git a/project/AutomaticModuleName.scala b/project/AutomaticModuleName.scala new file mode 100644 index 00000000..c05e9c58 --- /dev/null +++ b/project/AutomaticModuleName.scala @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2009-2018 Lightbend Inc. + */ +import sbt.{ Def, _ } +import sbt.Keys._ + +/** + * Helper to set Automatic-Module-Name in projects. + * + * !! DO NOT BE TEMPTED INTO AUTOMATICALLY DERIVING THE NAMES FROM PROJECT NAMES !! + * + * The names carry a lot of implications and DO NOT have to always align 1:1 with the group ids or package names, though + * there should be of course a strong relationship between them. + */ +object AutomaticModuleName { + private val AutomaticModuleName = "Automatic-Module-Name" + + def settings(name: String): Seq[Def.Setting[Task[Seq[PackageOption]]]] = Seq( + packageOptions in (Compile, packageBin) += Package.ManifestAttributes(AutomaticModuleName → name)) +} diff --git a/project/Dependencies.scala b/project/Dependencies.scala new file mode 100644 index 00000000..d912e9ed --- /dev/null +++ b/project/Dependencies.scala @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2021 Lightbend Inc. + */ + +import sbt._ + +object Dependencies { + val Scala212 = "2.12.14" + val Scala213 = "2.13.1" + val AkkaVersion = System.getProperty("override.akka.version", "2.6.16") + val AkkaVersionInDocs = AkkaVersion.take(3) + // for example + val AkkaHttpVersion = "10.2.6" + val AkkaManagementVersion = "1.0.6" + val R2dbcVersion = "0.9.0.M2" + + object Compile { + val akkaActorTyped = "com.typesafe.akka" %% "akka-actor-typed" % AkkaVersion + val akkaStream = "com.typesafe.akka" %% "akka-stream" % AkkaVersion + val akkaPersistence = "com.typesafe.akka" %% "akka-persistence-typed" % AkkaVersion + val akkaPersistenceTyped = "com.typesafe.akka" %% "akka-persistence-typed" % AkkaVersion + val akkaPersistenceQuery = "com.typesafe.akka" %% "akka-persistence-query" % AkkaVersion + val akkaClusterTyped = "com.typesafe.akka" %% "akka-cluster-typed" % AkkaVersion + val akkaClusterShardingTyped = "com.typesafe.akka" %% "akka-cluster-sharding-typed" % AkkaVersion + val akkaSerializationJackson = "com.typesafe.akka" %% "akka-serialization-jackson" % AkkaVersion + val akkaSlf4j = "com.typesafe.akka" %% "akka-slf4j" % AkkaVersion + val logback = "ch.qos.logback" % "logback-classic" % "1.2.6" // EPL 1.0 / LGPL 2.1 + + val postgresql = "org.postgresql" % "postgresql" % "42.2.18" + val r2dbcSpi = "io.r2dbc" % "r2dbc-spi" % R2dbcVersion + val r2dbcPool = "io.r2dbc" % "r2dbc-pool" % R2dbcVersion + val r2dbcPostgres = "org.postgresql" % "r2dbc-postgresql" % R2dbcVersion + } + + object TestDeps { + val akkaPersistenceTck = "com.typesafe.akka" %% "akka-persistence-tck" % AkkaVersion % Test + val akkaTestkit = "com.typesafe.akka" %% "akka-actor-testkit-typed" % AkkaVersion % Test + val akkaStreamTestkit = "com.typesafe.akka" %% "akka-stream-testkit" % AkkaVersion % Test + val akkaJackson = "com.typesafe.akka" %% "akka-serialization-jackson" % AkkaVersion % Test + + val logback = Compile.logback % Test + val scalaTest = "org.scalatest" %% "scalatest" % "3.1.1" % Test // ApacheV2 + val junit = "junit" % "junit" % "4.12" % Test // Eclipse Public License 1.0 + val junitInterface = "com.novocode" % "junit-interface" % "0.11" % Test // "BSD 2-Clause" + } + + import Compile._ + + val core = Seq( + akkaPersistence, + akkaPersistenceQuery, + r2dbcSpi, + r2dbcPool, + r2dbcPostgres, + postgresql, + TestDeps.akkaPersistenceTck, + TestDeps.akkaStreamTestkit, + TestDeps.akkaTestkit, + TestDeps.akkaJackson, + TestDeps.logback, + TestDeps.scalaTest) +} diff --git a/project/build.properties b/project/build.properties new file mode 100644 index 00000000..06703e34 --- /dev/null +++ b/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.3.9 diff --git a/project/plugins.sbt b/project/plugins.sbt new file mode 100644 index 00000000..12718d70 --- /dev/null +++ b/project/plugins.sbt @@ -0,0 +1,12 @@ +addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.2.0") // for maintenance of copyright file header +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") +addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.4.4") + +// for releasing +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") + +//// docs +addSbtPlugin("com.lightbend.paradox" % "sbt-paradox-dependencies" % "0.2.1") +addSbtPlugin("com.lightbend.akka" % "sbt-paradox-akka" % "0.39") +addSbtPlugin("com.lightbend.sbt" % "sbt-publish-rsync" % "0.2") +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") diff --git a/project/project-info.conf b/project/project-info.conf new file mode 100644 index 00000000..186ad429 --- /dev/null +++ b/project/project-info.conf @@ -0,0 +1,35 @@ +project-info { + version: "current" + shared-info { + jdk-versions: ["OpenJDK 11"] + issues: { + url: "https://github.com/akka/akka-persistence-r2dbc/issues" + text: "Github issues" + } + release-notes: { + url: "https://github.com/akka/akka-persistence-r2dbc/releases" + text: "Github releases" + } + forums: [ + { + text: "Lightbend Discuss" + url: "https://discuss.lightbend.com/c/akka/" + } + { + text: "akka/akka Gitter channel" + url: "https://gitter.im/akka/akka" + } + ] + } + core: ${project-info.shared-info} { + title: "Akka Persistence R2DBC" + jpms-name: "akka.persistence.r2dbc" + levels: [ + { + readiness: "Incubating" + since: "2021-09-19" // update + since-version: "0.1" + } + ] + } +}