-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from winitzki/feature/add_ci
add git workflows
- Loading branch information
Showing
9 changed files
with
179 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/setup-java@v1.4.3" | ||
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/setup-java@v1.4.3" | ||
with: | ||
architecture: x64 | ||
java-package: jdk | ||
java-version: '17' | ||
- run: sbt scalafmtCheckAll scalafmtSbtCheck | ||
name: scall_build_and_test | ||
on: | ||
push: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
# 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. | ||
|
||
# Code formatting | ||
|
||
The GitHub job will verify that all code is properly formatted. | ||
|
||
To reformat code, run the script: | ||
|
||
`bash reformat_all_code.sh` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package sofp.unit | ||
|
||
import com.eed3si9n.expecty.Expecty.expect | ||
|
||
import munit.FunSuite | ||
|
||
class Exercises_1_6_1 extends FunSuite { | ||
|
||
test("exercise 1.6.1.1") { | ||
|
||
def staggeredFactorial(n: Int): Int = (n to 1 by -2).product | ||
|
||
expect(staggeredFactorial(8) == 384) | ||
expect(staggeredFactorial(9) == 945) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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\"" } | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt scalafmtAll scalafmtSbt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |