Giter Site home page Giter Site logo

scala-snippet-checker's Introduction

Scala Snippet Checker

A Github Action to run Scala Script snippet code in issues.

It detects scala code in issues and comments. Each snippet must be annotated with scala-cli after backtick.

In the background, it uses ScalaCLI to run Scala code.

Annotate snippet of code

There are a few ways to annotate snippet of code to run:

  • ```scala-cli
  • ```scala-cli args
  • ```scala scala-cli
  • ```scala ... scala-cli
  • ```scala ... scala-cli args

scala-cli keyword must be added to the end of header of a snippet. To pass arguments to ScalaCLI, add them after scala-cli.

Usage:

For now, it is only available in a Linux environment. Windows and MacOs will be supported in the future.

on:
  issue_comment:
    types: [created, edited]
  issues:
    types: [opened, edited]

jobs:
   snippet-runner:
     timeout-minutes: 2
     runs-on: "ubuntu-latest"
     steps:
     - uses: virtuslab/scala-snippet-checker@main

It is recommended to specify a low execution time in timeout minutes.

Examples

test03

```scala-cli
println("Hello30")
```

test02

```scala-cli
// using scala "3.1.0"
// using lib "com.lihaoyi::os-lib:0.7.8"

println(os.pwd)
println("Hello9")
```

will generate a new comment:

In: https://github.com/org/repo/issues/1 Found following snippets:


Snippet:

println("Hello30")

Output:

Compiling project (Scala 3.0.2, JVM)
Compiled project (Scala 3.0.2, JVM)
Hello30


Snippet:

// using scala "3.1.0"
// using lib "com.lihaoyi::os-lib:0.7.8"

println(os.pwd)
println("Hello9")

Output:

Compiling project (Scala 3.1.0, JVM)
Compiled project (Scala 3.1.0, JVM)
/home/runner/work/snippet-runner/snippet-runner
Hello9

Nightly checker

Use nightly checker to find the latest nightly that worked with the input snippet

โš ๏ธ For now, nightly checker works only with Scala 3

Annotate snippet of code for nightly checker

There are a few ways to annotate snippet of code to run:

  • ```scala-cli nightly-checker
  • ```scala-cli args nightly-checker
  • ```scala scala-cli nightly-checker
  • ```scala ... scala-cli nightly-checker
  • ```scala ... scala-cli args nightly-checker

Examples Nightly Checker


```scala-cli nightly-checker
//> using scala "3.1.2"
// //> using scala "3.1.1" // Last working stable version

def test() = {
  func(_ => Box(Seq.empty[String]) )
}

def func[R0](to0: Unit => R0): Unit = ???

trait JsonFormat[T]
object JsonFormat{
  implicit def immSeqFormat: JsonFormat[Seq[String]]  = ???

  implicit def iterableFormat: JsonFormat[Iterable[String]]   = ??? 
}

case class Box[A1: JsonFormat](elem: A1)
```

will generate a new comment:

In: https://github.com/org/repo/issues/1 Found following snippets:


Snippet:

//> using scala "3.1.2"
// //> using scala "3.1.1" // Last working stable version

def test() = {
 func(_ => Box(Seq.empty[String]) )
}

def func[R0](to0: Unit => R0): Unit = ???

trait JsonFormat[T]
object JsonFormat{
 implicit def immSeqFormat: JsonFormat[Seq[String]]  = ???

 implicit def iterableFormat: JsonFormat[Iterable[String]]   = ??? 
}

case class Box[A1: JsonFormat](elem: A1)

Output:

Found the latest nightly version working with the snippet code: 3.1.2-RC1-bin-20211213-8e1054e-NIGHTLY

scala-snippet-checker's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar lwronski avatar romanowski avatar tgodzik avatar web-flow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

lwronski

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.