-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from xuwei-k/playwright-test
add playwright test
- Loading branch information
Showing
9 changed files
with
486 additions
and
61 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 |
---|---|---|
|
@@ -5,10 +5,14 @@ on: | |
workflow_dispatch: | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
runs-on: "${{ matrix.os }}" | ||
timeout-minutes: 20 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- "ubuntu-latest" | ||
- "macos-latest" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
|
@@ -29,7 +33,7 @@ jobs: | |
updateClassifiers | ||
test | ||
copyFilesFull | ||
- if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' && github.repository_owner == 'xuwei-k' }} | ||
- if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' && github.repository_owner == 'xuwei-k' && matrix.os == 'ubuntu-latest' }} | ||
uses: JamesIves/[email protected] | ||
with: | ||
branch: gh-pages | ||
|
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
57 changes: 57 additions & 0 deletions
57
localServer/src/main/scala/scalameta_ast/LocalServer.scala
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,57 @@ | ||
package scalameta_ast | ||
|
||
import unfiltered.jetty.Server | ||
import unfiltered.request.Path | ||
import unfiltered.response.HtmlContent | ||
import unfiltered.response.JsContent | ||
import unfiltered.response.JsonContent | ||
import unfiltered.response.NotFound | ||
import unfiltered.response.Ok | ||
import unfiltered.response.ResponseString | ||
import java.io.File | ||
import java.nio.charset.StandardCharsets | ||
import java.nio.file.Files | ||
import java.time.LocalDateTime | ||
import java.time.format.DateTimeFormatter | ||
import scala.annotation.nowarn | ||
|
||
@nowarn("msg=a type was inferred to be") | ||
object LocalServer { | ||
|
||
def server(log: Boolean): Server = { | ||
unfiltered.jetty.Server.anylocal.plan( | ||
unfiltered.filter.Planify { case Path(p) => | ||
if (log) { | ||
println(s"${DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(LocalDateTime.now())} ${p}") | ||
} | ||
val f = new File("sources", if (p == "/") "index.html" else s".$p") | ||
if (f.isFile) { | ||
val path = f.toPath | ||
val res = ResponseString(Files.readString(path, StandardCharsets.UTF_8)) | ||
p.split('.') | ||
.lastOption | ||
.collect { | ||
case "html" => | ||
HtmlContent | ||
case "js" => | ||
JsContent | ||
case "json" => | ||
JsonContent | ||
} | ||
.map(_ ~> res) | ||
.getOrElse(res) | ||
} else if (p == "/favicon.ico") { | ||
Ok | ||
} else { | ||
NotFound | ||
} | ||
} | ||
) | ||
} | ||
|
||
def main(args: Array[String]): Unit = { | ||
server(log = true).run { svr => | ||
unfiltered.util.Browser.open(svr.portBindings.head.url) | ||
} | ||
} | ||
} |
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,9 @@ | ||
Defn.Def( | ||
Nil, | ||
Term.Name("a"), | ||
Nil, | ||
Nil, | ||
None, | ||
Term.Name("b") | ||
) | ||
|
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,36 @@ | ||
package fix | ||
|
||
import scala.meta.Defn | ||
import scala.meta.Term | ||
import scalafix.Patch | ||
import scalafix.lint.Diagnostic | ||
import scalafix.lint.LintSeverity | ||
import scalafix.v1.SemanticDocument | ||
import scalafix.v1.SemanticRule | ||
|
||
class Example extends SemanticRule("Example") { | ||
override def fix(implicit | ||
doc: SemanticDocument | ||
): Patch = { | ||
doc.tree.collect { | ||
case t @ Defn.Def( | ||
Nil, | ||
Term.Name("a"), | ||
Nil, | ||
Nil, | ||
None, | ||
Term.Name("b") | ||
) => | ||
Patch.lint( | ||
Diagnostic( | ||
id = "", | ||
message = "", | ||
position = t.pos, | ||
explanation = "", | ||
severity = LintSeverity.Warning | ||
) | ||
) | ||
}.asPatch | ||
} | ||
} | ||
|
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,36 @@ | ||
package fix | ||
|
||
import scala.meta.Defn | ||
import scala.meta.Term | ||
import scalafix.Patch | ||
import scalafix.lint.Diagnostic | ||
import scalafix.lint.LintSeverity | ||
import scalafix.v1.SyntacticDocument | ||
import scalafix.v1.SyntacticRule | ||
|
||
class Example extends SyntacticRule("Example") { | ||
override def fix(implicit | ||
doc: SyntacticDocument | ||
): Patch = { | ||
doc.tree.collect { | ||
case t @ Defn.Def( | ||
Nil, | ||
Term.Name("a"), | ||
Nil, | ||
Nil, | ||
None, | ||
Term.Name("b") | ||
) => | ||
Patch.lint( | ||
Diagnostic( | ||
id = "", | ||
message = "", | ||
position = t.pos, | ||
explanation = "", | ||
severity = LintSeverity.Warning | ||
) | ||
) | ||
}.asPatch | ||
} | ||
} | ||
|
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,12 @@ | ||
Seq( | ||
Token.BOF, | ||
Token.KwDef, | ||
Token.Space, | ||
Token.Ident("a"), | ||
Token.Space, | ||
Token.Equals, | ||
Token.Space, | ||
Token.Ident("b"), | ||
Token.EOF | ||
) | ||
|
Oops, something went wrong.