Skip to content

Commit

Permalink
NODE-2553 Autocompilation task (#3806)
Browse files Browse the repository at this point in the history
  • Loading branch information
xrtm000 authored Jan 26, 2023
1 parent d9f5453 commit 29c8287
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/check-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ jobs:
path: ~/.cache/coursier
key: coursier-cache
- name: Check PR
run: |
sbt --mem 6144 --batch checkPR
find ~/.cache/coursier -type d -name '*SNAPSHOT' | xargs rm -vrf {} \;
run: sbt --mem 6144 --batch checkPR
- uses: dorny/paths-filter@v2
id: filter
with:
Expand All @@ -37,6 +35,20 @@ jobs:
- 'lang/**'
- 'build.sbt'
- 'project/*'
- name: Compile external sources
if: steps.filter.outputs.lang == 'true'
run: |
sbt lang/assembly
git clone https://github.com/waves-exchange/neutrino-contract
git clone https://github.com/waves-exchange/contracts
git clone https://oauth2:${{ secrets.DUCKS_GITHUB_TOKEN }}@github.com/akharazyan/wavesducks-public
git clone https://oauth2:${{ secrets.SWOPFI_GITLAB_TOKEN }}@gitlabwp.wvservices.com/swopfi/swopfi-smart-contracts
find neutrino-contract/script -name "*.ride" -type f -exec java -jar lang/jvm/target/file-compiler.jar {} +;
find contracts/ride -name "*.ride" -type f -exec java -jar lang/jvm/target/file-compiler.jar {} +;
find wavesducks-public/ride -name "*.ride" -type f -exec java -jar lang/jvm/target/file-compiler.jar {} +;
find swopfi-smart-contracts/dApps -name "*.ride" -type f -exec java -jar lang/jvm/target/file-compiler.jar {} +;
- name: Clean cache
run: find ~/.cache/coursier -type d -name '*SNAPSHOT' | xargs rm -vrf {} \;
- name: Prepare version
if: false # steps.filter.outputs.lang == 'true'
id: sbt-version
Expand Down
17 changes: 17 additions & 0 deletions lang/jvm/build.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
ThisProject / publishTo := sonatypePublishToBundle.value
ThisProject / publish / skip := false

inTask(assembly)(
Seq(
test := {},
assemblyJarName := s"file-compiler.jar",
assemblyMergeStrategy := {
case p if p.endsWith(".proto") || p.endsWith("module-info.class") || p.endsWith("io.netty.versions.properties") =>
MergeStrategy.discard
case "scala-collection-compat.properties" =>
MergeStrategy.discard
case p if Set("scala/util/control/compat", "scala/collection/compat").exists(p.replace('\\', '/').contains) =>
MergeStrategy.last
case other =>
(assembly / assemblyMergeStrategy).value(other)
}
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.wavesplatform.lang

import com.wavesplatform.lang.v1.estimator.v3.ScriptEstimatorV3

import java.nio.file.{Files, Paths}
import scala.jdk.CollectionConverters.*

object FileCompiler extends App {
private val estimator = ScriptEstimatorV3(true, false)
args
.foreach { path =>
val script = Files.readAllLines(Paths.get(path)).asScala.reduce(_ + "\n" + _)
API
.compile(script, estimator)
.fold(
error => throw new RuntimeException(s"$error while compiling $path"),
_ => println(s"successfully compiled $path")
)
}
}

0 comments on commit 29c8287

Please sign in to comment.