Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rendering raports #290

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/buildExecuteCustom-A.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ jobs:
lastRC="$(./scripts/lastVersionRC.sc)"
lastStable=$(./scripts/lastVersionStable.sc)

scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion > raport-full.md
scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion --compareWith=$lastRC > raport-compare-$lastRC.md
scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion --compareWith=$lastStable > raport-compare-$lastStable.md
FOR_HTML=1 scala-cli scripts/raport-regressions.scala -- $scalaVersion > rendered.raport-full.md
scala-cli scripts/raport-regressions.scala -- $scalaVersion > raport-full.md
scala-cli scripts/raport-regressions.scala -- $scalaVersion --compareWith=$lastRC > raport-compare-$lastRC.md
scala-cli scripts/raport-regressions.scala -- $scalaVersion --compareWith=$lastStable > raport-compare-$lastStable.md

- name: Upload raports
uses: actions/upload-artifact@v3
Expand All @@ -87,6 +88,6 @@ jobs:
uses: ./.github/actions/push-raport-to-gh-pages
with:
artifact-name: build-raports
file-to-pick: raport-full.md
file-to-pick: rendered.raport-full.md
build-title: ${{ needs.execute-build-plan.outputs.used-scala-version }}
token: ${{ steps.generate-token.outputs.token }}
9 changes: 5 additions & 4 deletions .github/workflows/buildExecuteCustom-B.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ jobs:
lastRC="$(./scripts/lastVersionRC.sc)"
lastStable=$(./scripts/lastVersionStable.sc)

scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion > raport-full.md
scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion --compareWith=$lastRC > raport-compare-$lastRC.md
scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion --compareWith=$lastStable > raport-compare-$lastStable.md
FOR_HTML=1 scala-cli scripts/raport-regressions.scala -- $scalaVersion > rendered.raport-full.md
scala-cli scripts/raport-regressions.scala -- $scalaVersion > raport-full.md
scala-cli scripts/raport-regressions.scala -- $scalaVersion --compareWith=$lastRC > raport-compare-$lastRC.md
scala-cli scripts/raport-regressions.scala -- $scalaVersion --compareWith=$lastStable > raport-compare-$lastStable.md

- name: Upload raports
uses: actions/upload-artifact@v3
Expand All @@ -87,6 +88,6 @@ jobs:
uses: ./.github/actions/push-raport-to-gh-pages
with:
artifact-name: build-raports
file-to-pick: raport-full.md
file-to-pick: rendered.raport-full.md
build-title: ${{ needs.execute-build-plan.outputs.used-scala-version }}
token: ${{ steps.generate-token.outputs.token }}
14 changes: 8 additions & 6 deletions .github/workflows/buildExecuteScheduledWeekly-A.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,17 @@ jobs:
lastRC="$(./scripts/lastVersionRC.sc)"
lastStable=$(./scripts/lastVersionStable.sc)

scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion > raport-full.md
scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion --compareWith=$lastRC > raport-compare-$lastRC.md
scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion --compareWith=$lastStable > raport-compare-$lastStable.md
FOR_HTML=1 scala-cli scripts/raport-regressions.scala -- $scalaVersion > rendered.raport-full.md
scala-cli scripts/raport-regressions.scala -- $scalaVersion > raport-full.md
scala-cli scripts/raport-regressions.scala -- $scalaVersion --compareWith=$lastRC > raport-compare-$lastRC.md
scala-cli scripts/raport-regressions.scala -- $scalaVersion --compareWith=$lastStable > raport-compare-$lastStable.md

lastWeeklyVersionFile=./last-successfull-weekly-version
if [[ -f "$lastWeeklyVersionFile" ]]; then
lastWeeklyVersion=$(cat $lastWeeklyVersionFile)
echo "Comparing with last foundly weekly version: ${lastWeeklyVersion}"
scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion --compareWith=$lastWeeklyVersion > raport-compare-$lastWeeklyVersion.md
echo "Comparing with last found weekly version: ${lastWeeklyVersion}"
scala-cli scripts/raport-regressions.scala -- $scalaVersion --compareWith=$lastWeeklyVersion > raport-compare-$lastWeeklyVersion.md
scala-cli scripts/compareVersions.scala -- $scalaVersion $lastWeeklyVersion > raport-cmp-$lastWeeklyVersion.md
else
echo "Not found previous weekly build version."
fi
Expand All @@ -105,6 +107,6 @@ jobs:
uses: ./.github/actions/push-raport-to-gh-pages
with:
artifact-name: build-raports
file-to-pick: raport-full.md
file-to-pick: rendered.raport-full.md
build-title: ${{ needs.execute-build-plan.outputs.used-scala-version }}
token: ${{ steps.generate-token.outputs.token }}
14 changes: 8 additions & 6 deletions .github/workflows/buildExecuteScheduledWeekly-B.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,17 @@ jobs:
lastRC="$(./scripts/lastVersionRC.sc)"
lastStable=$(./scripts/lastVersionStable.sc)

scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion > raport-full.md
scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion --compareWith=$lastRC > raport-compare-$lastRC.md
scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion --compareWith=$lastStable > raport-compare-$lastStable.md
FOR_HTML=1 scala-cli scripts/raport-regressions.scala -- $scalaVersion > rendered.raport-full.md
scala-cli scripts/raport-regressions.scala -- $scalaVersion > raport-full.md
scala-cli scripts/raport-regressions.scala -- $scalaVersion --compareWith=$lastRC > raport-compare-$lastRC.md
scala-cli scripts/raport-regressions.scala -- $scalaVersion --compareWith=$lastStable > raport-compare-$lastStable.md

