Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build #209

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 178 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,207 @@ on:
branches: [main]
push:
branches: [main]
tags: [v*]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


concurrency:
group: ${{ github.workflow }} @ ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest]
scala: [3.2.1]
java: [temurin@11]
scala: [3]
java: [temurin@17, temurin@11]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
cache: sbt

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt +update

- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
run: sbt githubWorkflowCheck

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

- name: Check project
run: sbt ++${{ matrix.scala }} scalafmtCheckAll headerCheckAll
- name: Test
run: sbt '++ ${{ matrix.scala }}' test

- name: Build project
run: sbt ++${{ matrix.scala }} test IntegrationTest/test
- name: Check binary compatibility
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' mimaReportBinaryIssues

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

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p target model/target scodec/target fs2/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: tar cf targets.tar target model/target scodec/target fs2/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
uses: actions/upload-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}
path: targets.tar

publish:
name: Publish Artifacts
needs: [build]
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt +update

- name: Download target directories (3)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3

- name: Inflate target directories (3)
run: |
tar xf targets.tar
rm targets.tar

- name: Import signing key
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: echo $PGP_SECRET | base64 -d -i - | gpg --import

- name: Import signing key and strip passphrase
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != ''
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: |
echo "$PGP_SECRET" | base64 -d -i - > /tmp/signing-key.gpg
echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg
(echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1)

- name: Publish
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }}
run: sbt tlCiRelease

dependency-submission:
name: Submit Dependencies
if: github.event_name != 'pull_request'
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt +update

- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
with:
configs-ignore: test scala-tool scala-doc-tool test-internal
13 changes: 11 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version = 3.6.1
version = 3.7.3
runner.dialect = scala3
project.git = true
maxColumn = 120
align.preset=most
align.preset = most
assumeStandardLibraryStripMargin = true
rewrite.rules = [
PreferCurlyFors,
Expand All @@ -12,3 +12,12 @@ rewrite.rules = [
rewrite.imports.sort = scalastyle
rewrite.scala3.convertToNewSyntax = true
rewrite.scala3.removeOptionalBraces = true

fileOverride {
"glob:**/*.sbt" {
runner.dialect = sbt1
}
"glob:**/project/*.scala" {
runner.dialect = scala212
}
}
110 changes: 58 additions & 52 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,82 +1,88 @@
import org.scalafmt.sbt.ScalafmtPlugin

import scala.annotation.nowarn

// General info
val username = "RustedBones"
val repo = "taxonomy"
val username = "RustedBones"
val repo = "taxonomy"
val githubUrl = s"https://github.com/$username/$repo"

// for sbt-github-actions
ThisBuild / scalaVersion := "3.2.1"
ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(name = Some("Check project"), commands = List("scalafmtCheckAll", "headerCheckAll")),
WorkflowStep.Sbt(name = Some("Build project"), commands = List("test", "IntegrationTest/test"))
ThisBuild / tlBaseVersion := "1.2"
ThisBuild / tlVersionIntroduced := Map("3" -> "1.1.0")
ThisBuild / organization := "fr.davit"
ThisBuild / organizationName := "Michel Davit"
ThisBuild / startYear := Some(2020)
ThisBuild / licenses := Seq(License.Apache2)
ThisBuild / homepage := Some(url(githubUrl))
ThisBuild / scmInfo := Some(ScmInfo(url(githubUrl), s"[email protected]:$username/$repo.git"))
ThisBuild / developers := List(
Developer(
id = s"$username",
name = "Michel Davit",
email = "[email protected]",
url = url(s"https://github.com/$username")
)
)

// scala versions
val scala3 = "3.3.1"
val defaultScala = scala3

// github actions
val java17 = JavaSpec.temurin("17")
val java11 = JavaSpec.temurin("11")
val defaultJava = java17

ThisBuild / scalaVersion := defaultScala
ThisBuild / githubWorkflowTargetBranches := Seq("main")
ThisBuild / githubWorkflowPublishTargetBranches := Seq.empty
ThisBuild / githubWorkflowJavaVersions := Seq(java17, java11)

// build
ThisBuild / tlFatalWarnings := true
ThisBuild / tlJdkRelease := Some(8)
ThisBuild / tlSonatypeUseLegacyHost := true

// mima
ThisBuild / mimaBinaryIssueFilters ++= Seq()

lazy val commonSettings = Defaults.itSettings ++
headerSettings(Configurations.IntegrationTest) ++
inConfig(IntegrationTest)(ScalafmtPlugin.scalafmtConfigSettings) ++
Seq(
organization := "fr.davit",
organizationName := "Michel Davit",
scalaVersion := (ThisBuild / scalaVersion).value,
homepage := Some(url(s"https://github.com/$username/$repo")),
licenses += ("Apache-2.0", new URL("https://www.apache.org/licenses/LICENSE-2.0.txt")),
startYear := Some(2020),
scmInfo := Some(ScmInfo(url(s"https://github.com/$username/$repo"), s"[email protected]:$username/$repo.git")),
developers := List(
Developer(
id = s"$username",
name = "Michel Davit",
email = "[email protected]",
url = url(s"https://github.com/$username")
)
),
publishMavenStyle := true,
Test / publishArtifact := false,
publishTo := {
val resolver = if (isSnapshot.value) {
Opts.resolver.sonatypeSnapshots: @nowarn("cat=deprecation")
} else {
Opts.resolver.sonatypeStaging
}
Some(resolver)
},
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
credentials ++= (for {
username <- sys.env.get("SONATYPE_USERNAME")
password <- sys.env.get("SONATYPE_PASSWORD")
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq,
inConfig(IntegrationTest)(ScalafmtPlugin.scalafmtConfigSettings) ++ Seq(
testFrameworks += new TestFramework("munit.Framework")
)

lazy val `taxonomy` = (project in file("."))
.settings(commonSettings: _*)
.aggregate(`taxonomy-model`, `taxonomy-scodec`, `taxonomy-fs2`)
lazy val `taxonomy` = project
.in(file("."))
.settings(commonSettings)
.aggregate(
`taxonomy-model`,
`taxonomy-scodec`,
`taxonomy-fs2`
)
.settings(
publish / skip := true
publish / skip := true,
mimaPreviousArtifacts := Set.empty
)

lazy val `taxonomy-model` = (project in file("model"))
.settings(commonSettings: _*)
lazy val `taxonomy-model` = project
.in(file("model"))
.settings(commonSettings)

lazy val `taxonomy-scodec` = (project in file("scodec"))
lazy val `taxonomy-scodec` = project
.in(file("scodec"))
.configs(IntegrationTest)
.dependsOn(`taxonomy-model`)
.settings(commonSettings: _*)
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
Dependencies.ScodecCore,
Dependencies.Test.MUnitCE3
)
)

lazy val `taxonomy-fs2` = (project in file("fs2"))
lazy val `taxonomy-fs2` = project
.in(file("fs2"))
.configs(IntegrationTest)
.dependsOn(`taxonomy-scodec`)
.settings(commonSettings: _*)
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
Dependencies.FS2Core,
Expand Down
Loading