Skip to content

Commit fd15311

Browse files
committed
Test examples on CI
1 parent 0f33af5 commit fd15311

File tree

36 files changed

+52
-519
lines changed

36 files changed

+52
-519
lines changed

.github/scripts/check_examples.sc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//> using scala "3"
2+
//> using lib "com.lihaoyi::os-lib:0.8.0"
3+
4+
val toParse: Seq[os.Path] =
5+
if args.nonEmpty then args.map(p => os.pwd / os.RelPath(p))
6+
else os.list(os.pwd / "examples").filterNot(_.last.startsWith("."))
7+
8+
9+
val failed = toParse.filter { path =>
10+
val args =
11+
if !os.exists(path / ".opts") then Nil
12+
else os.read(path / ".opts").split(" ").toSeq
13+
14+
15+
println(s"Running $path")
16+
os.proc(os.pwd / "scala-cli-src", "--jvm", "temurin:17", args, path)
17+
.call(check = false).exitCode != 0
18+
}
19+
20+
if failed.isEmpty then println("Success!") else
21+
println("Failed examples:")
22+
failed.foreach(path => println(s" $path failed"))

.github/scripts/check_gifs.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ jobs:
202202
run: .github/scripts/check_docs.sh
203203
- name: Test gifs
204204
run: gifs/generate_gifs.sh $(ls gifs/scenarios/)
205+
- name: Check examples
206+
run: ./scala-cli-src --jvm temurin:17 .github/scripts/check_examples.sc
205207

206208
checks:
207209
timeout-minutes: 15

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ out/
55
.scala
66
.bsp
77
.idea/
8+
9+
*.semanticdb

examples/cross-build/.opts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--js --help

examples/cross-build/Hello.js.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//> using scala 2.13
2-
//> using target scala-js
1+
//> using scala "2.13"
2+
//> using target "scala-js"
33

44
import scala.scalajs.js
55

examples/cross-build/Hello.native.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//> using scala 2.13
2-
//> using target scala-native
1+
//> using scala "2.13"
2+
//> using target "scala-native"
33

44
import scala.scalanative.libc._
55
import scala.scalanative.unsafe._

examples/gists/Messages.scala

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/gists/README.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

examples/intro/README.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)