Skip to content

Commit

Permalink
Make Scalafmt mandatory in build (#1573)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandru committed May 15, 2022
1 parent 5d732ee commit d2f8ed1
Show file tree
Hide file tree
Showing 757 changed files with 5,106 additions and 3,577 deletions.
60 changes: 59 additions & 1 deletion .github/workflows/build.yml
Expand Up @@ -111,6 +111,10 @@ jobs:
mima:
name: Mima / scala ${{ matrix.scala }}, jdk ${{ matrix.java }}
runs-on: ubuntu-20.04

env:
CI: true

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -151,9 +155,60 @@ jobs:
SCALA_VERSION: ${{ matrix.scala }}
SBT_COMMAND: mimaReportBinaryIssues

scalafmt:
name: Scalafmt / scala ${{ matrix.scala }}, jdk ${{ matrix.java }}
runs-on: ubuntu-20.04

env:
CI: true

strategy:
fail-fast: false
matrix:
include:
- { java: 11, scala: 2.12.15 }
- { java: 11, scala: 2.13.8 }
- { java: 11, scala: 3.1.2 }

steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
with:
java-version: "adopt@1.${{ matrix.java }}"

- name: Cache ivy2
uses: actions/cache@v1
with:
path: ~/.ivy2/cache
key: ${{ runner.os }}-sbt-ivy-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Cache coursier (linux)
if: contains(runner.os, 'linux')
uses: actions/cache@v1
with:
path: ~/.cache/coursier/v1
key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Cache sbt
uses: actions/cache@v1
with:
path: ~/.sbt
key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: sbt scalafmtCheckAll
run: |
./.github/scripts/exec-sbt-command
env:
SCALA_VERSION: ${{ matrix.scala }}
SBT_COMMAND: scalafmtCheckAll

unidoc:
name: Unidoc / scala ${{ matrix.scala }}, jdk ${{ matrix.java }}
runs-on: ubuntu-20.04

env:
CI: true

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -196,7 +251,7 @@ jobs:

all_tests:
name: All Tests
needs: [ jvm-tests, js-tests, mima, unidoc ]
needs: [ jvm-tests, js-tests, mima, scalafmt, unidoc ]
runs-on: ubuntu-20.04
steps:
- name: Ack
Expand All @@ -208,6 +263,9 @@ jobs:
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/series/4.x')
needs: [ all_tests ]

env:
CI: true

runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/manual-publish.yml
Expand Up @@ -16,6 +16,9 @@ jobs:
publish:
name: Publish to Sonatype (Request)

env:
CI: true

runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
Expand Down
82 changes: 38 additions & 44 deletions .scalafmt.conf
@@ -1,67 +1,61 @@
version = "3.0.2"

maxColumn = 120
docstrings = ScalaDoc
version = "3.5.2"
runner.dialect = scala213source3

project.git = true
preset = default

# Alignment is cool, until we have to view diffs and solve merge conflicts
align.preset = none
align.tokens = [
{code = "<-"},
]

# If true, the margin character | is aligned with the opening triple quote string literals
assumeStandardLibraryStripMargin = true
fileOverride {
"glob:**/src/main/scala_3.0/**" {
runner.dialect = scala3
},
"glob:**/*.sbt" {
align.tokens = [
{code = "<-"},
{code = "="},
{code = "%", owners = [{regex = "Term.ApplyInfix"}]},
{code = "%%", owners = [{regex = "Term.ApplyInfix"}]}
]
},
"glob:**/project/*.scala" {
align.tokens = [
{code = "<-"},
{code = "="},
{code = "%", owners = [{regex = "Term.ApplyInfix"}]},
{code = "%%", owners = [{regex = "Term.ApplyInfix"}]}
]
}
}

#From scalafmt website:
#see: http://scalameta.org/scalafmt/#includeCurlyBraceInSelectChains
includeCurlyBraceInSelectChains = false
docstrings.style = keep
maxColumn = 120

rewrite.rules = [
SortImports,
AvoidInfix,
]

spaces.inImportCurlyBraces = true
includeNoParensInSelectChains = false
trailingCommas = preserve

continuationIndent {
callSite = 2
defnSite = 2
extendSite = 2
}

danglingParentheses = false

newlines {
alwaysBeforeTopLevelStatements = false
sometimesBeforeColonInMethodReturnType = true
penalizeSingleSelectMultiArgList = false
alwaysBeforeElseAfterCurlyIf = false
neverInResultType = false
}

spaces {
afterKeywordBeforeParen = true
}

binPack {
parentConstructors = true
literalArgumentLists = true
}

optIn {
breaksInsideChains = false
breakChainOnFirstMethodDot = true
configStyleArguments = true
blankLineBeforeDocstring = true
forceBlankLineBeforeDocstring = false
}

runner {
optimizer {
# Set to -1 to disable. Number of characters needed to trigger "config-style" formatting
# see: http://scalameta.org/scalafmt/#runner.optimizer.forceConfigStyleOnOffset
forceConfigStyleOnOffset = 150

# minimum number of func arguments before config-style (look at top of file) is enabled
forceConfigStyleMinArgCount = 2
}
newlines {
source = keep
afterCurlyLambdaParams = preserve
beforeCurlyLambdaParams = multilineWithCaseOnly
topLevelBodyIfMinStatements = []
}

lineEndings=preserve

0 comments on commit d2f8ed1

Please sign in to comment.