diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml deleted file mode 100644 index a9ae19c..0000000 --- a/.forgejo/workflows/build.yaml +++ /dev/null @@ -1,8 +0,0 @@ -on: [push] -jobs: - test: - runs-on: docker - container: - image: alpine:3.19 - steps: - - run: echo Verifying builds diff --git a/.forgejo/workflows/pull_request.yaml b/.forgejo/workflows/pull_request.yaml new file mode 100644 index 0000000..867e08e --- /dev/null +++ b/.forgejo/workflows/pull_request.yaml @@ -0,0 +1,24 @@ +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + library_snapshot: + runs-on: docker + container: + image: registry.garrity.co:8443/gs/ci-scala:latest + name: 'Build and Test Library Snapshot' + env: + GS_MAVEN_USER: ${{ vars.GS_MAVEN_USER }} + GS_MAVEN_TOKEN: ${{ secrets.GS_MAVEN_TOKEN }} + steps: + - uses: actions/checkout@v4 + name: 'Checkout Repository' + - name: 'Pre-Commit' + run: | + pre-commit install + pre-commit run --all-files + - name: 'Unit Tests and Code Coverage' + run: sbt clean coverage test coverageReport + - name: 'Publish Snapshot' + run: sbt clean publish diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d84ba64..f2e8cfc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,13 @@ repos: 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: v0.1.3 + rev: v1.0.0 hooks: - id: scalafmt diff --git a/build.sbt b/build.sbt index b1b52b7..2d2e233 100644 --- a/build.sbt +++ b/build.sbt @@ -1,12 +1,15 @@ -val scala3: String = "3.3.1" +val scala3: String = "3.4.0" ThisBuild / scalaVersion := scala3 ThisBuild / versionScheme := Some("semver-spec") ThisBuild / gsProjectName := "gs-uuid" val sharedSettings = Seq( - scalaVersion := scala3, - version := semVerSelected.value + scalaVersion := scala3, + version := semVerSelected.value, + coverageFailOnMinimum := true, + coverageMinimumStmtTotal := 100, + coverageMinimumBranchTotal := 100 ) lazy val testSettings = Seq( diff --git a/project/build.properties b/project/build.properties index abbbce5..04267b1 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.9.8 +sbt.version=1.9.9 diff --git a/project/plugins.sbt b/project/plugins.sbt index 96d399c..49f95ef 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,10 +1,33 @@ -credentials += Credentials(Path.userHome / ".sbt" / ".credentials") +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.0.8") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.11") addSbtPlugin("gs" % "sbt-garrity-software" % "0.2.0") addSbtPlugin("gs" % "sbt-gs-semver" % "0.2.0") diff --git a/src/test/scala/gs/uuid/v0/UUIDTests.scala b/src/test/scala/gs/uuid/v0/UUIDTests.scala index 891fb76..2bda4f5 100644 --- a/src/test/scala/gs/uuid/v0/UUIDTests.scala +++ b/src/test/scala/gs/uuid/v0/UUIDTests.scala @@ -50,6 +50,13 @@ class UUIDTests extends munit.FunSuite: assert(parsed == Some(base)) } + test("should return lsb, msb, and if the UUID is zero") { + val uuid = UUID.parse("00000000-0000-0000-0000-000000000000") + assert(uuid.map(_.lsb()) == Some(0L)) + assert(uuid.map(_.msb()) == Some(0L)) + assert(uuid.map(_.isZero()) == Some(true)) + } + private def doGen( using UUID.Generator