lastWeeklyVersionFile=./last-successfull-weekly-version
if [[ -f "$lastWeeklyVersionFile" ]]; then
lastWeeklyVersion=$(cat $lastWeeklyVersionFile)
echo "Comparing with last foundly weekly version: ${lastWeeklyVersion}"
scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion --compareWith=$lastWeeklyVersion > raport-compare-$lastWeeklyVersion.md
echo "Comparing with last found weekly version: ${lastWeeklyVersion}"
scala-cli scripts/raport-regressions.scala -- $scalaVersion --compareWith=$lastWeeklyVersion > raport-compare-$lastWeeklyVersion.md
scala-cli scripts/compareVersions.scala -- $scalaVersion $lastWeeklyVersion > raport-cmp-$lastWeeklyVersion.md
else
echo "Not found previous weekly build version."
fi
Expand All @@ -105,6 +107,6 @@ jobs:
uses: ./.github/actions/push-raport-to-gh-pages
with:
artifact-name: build-raports
file-to-pick: raport-full.md
file-to-pick: rendered.raport-full.md
build-title: ${{ needs.execute-build-plan.outputs.used-scala-version }}
token: ${{ steps.generate-token.outputs.token }}
23 changes: 0 additions & 23 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,3 @@ jobs:
- name: Test build
run: scripts/test-build.sh

test-cli:
runs-on: ubuntu-22.04
steps:
- name: Git Checkout
uses: actions/checkout@v3

- uses: coursier/setup-action@v1
with:
apps: scala sbt mill:0.11.5 scala-cli:1.0.4

- name: Start minikube
run: minikube start

- name: Build up base docker images
env:
BUILD_ONLY_DEFAULT_JDK: true
run: |
eval $(minikube -p minikube docker-env)
scripts/build-all.sh test

- name: Test CLI
run: scripts/test-cli.sh

4 changes: 2 additions & 2 deletions .github/workflows/compare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
ES_USER: ${{ secrets.OPENCB_ELASTIC_USER }}
ES_PASSWORD: ${{ secrets.OPENCB_ELASTIC_PSWD }}
run: |
scala-cli scripts/raport-regressions.scala scripts/console_printer.scala -- \
scala-cli scripts/raport-regressions.scala -- \
${{ inputs.scala-version }} \
--compareWith=${{ inputs.compare-with-scala-version }} \
--buildId=${{ inputs.build-id }} \
Expand All @@ -58,7 +58,7 @@ jobs:
ES_PASSWORD: ${{ secrets.OPENCB_ELASTIC_PSWD }}
run: |
scalaVersion=${{ inputs.scala-version }}
scala-cli scripts/raport-regressions.scala scripts/md_printer.scala -- $scalaVersion > raport-full.md
FOR_HTML=1 scala-cli scripts/raport-regressions.scala -- $scalaVersion > raport-full.md

- name: Upload raports
uses: actions/upload-artifact@v3
Expand Down
18 changes: 0 additions & 18 deletions scripts/console_printer.scala

This file was deleted.

19 changes: 0 additions & 19 deletions scripts/md_printer.scala

This file was deleted.

63 changes: 61 additions & 2 deletions scripts/raport-regressions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import scala.concurrent.duration.*
import org.elasticsearch.client.RestClient
import org.apache.http.HttpHost

import Printer.{println, *}
val printer: Printer =
if sys.env.contains("FOR_HTML") then Printer.HTMLCompatPrinter
else Printer.StandardPrinter
import printer.{println, *}

given ExecutionContext = ExecutionContext.global

Expand Down Expand Up @@ -266,7 +269,7 @@ def listFailedProjects(
val name = label.padTo(8, " ").mkString
val ver = projectVersions(project)
println(
s"$color$name${RESET} failure in ${BOLD}${Printer
s"$color$name${RESET} failure in ${BOLD}${printer
.projectUrlString(project.name, ver, buildURL)}$LINE_BREAK"
)
val compilerFailure = summary.compilerFailure
Expand Down Expand Up @@ -533,3 +536,59 @@ def isVersionNewerThen(version: String, reference: String) =
end isVersionNewerThen
def isVersionNewerOrEqualThen(version: String, reference: String) =
version == reference || isVersionNewerThen(version, reference)


sealed trait Printer{
import scala.Console
def RED: String
def YELLOW: String
def MAGENTA: String
def RESET :String
def BOLD :String
def LINE_BREAK : String

def println(text: String): Unit
def printLine(): Unit
def log(text: String): Unit
def showUrl(url: String, text: String): String

final def projectUrlString(projectName: String, version: String, buildUrl: String): String = {
val projectVerString = if version.isEmpty then projectName else s"$projectName @ $version"
if buildUrl.isEmpty then projectVerString
else showUrl(buildUrl, projectVerString)
}
}

object Printer{
object StandardPrinter extends Printer{
import scala.Console
override val RED = Console.RED
override val YELLOW = Console.YELLOW
override val MAGENTA = Console.MAGENTA
override val RESET = Console.RESET
override val BOLD = Console.BOLD
override val LINE_BREAK = ""

override def println(text: String): Unit = Predef.println(text)
override def log(text: String) = Predef.println(text)
override def printLine() = println("-" * 20)
override def showUrl(url: String, text: String): String =
s"$text - $url"
}


object HTMLCompatPrinter extends Printer{
override val RED = """<span style="color:red">"""
override val YELLOW = """<span style="color:yellow">"""
override val MAGENTA = """<span style="color:magenta">"""
override val RESET = """</span>"""
override val BOLD = """<span style="font-weight:bold">"""
override val LINE_BREAK = "<br>"

override def println(text: String): Unit = Predef.println(s"$text")
override def log(text: String) = System.err.println(s"$text")
override def printLine() = println("<hr>")
override def showUrl(url: String, text: String): String=
s"""<a href="$url">$text</a>"""
}
}
Loading