Skip to content

Commit

Permalink
add git workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei.winitzki committed Nov 22, 2023
1 parent 1c90593 commit e768cbc
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 1 deletion.
60 changes: 60 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
jobs:
build:
name: Build
needs:
- checks
runs-on: ubuntu-latest
steps:
- uses: "actions/checkout@v2"
with:
submodules: 'true'
- name: "~/.sbt\n\"~/.cache/coursier\"\n cache"
uses: "actions/cache@v3"
with:
key: "${{ runner.os }}-sbt-${{ hashFiles('build.sbt', 'project/plugins.sbt', 'project/build.properties') }}"
path: |
~/.sbt
"~/.cache/coursier"
restore-keys: |
${{ runner.os }}-sbt
- name: "java ${{ matrix.java}} setup"
uses: "actions/[email protected]"
with:
architecture: x64
java-package: jdk
java-version: "${{ matrix.java}}"
- run: "sbt -DJDK_VERSION=${{ matrix.java}} \"++${{ matrix.scala}} test\""
strategy:
matrix:
java:
- '8.0.382'
- '11.0.21'
- '17.0.9'
scala:
- '2.13.11'
checks:
name: Check formatting
runs-on: ubuntu-latest
steps:
- uses: "actions/checkout@v2"
with:
submodules: 'true'
- name: "~/.sbt\n\"~/.cache/coursier\"\n cache"
uses: "actions/cache@v3"
with:
key: "${{ runner.os }}-sbt-${{ hashFiles('build.sbt', 'project/plugins.sbt', 'project/build.properties') }}"
path: |
~/.sbt
"~/.cache/coursier"
restore-keys: |
${{ runner.os }}-sbt
- name: java 17 setup
uses: "actions/[email protected]"
with:
architecture: x64
java-package: jdk
java-version: '17'
- run: sbt scalafmtCheckAll scalafmtSbtCheck
name: scall_build_and_test
on:
push: {}
18 changes: 18 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://scalameta.org/scalafmt/docs/configuration.html
version=3.7.17 # This is the version of the scalafmt formatter core.
runner.dialect=scala213 # May need to override this for some files.
preset=IntelliJ
maxColumn = 160
align.preset=most
rewrite.trailingCommas.style = multiple
rewrite.trailingCommas.allowFolding = true
verticalMultiline.arityThreshold = 5
verticalMultiline.newlineAfterOpenParen = true
rewriteTokens = {
"⇒": "=>"
"→": "->"
"←": "<-"
}
importSelectors = singleLine
optIn.breakChainOnFirstMethodDot = false
optIn.breaksInsideChains = true
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# sofp-solutions

Solutions for exercises in the book "Science of functional programming"

Solutions for each chapter is a submodule in this project.

Common code may be put into the `common` submodule.
2 changes: 1 addition & 1 deletion chapter01/src/test/scala/sofp/unit/Exercise1.1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import munit.FunSuite
class Exercise1_1 extends FunSuite {

test("exercise 1.1") {
expect(1 == 0)
expect(0 == 0)
}

}
56 changes: 56 additions & 0 deletions github-scala-build-and-test.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
let GithubActions =
https://regadas.dev/github-actions-dhall/package.dhall
sha256:71df44892a17abca817cfb35e2612d117f7fceec55114a6eb76b65a7eea4e6f4

let matrix =
toMap { java = [ "8.0.382", "11.0.21", "17.0.9" ], scala = [ "2.13.11" ] }

let setup =
[ GithubActions.steps.actions/checkout // { `with` = Some (toMap { submodules = "true" }) }
, GithubActions.steps.actions/cache
{ path =
''
~/.sbt
"~/.cache/coursier"
''
, key = "sbt"
, hashFiles =
[ "build.sbt"
, "project/plugins.sbt"
, "project/build.properties"
]
}
]

in GithubActions.Workflow::{
, name = "scall_build_and_test"
, on = GithubActions.On::{
, push = Some GithubActions.Push::{=}
--, pull_request = Some GithubActions.PullRequest::{=}
}
, jobs = toMap
{ checks = GithubActions.Job::{
, name = Some "Check formatting"
, runs-on = GithubActions.types.RunsOn.ubuntu-latest
, steps =
setup
# [ GithubActions.steps.actions/setup-java { java-version = "17" }
, GithubActions.steps.run
{ run = "sbt scalafmtCheckAll scalafmtSbtCheck" }
]
}
, build = GithubActions.Job::{
, name = Some "Build"
, needs = Some [ "checks" ]
, strategy = Some GithubActions.Strategy::{ matrix }
, runs-on = GithubActions.types.RunsOn.ubuntu-latest
, steps =
setup
# [ GithubActions.steps.actions/setup-java
{ java-version = "\${{ matrix.java}}" }
, GithubActions.steps.run
{ run = "sbt -DJDK_VERSION=\${{ matrix.java}} \"++\${{ matrix.scala}} test\"" }
]
}
}
}
1 change: 1 addition & 0 deletions reformat_all_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt scalafmtAll scalafmtSbt
1 change: 1 addition & 0 deletions update_github_actions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dhall-to-yaml --file github-scala-build-and-test.dhall > .github/workflows/build-and-test.yml

0 comments on commit e768cbc

Please sign in to comment.