From 9351b44ac9d665c47b16b88b095341bb84348dac Mon Sep 17 00:00:00 2001 From: Pat Garrity Date: Sun, 23 Mar 2025 21:55:58 -0500 Subject: [PATCH] Initial commit - bootstrap the repository and some design. --- .gitignore | 8 ++ .pre-commit-config.yaml | 17 +++ .scalafmt.conf | 71 ++++++++++++ LICENSE | 9 ++ README.md | 23 ++++ adr/2025-03-23-database-design.md.md | 156 +++++++++++++++++++++++++++ adr/README.md | 3 + build.sbt | 97 +++++++++++++++++ project/build.properties | 1 + project/plugins.sbt | 33 ++++++ 10 files changed, 418 insertions(+) create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 .scalafmt.conf create mode 100644 LICENSE create mode 100644 README.md create mode 100644 adr/2025-03-23-database-design.md.md create mode 100644 adr/README.md create mode 100644 build.sbt create mode 100644 project/build.properties create mode 100644 project/plugins.sbt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dec42b8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +target/ +project/target/ +project/project/ +modules/model/target/ +modules/web/target/ +modules/cli/target/ +.version +.scala-build/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..d3cafd8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + - id: fix-byte-order-marker + - id: mixed-line-ending + args: ['--fix=lf'] + description: Enforces using only 'LF' line endings. + - id: trailing-whitespace + - id: check-yaml + - repo: https://git.garrity.co/garrity-software/gs-pre-commit-scala + rev: v1.0.1 + hooks: + - id: scalafmt diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 0000000..13746e4 --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,71 @@ +// See: https://github.com/scalameta/scalafmt/tags for the latest tags. +version = 3.9.4 +runner.dialect = scala3 +maxColumn = 80 + +rewrite { + rules = [RedundantBraces, RedundantParens, Imports, SortModifiers] + imports.expand = true + imports.sort = scalastyle + redundantBraces.ifElseExpressions = true + redundantBraces.stringInterpolation = true +} + +indent { + main = 2 + callSite = 2 + defnSite = 2 + extendSite = 4 + withSiteRelativeToExtends = 2 + commaSiteRelativeToExtends = 2 +} + +align { + preset = more + openParenCallSite = false + openParenDefnSite = false +} + +newlines { + implicitParamListModifierForce = [before,after] + topLevelStatementBlankLines = [ + { + blanks = 1 + } + ] + afterCurlyLambdaParams = squash +} + +danglingParentheses { + defnSite = true + callSite = true + ctrlSite = true + exclude = [] +} + +verticalMultiline { + atDefnSite = true + arityThreshold = 2 + newlineAfterOpenParen = true +} + +comments { + wrap = standalone +} + +docstrings { + style = "SpaceAsterisk" + oneline = unfold + wrap = yes + forceBlankLineBefore = true +} + +project { + excludePaths = [ + "glob:**target/**", + "glob:**.metals/**", + "glob:**.bloop/**", + "glob:**.bsp/**", + "glob:**metals.sbt" + ] +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f2b2735 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright Patrick Garrity + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..72f84dc --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# gs-maintainer + +[GS Open Source](https://garrity.co/oss.html) | +[License (MIT)](./LICENSE) + +Auto-maintenance for Scala projects. + +- [Installation](#installation) +- [Usage](#usage) +- [Donate](#donate) + +## Installation + +This project is not yet available. + +## Usage + +This project is not yet available. + +## Donate + +Enjoy this project or want to help me achieve my [goals](https://garrity.co)? +Consider [Donating to Pat on Ko-fi](https://ko-fi.com/gspfm). diff --git a/adr/2025-03-23-database-design.md.md b/adr/2025-03-23-database-design.md.md new file mode 100644 index 0000000..89bfe14 --- /dev/null +++ b/adr/2025-03-23-database-design.md.md @@ -0,0 +1,156 @@ +# ADR 2025-03-23: Database Design + +## Table of Contents + +- [Context](#context) +- [Decision](#decision) + - [Table: Registered Projects](#table-registered-project) + - [Table: Scala Version](#table-scala-version) + - [Table: SBT Version](#table-sbt-version) + - [Table: Project Dependency](#table-project-dependency) + - [Table: Version Parser](#table-version-parser) + - [Table: Project Dependency Version Parser](#table-project-dependency-version-parser) + - [Table: Dependency Version](#table-dependency-version) +- [Out of Scope](#out-of-scope) + +## Context + +The `gs-maintainer` project is intended to manage dependency version updates, +Scala language version updates, and SBT version updates for Scala projects. It +is also intended to help provide tracking information over time along with +dashboards to help inform and expedite development. + +## Decision + +Establish a small core database that can be expanded upon over time. This +database must support: + +- The concept of _registering_ a project for maintenance. +- The concept of _tracking critical tool versions_ over time. +- The concept of _tracking a dependency_ over time. + +This will be accomplished using 7 tables: + +- [Table: Registered Projects](#table-registered-project) +- [Table: Scala Version](#table-scala-version) +- [Table: SBT Version](#table-sbt-version) +- [Table: Project Dependency](#table-project-dependency) +- [Table: Version Parser](#table-version-parser) +- [Table: Project Dependency Version Parser](#table-project-dependency-version-parser) +- [Table: Dependency Version](#table-dependency-version) + +### Table: Registered Project + +```sql +CREATE TABLE registered_project( + project_id UUID NOT NULL PRIMARY KEY, + group TEXT NOT NULL, + name TEXT NOT NULL, + registered_at TIMESTAMPTZ NOT NULL, + git_url TIMESTAMPTZ NOT NULL +); +``` + +```sql +CREATE UNIQUE INDEX idx_registered_project_group_name +ON registered_project (group, name); +``` + +### Table: Scala Version + +```sql +CREATE TABLE scala_version( + version TEXT NOT NULL PRIMARY KEY, + major INT NOT NULL, + minor INT NOT NULL, + patch INT NOT NULL, + added_at TIMESTAMPTZ NOT NULL +); +``` + +```sql +CREATE UNIQUE INDEX idx_scala_version_major_minor_patch +ON scala_version (major, minor, patch); +``` + +### Table: SBT Version + +```sql +CREATE TABLE sbt_version( + version TEXT NOT NULL PRIMARY KEY, + major INT NOT NULL, + minor INT NOT NULL, + patch INT NOT NULL, + added_at TIMESTAMPTZ NOT NULL +); +``` + +```sql +CREATE UNIQUE INDEX idx_sbt_version_major_minor_patch +ON sbt_version (major, minor, patch); +``` + +### Table: Project Dependency + +```sql +CREATE TABLE project_dependency( + dependency_id UUID NOT NULL PRIMARY KEY, + group TEXT NOT NULL, + name TEXT NOT NULL, + added_at TIMESTAMPTZ NOT NULL +); +``` + +```sql +CREATE UNIQUE INDEX idx_project_dependency_group_name +ON project_dependency (group, name); +``` + +### Table: Version Parser + +```sql +CREATE TABLE version_parser( + parser_id UUID NOT NULL PRIMARY KEY, + parser_name TEXT NOT NULL UNIQUE, + implementation TEXT NOT NULL, + added_at TIMESTAMPTZ NOT NULL +); +``` + +### Table: Project Dependency Version Parser + +```sql +CREATE TABLE project_dependency_version_parser( + dependency_id UUID NOT NULL REFERENCES project_dependency, + parser_id UUID NOT NULL REFERENCES version_parser, + PRIMARY KEY (dependency_id, parser_id) +); +``` + +### Table: Dependency Version + +```sql +CREATE TABLE dependency_version( + dependency_id UUID NOT NULL REFERENCES project_dependency, + version TEXT NOT NULL, + first INT NULL, + second INT NULL, + third INT NULL, + fourth INT NULL, + added_at TIMESTAMPTZ NOT NULL, + PRIMARY KEY (dependency_id, version) +); +``` + +```sql +CREATE INDEX idx_dependency_version_order +ON dependency_version (first, second, third, fourth, added_at) +NULLS LAST; +``` + +## Out of Scope + +The following items are considered out of scope: + +- Project level upgrade policies. +- Per-dependency upgrade policies. diff --git a/adr/README.md b/adr/README.md new file mode 100644 index 0000000..4faee66 --- /dev/null +++ b/adr/README.md @@ -0,0 +1,3 @@ +# Architecture Decision Records (ADRs) + +- [2025-03-23: Database Design](./2025-03-23-database-design.md.md) diff --git a/build.sbt b/build.sbt new file mode 100644 index 0000000..cf2ac14 --- /dev/null +++ b/build.sbt @@ -0,0 +1,97 @@ +val scala3: String = "3.6.3" + +ThisBuild / scalaVersion := scala3 +ThisBuild / gsProjectName := "gs-maintainer" + +ThisBuild / externalResolvers := Seq( + "Garrity Software Mirror" at "https://maven.garrity.co/releases", + "Garrity Software Releases" at "https://maven.garrity.co/gs" +) + +lazy val sharedSettings = Seq( + scalaVersion := scala3, + version := calVer.value, + publish / skip := true, + publishLocal / skip := true, + publishArtifact := false +) + +val Deps = new { + val Cats = new { + val Core: ModuleID = "org.typelevel" %% "cats-core" % "2.13.0" + val Effect: ModuleID = "org.typelevel" %% "cats-effect" % "3.5.7" + } + + val Fs2 = new { + val Core: ModuleID = "co.fs2" %% "fs2-core" % "3.11.0" + } + + val Skunk = new { + val Core: ModuleID = "org.tpolecat" %% "skunk-core" % "1.1.0-M3" + } + + val Http4s = new { + val Core: ModuleID = "org.http4s" %% "http4s-core" % "1.0.0-M44" + val Dsl: ModuleID = "org.http4s" %% "http4s-dsl" % "1.0.0-M44" + val EmberServer: ModuleID = + "org.http4s" %% "http4s-ember-server" % "1.0.0-M44" + } + + val Gs = new { + val Uuid: ModuleID = "gs" %% "gs-uuid-v0" % "0.4.0" + val Config: ModuleID = "gs" %% "gs-config-v0" % "0.2.0" + val Datagen: ModuleID = "gs" %% "gs-datagen-core-v0" % "0.3.0" + } + + val MUnit: ModuleID = "org.scalameta" %% "munit" % "1.1.0" +} + +lazy val testSettings = Seq( + libraryDependencies ++= Seq( + Deps.MUnit % Test, + Deps.Gs.Datagen % Test + ) +) + +lazy val `gs-maintainer` = project + .in(file(".")) + .aggregate(model, web, cli) + .settings(sharedSettings) + .settings(name := s"${gsProjectName.value}") + +lazy val model = project + .in(file("modules/model")) + .settings(sharedSettings) + .settings(testSettings) + .settings(name := s"${gsProjectName.value}-model") + .settings( + libraryDependencies ++= Seq( + Deps.Gs.Uuid, + Deps.Cats.Core + ) + ) + +lazy val web = project + .in(file("modules/web")) + .dependsOn(model) + .settings(sharedSettings) + .settings(testSettings) + .settings(name := s"${gsProjectName.value}-web") + .settings( + libraryDependencies ++= Seq( + Deps.Http4s.Core, + Deps.Http4s.Dsl, + Deps.Http4s.EmberServer + ) + ) + +lazy val cli = project + .in(file("modules/cli")) + .dependsOn(model) + .settings(sharedSettings) + .settings(testSettings) + .settings(name := s"${gsProjectName.value}-cli") + .settings( + libraryDependencies ++= Seq( + ) + ) diff --git a/project/build.properties b/project/build.properties new file mode 100644 index 0000000..cc68b53 --- /dev/null +++ b/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.10.11 diff --git a/project/plugins.sbt b/project/plugins.sbt new file mode 100644 index 0000000..a159626 --- /dev/null +++ b/project/plugins.sbt @@ -0,0 +1,33 @@ +def selectCredentials(): Credentials = + if ((Path.userHome / ".sbt" / ".credentials").exists()) + Credentials(Path.userHome / ".sbt" / ".credentials") + else + Credentials.apply( + realm = "Reposilite", + host = "maven.garrity.co", + userName = sys.env + .get("GS_MAVEN_USER") + .getOrElse( + throw new RuntimeException( + "You must either provide ~/.sbt/.credentials or specify the GS_MAVEN_USER environment variable." + ) + ), + passwd = sys.env + .get("GS_MAVEN_TOKEN") + .getOrElse( + throw new RuntimeException( + "You must either provide ~/.sbt/.credentials or specify the GS_MAVEN_TOKEN environment variable." + ) + ) + ) + +credentials += selectCredentials() + +externalResolvers := Seq( + "Garrity Software Mirror" at "https://maven.garrity.co/releases", + "Garrity Software Releases" at "https://maven.garrity.co/gs" +) + +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.3.1") +addSbtPlugin("gs" % "sbt-garrity-software" % "0.5.0") +addSbtPlugin("gs" % "sbt-gs-calver" % "0.2.0")