-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//> using scala "3.1.2" | ||
//> using lib "com.lihaoyi::os-lib:0.8.0" | ||
import scala.util.Properties | ||
|
||
val platformSuffix: String = { | ||
val os = | ||
if (Properties.isWin) "pc-win32" | ||
else if (Properties.isLinux) "pc-linux" | ||
else if (Properties.isMac) "apple-darwin" | ||
else sys.error(s"Unrecognized OS: ${sys.props("os.name")}") | ||
os | ||
} | ||
val artifactsPath = os.Path("artifacts", os.pwd) | ||
val destPath = | ||
if (Properties.isWin) artifactsPath / s"ls-$platformSuffix.exe" | ||
else artifactsPath / s"ls-$platformSuffix" | ||
val scalaCLILauncher = | ||
if (Properties.isWin) "scala-cli.bat" else "scala-cli" | ||
|
||
os.makeDir(artifactsPath) | ||
os.proc(scalaCLILauncher, "package", ".", "-o", destPath, "--native-image") | ||
.call(cwd = os.pwd) | ||
.out | ||
.text() | ||
.trim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "v*" | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.OS }} | ||
strategy: | ||
matrix: | ||
OS: ["ubuntu-latest", "macos-latest", "windows-latest"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: coursier/cache-action@v6.3 | ||
- uses: VirtusLab/scala-cli-setup@v0.1 | ||
- run: scala-cli test . | ||
- name: Package app | ||
run: scala-cli .github/scripts/package.sc | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: launchers | ||
path: artifacts | ||
if-no-files-found: error | ||
retention-days: 2 | ||
|
||
format: | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: coursier/cache-action@v6.3 | ||
- uses: VirtusLab/scala-cli-setup@v0.1 | ||
- name: Scalafmt check | ||
run: | | ||
scala-cli fmt --check . || ( | ||
echo "To format code run" | ||
echo " scala-cli fmt ." | ||
exit 1 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
version = 3.5.2 | ||
runner.dialect = scala3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//> using scala "3.1.2" | ||
//> using lib "com.lihaoyi::os-lib:0.8.0" | ||
|
||
@main def hello(args: String*) = | ||
val path = args.headOption match | ||
case Some(p) => os.Path(p, os.pwd) | ||
case _ => os.pwd | ||
|
||
if (os.isDir(path)) println(os.list(path).mkString(",")) | ||
else System.err.println("Expected directory path as an input") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//> using lib "org.scalameta::munit::0.7.27" | ||
|
||
import scala.util.Properties | ||
|
||
class TestsLs extends munit.FunSuite { | ||
test("ls") { | ||
// prepare test directory | ||
val tempDir = os.temp.dir() | ||
// create files | ||
val expectedFiles = Seq("Ls", "Hello").map(tempDir / _) | ||
expectedFiles.foreach(os.write(_, "Hello")) | ||
|
||
// check | ||
val scalaCLILauncher = | ||
if (Properties.isWin) "scala-cli.bat" else "scala-cli" | ||
val foundFiles = | ||
os.proc(scalaCLILauncher, "Ls.scala", "--", tempDir) | ||
.call() | ||
.out | ||
.text() | ||
.trim | ||
|
||
expectedFiles.map(_.toString).foreach { file => | ||
assert(foundFiles.contains(file)) | ||
} | ||
} | ||
} |