Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/dependency-graph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
name: Update Dependency Graph
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- uses: sbt/setup-sbt@v1
- uses: scalacenter/sbt-dependency-submission@v2
- uses: scalacenter/sbt-dependency-submission@v3
with:
working-directory: './'

48 changes: 40 additions & 8 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
name: pr
on: pull_request
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 1
- name: Set up JDK
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'
cache: 'sbt'
- name: Set up SBT
uses: sbt/setup-sbt@v1
- name: Check formatting
run: sbt "scalafmtCheckAll; scalafmtSbtCheck;"
- run: echo "Previous step failed because code is not formatted. Run 'sbt format'"
if: ${{ failure() }}

test-scroll:
needs: format
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
with:
fetch-depth: 1
- name: Set up JDK
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'
Expand All @@ -20,9 +40,21 @@ jobs:
uses: sbt/setup-sbt@v1
- name: Compile and run tests
run: sbt "clean; test;"
- name: Compile Jmh benchmarks
run: sbt "clean; benchmark/Jmh/compile;"
- name: Check formatting
run: sbt "scalafmtCheckAll; scalafmtSbtCheck;"
- run: echo "Previous step failed because code is not formatted. Run 'sbt format'"
if: ${{ failure() }}

jmh-compile:
needs: format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 1
- name: Set up JDK
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'
cache: 'sbt'
- name: Set up SBT
uses: sbt/setup-sbt@v1
- name: Compile JMH benchmarks
run: sbt "benchmark/Jmh/compile;"
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import org.eclipse.emf.ecore.xmi.XMLResource
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
import scroll.internal.errors.SCROLLErrors.CROMMetaModelLoadFailure
import scroll.internal.util.ResourceLoader

/** Trait providing functionality for importing ecore models.
*/
trait ECoreImporter {
private val META_MODEL_PATH = getClass.getResource("/crom_l1_composed.ecore").getPath
private val META_MODEL_PATH: String = ResourceLoader.resourcePath("/crom_l1_composed.ecore")

private def registerMetaModel(rs: ResourceSetImpl): Unit = {
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap
Expand Down
22 changes: 22 additions & 0 deletions core/src/main/scala/scroll/internal/util/ResourceLoader.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package scroll.internal.util

object ResourceLoader {

/** Returns a filesystem path to a classpath resource, extracting it to a temp file if it lives inside a JAR. */
def resourcePath(name: String, loader: ClassLoader = getClass.getClassLoader): String = {
val url = loader.getResource(name.stripPrefix("/"))
require(url != null, s"Classpath resource not found: $name")
if (url.getProtocol == "file") url.getPath
else {
val suffix = name.substring(name.lastIndexOf('.'))
val tmp = java.io.File.createTempFile("scroll-resource", suffix)
tmp.deleteOnExit()
val in = url.openStream()
val out = new java.io.FileOutputStream(tmp)
try in.transferTo(out)
finally { in.close(); out.close() }
tmp.getAbsolutePath
}
}

}
1 change: 1 addition & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sbt.CrossVersion
import sbt.moduleIDConfigurable
import sbt.stringToOrganization

object Dependencies extends Dependencies
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.12.13
sbt.version=2.0.1
7 changes: 3 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.3.1")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.3")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.8")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.6.1")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.3.1")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.8")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.6.1")
3 changes: 3 additions & 0 deletions tests/src/test/scala/scroll/tests/AbstractSCROLLTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package scroll.tests
import org.scalatest.matchers.should.Matchers
import org.scalatest.ParallelTestExecution
import org.scalatest.funsuite.AnyFunSuite
import scroll.internal.util.ResourceLoader

abstract class AbstractSCROLLTest extends AnyFunSuite with Matchers with ParallelTestExecution {

protected def streamToSeq(in: java.io.ByteArrayOutputStream, splitAt: String = System.lineSeparator()): Seq[String] =
in.toString.split(splitAt).toSeq

protected def resourcePath(name: String): String = ResourceLoader.resourcePath(name)

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CROITest extends AbstractParameterizedSCROLLTest {

test("CROI is filled manually") {
forAll(PARAMS) { (c: Boolean, cc: Boolean) =>
val p = getClass.getResource("/Bank.crom").getPath
val p = resourcePath("/Bank.crom")
new CompartmentUnderTest(c, cc) with CROI {
val n = new CoreA()
val r = new RoleA()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ECoreInstanceTest extends AbstractParameterizedSCROLLTest {
}

test("Loading from a valid path containing a valid model") {
val p = getClass.getResource("/Bank.crom").getPath
val p = resourcePath("/Bank.crom")
forAll(PARAMS) { (c: Boolean, cc: Boolean) =>
new CompartmentUnderTest(c, cc) with CROM {
wellformed(p) shouldBe true
Expand Down
Loading