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

Add diesel support, Update to Scala 3, disable rdf4j (scala bug) #3

Merged
merged 23 commits into from
Jun 26, 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
92 changes: 35 additions & 57 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,86 +17,76 @@ on:
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.1.3]
scala: [3]
java: [temurin@17]
project: [rootJS, rootJVM]
jsenv: [NodeJS]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download Java (temurin@17)
id: download-java-temurin-17
if: matrix.java == 'temurin@17'
uses: typelevel/download-java@v2
with:
distribution: temurin
java-version: 17

- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v3
with:
distribution: jdkfile
distribution: temurin
java-version: 17
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}
cache: sbt

- name: Cache sbt
uses: actions/cache@v3
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: Setup NodeJS v14 LTS
- name: sbt update
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: 'sbt ''project ${{ matrix.project }}'' ''++ ${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' reload +update'

- name: Setup NodeJS v16 LTS
if: matrix.project == 'rootJS' && matrix.jsenv == 'NodeJS'
uses: actions/setup-node@v2.4.0
uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16

- name: Check that workflows are up to date
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' ''project /'' githubWorkflowCheck'
run: sbt githubWorkflowCheck

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

- name: scalaJSLink
if: matrix.project == 'rootJS'
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' Test/scalaJSLinkerResult'
run: 'sbt ''project ${{ matrix.project }}'' ''++ ${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' Test/scalaJSLinkerResult'

- name: Test
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' test'
run: 'sbt ''project ${{ matrix.project }}'' ''++ ${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' test'

- name: Check binary compatibility
if: matrix.java == 'temurin@17'
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' mimaReportBinaryIssues'
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest' && matrix.jsenv == 'NodeJS'
run: 'sbt ''project ${{ matrix.project }}'' ''++ ${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' mimaReportBinaryIssues'

- name: Generate API documentation
if: matrix.java == 'temurin@17'
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' doc'
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest' && matrix.jsenv == 'NodeJS'
run: 'sbt ''project ${{ matrix.project }}'' ''++ ${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' doc'

dependency-submission:
name: Submit Dependencies
if: github.event_name != 'pull_request'
strategy:
matrix:
os: [ubuntu-latest]
scala: [3.1.3]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -105,33 +95,21 @@ jobs:
with:
fetch-depth: 0

- name: Download Java (temurin@17)
id: download-java-temurin-17
if: matrix.java == 'temurin@17'
uses: typelevel/download-java@v2
with:
distribution: temurin
java-version: 17

- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v3
with:
distribution: jdkfile
distribution: temurin
java-version: 17
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}
cache: sbt

- name: Cache sbt
uses: actions/cache@v3
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@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt reload +update

- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
with:
modules-ignore: root rootJS rootJVM rootNative
configs-ignore: test scala-tool scala-doc-tool
25 changes: 15 additions & 10 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
version = "3.4.1"
version = "3.7.4"
runner.dialect = scala3
indent {
main = 2
matchSite = 1
significant = 3
}
align {
preset = more // For pretty alignment.
stripMargin = true
preset = some
stripMargin = false
}
maxColumn = 100 //
maxColumn = 100
assumeStandardLibraryStripMargin = true
rewrite.scala3 {
convertToNewSyntax = true
removeOptionalBraces = yes
}
newlines{
runner.dialectOverride.allowQuestionMarkAsTypeWildcard = false
newlines {
selectChains = keep
beforeMultiline = keep
source=keep
}
optIn.breakChainOnFirstMethodDot = false
includeNoParensInSelectChains = false
comments.wrapSingleLineMlcAsSlc = false
docstrings{
wrap = "no"
oneline = fold
style = SpaceAsterisk
}

optIn.configStyleArguments = true
runner.optimizer.forceConfigStyleMinArgCount = 5

fileOverride {
"glob:**.sbt" {
Expand All @@ -39,4 +44,4 @@ fileOverride {
"glob:**/sbt-plugin/**.scala" {
runner.dialect = scala212source3
}
}
}
48 changes: 42 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
## Banana-Play
## Banana-RDF for Scala 3

This project is porting [banana-rdf](https://github.com/banana-rdf/banana-rdf)
to Scala3.

Thanks to the financial help by NlNet in the [solid-control](https://github.com/co-operating-systems/solid-control)
project.

### Artifacts

Artifacts can be found in the sonatype repository
https://oss.sonatype.org/content/repositories/snapshots/net/bblfish/rdf/

### Changes from banana-rdf 0.8

[Scala 3](https://docs.scala-lang.org/scala3/) comes with many new features, but dropped one too.

#### Match Types

The most important dropped features we were relying on was type projections. We replace those
with [match types](https://docs.scala-lang.org/scala3/reference/new-types/match-types.html#).
As a result code where we used to have (see [0.8.x GraphTest](../../tree/series/0.8.x/rdf-test-suite/shared/src/main/scala/org/w3/banana/GraphTest.scala#L11))

```scala
val foo1gr: Rdf#Graph = Graph(Triple(exuri(), rdf("foo"), Literal("foo")))
```

we now have ([see GraphTest](rdf-test-suite/shared/src/main/scala/org/w3/banana/GraphTest.scala#L75))

```scala
val foo1gr: Graph[Rdf] = Graph(Triple(exuri(), rdf("foo"), Literal("foo")))
```

#### Relative Uris, Triples and Graphs

We also make heavy use of [opaque types](https://docs.scala-lang.org/scala3/reference/other-new-features/opaques.html).
This allows us to keep the distinction between relative URLs (`rURI`), triples (`rTriple`) and Graphs (`rGraph`) and
the usual graphs understood by RDF with absolute urls. The type distinction we make in [RDF](rdf/shared/src/main/scala/org/w3/banana/RDF.scala) is then also translated by differences in the operations allowed. For example [operations.rGraph](rdf/shared/src/main/scala/org/w3/banana/operations/rGraph.scala) do not allow the union of two rGraphs but do have a method to resolve an rGraph against an AbsoluteUrl. On the other hand the [operations.Graph](rdf/shared/src/main/scala/org/w3/banana/operations/Graph.scala) allow one to take the union of two `Graph[Rdf]`. They have no method `resolveAgainst` but do have a method `relativizeAgainst` which produces an `rGraph`.

Making relative URLs more clearly visible in the type system makes it easier to write parsers and serialisers, since those do contain
relative URLs.


This is a project to port [banana-rdf](https://github.com/banana-rdf/banana-rdf)
to Scala3. [Scala 3](https://docs.scala-lang.org/scala3/) comes with many new features, and dropped one
of the most important ones we were relying on: type projections.
So this repository is trying to build up from scratch the framework,
to see what holds water, before moving it back to the main repository.

### Discussions

Expand Down
Loading