From 1ff5ecde8c617dd0f25d1e512cf6bfefaa675a4e Mon Sep 17 00:00:00 2001 From: Yann Bouzonie Date: Tue, 1 Oct 2024 14:54:04 +0200 Subject: [PATCH] feat(ci)(cd): basic workflows (#1) scalafmt conf and basic CI/CD workflows --- .github/workflows/ci.yaml | 34 +++++++++ .github/workflows/publish.yaml | 21 +++++ .scalafmt.conf | 136 +++++++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/publish.yaml create mode 100644 .scalafmt.conf diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..8979e5f --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,34 @@ +name: CI +on: + pull_request: + paths: + - .github/workflows/ci.yaml + - build.sbt + - .scalafmt.conf + - project/** + - src/** + +defaults: + run: + shell: bash + +env: + GITHUB_TOKEN: ${{ secrets.READ_PACKAGES }} + +jobs: + code-check: + runs-on: self-hosted + container: + image: sbtscala/scala-sbt:eclipse-temurin-jammy-21.0.2_13_1.9.9_2.12.19 + options: --user 1001:1001 + steps: + - uses: actions/checkout@v4 + - run: sbt headerCheckAll + test: + runs-on: self-hosted + container: + image: sbtscala/scala-sbt:eclipse-temurin-jammy-21.0.2_13_1.9.9_2.12.19 + options: --user 1001:1001 + steps: + - uses: actions/checkout@v4 + - run: sbt clean test diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..f3a327c --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,21 @@ +name: publish +on: + push: + tags: + - "v*.*.*" + +env: + GITHUB_TOKEN: ${{ secrets.WRITE_PACKAGES }} + +jobs: + publish: + runs-on: self-hosted + container: + image: sbtscala/scala-sbt:eclipse-temurin-jammy-21.0.2_13_1.9.9_2.12.19 + options: --user 1001:1001 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: sbt publish + run: sbt clean publish diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 0000000..9c71391 --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,136 @@ +version = 2.7.5 +maxColumn = 120 + +optIn.forceBlankLineBeforeDocstring = true +trailingCommas = "never" + +align { + openParenCallSite = false + openParenDefnSite = false + preset=some + stripMargin = false + tokens = [] +} + +assumeStandardLibraryStripMargin = true +binPack.parentConstructors = "never" + +continuationIndent { + callSite = 2 + ctorSite = 4 + defnSite = 4 + extendSite = 4 +} + +danglingParentheses { + ctrlSite = true + defnSite = true +} + + +docstrings.style = "Asterisk" // JavaDoc +includeCurlyBraceInSelectChains = true +includeNoParensInSelectChains = false + +literals { + double = "Lower" + float = "Lower" + hexDigits = "Lower" + hexPrefix = "Lower" + long = "Upper" +} + +newlines { + afterCurlyLambdaParams = squash + afterCurlyLambdaParams=squash + alwaysBeforeElseAfterCurlyIf = false + beforeCurlyLambdaParams = multilineWithCaseOnly + beforeMultiline = fold + beforeMultilineDef = false + implicitParamListModifierPrefer = before +} + +rewrite { + redundantBraces { + generalExpressions = false + ifElseExpressions = false + methodBodies = false + parensForOneLineApply = true + stringInterpolation = true + } + rules = [ + RedundantBraces, + RedundantParens, + SortModifiers, + SortImports + ] + redundantBraces { + generalExpressions = false + methodBodies = false + ifElseExpressions = false + parensForOneLineApply = true + stringInterpolation = true + } + sortModifiers { + order = [ + "implicit", + "final", + "sealed", + "abstract", + "override", + "private", + "protected", + "lazy" + ] + } +} + +continuationIndent { + callSite = 2 + defnSite = 4 + ctorSite = 4 + extendSite = 4 +} + +align { + preset=some + tokens = [] + openParenCallSite = false + openParenDefnSite = false + preset = some + stripMargin = false + tokens = [] +} + +danglingParentheses { + defnSite = true + ctrlSite = true +} + +spaces { + afterKeywordBeforeParen = true + afterSymbolicDefs = false + beforeContextBoundColon = "Never" + inByNameTypes = true + inParentheses = false + neverAroundInfixTypes = [] + afterKeywordBeforeParen = true + inByNameTypes = true + afterSymbolicDefs = false +} + +literals { + long = "Upper" + float = "Lower" + double = "Lower" + hexPrefix = "Lower" + hexDigits = "Lower" +} + +docstrings { + style = "Asterisk" // JavaDoc +} + +binPack { + parentConstructors = "Never" +}