Skip to content

Commit

Permalink
Moved enabled tests counter to a separate executable
Browse files Browse the repository at this point in the history
  • Loading branch information
bugdea1er committed Nov 2, 2022
1 parent c4f445d commit 845f972
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 44 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/EnabledTestsCounter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Enabled tests counter

on:
push

jobs:
counter:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up JDK 14
uses: actions/setup-java@v2
with:
java-version: '14'
distribution: 'adopt'
- name: Build counter
run: mvn clean package -PEnabledTestsCounter -DskipTests
- name: Run counter
run: java -jar transpiler/target/transpiler-0.0.1-SNAPSHOT-jar-with-dependencies.jar
36 changes: 34 additions & 2 deletions .github/workflows/IntegrationTests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- cron: '30 18 * * 1'

jobs:
Verify:
ParserPrinter:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
Expand All @@ -19,4 +19,36 @@ jobs:
with:
python-version: '3.8.10'
- name: Run integration tests
run: mvn clean verify -B
run: mvn clean verify -B -Dit.test=ParserPrinterIT

CPython:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up JDK 14
uses: actions/setup-java@v2
with:
java-version: '14'
distribution: 'adopt'
- name: Set up Python 3.8.10
uses: actions/setup-python@v2
with:
python-version: '3.8.10'
- name: Run integration tests
run: mvn clean verify -B -Dit.test=CPythonIT

Django:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up JDK 14
uses: actions/setup-java@v2
with:
java-version: '14'
distribution: 'adopt'
- name: Set up Python 3.8.10
uses: actions/setup-python@v2
with:
python-version: '3.8.10'
- name: Run integration tests
run: mvn clean verify -B -Dit.test=DjangoIT
18 changes: 1 addition & 17 deletions .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,11 @@ name: Java CI
on: [push]

jobs:
build:
strategy:
matrix:
os: [ ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up JDK 14
uses: actions/setup-java@v2
with:
java-version: '14'
distribution: 'adopt'
- name: Build with Maven
run: mvn clean compile -B

test:
Tests:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
needs: build
steps:
- uses: actions/checkout@v2
- name: Set up JDK 14
Expand Down
42 changes: 36 additions & 6 deletions transpiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,50 @@ SOFTWARE.
<artifactId>scala-reflect</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.32</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>EnabledTestsCounter</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.polystat.py2eo.transpiler.EnabledTestsCounter</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package org.polystat.py2eo.transpiler

import org.junit.jupiter.api.Test
import java.io.FileInputStream
import scala.reflect.io.{File, Path}
import org.yaml.snakeyaml.Yaml

import scala.reflect.io.Path

class TestEnabledCounter extends Commons {
private val testsPath: Path = "src/test/resources/org/polystat/py2eo/transpiler/simple-tests"
object EnabledTestsCounter {
private val testsPath: Path = "transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests"

case class TestResult(name: String, category: String, enabled: Boolean)

@Test
def apply(): Unit = {
def main(args: Array[String]): Unit = {
val tests = testsPath.toDirectory.deepFiles.toSet
val results = for {
test <- tests
if !test.name.startsWith("eo_blocked")
if test.extension == "yaml"
if !isModule(test)
} yield TestResult(test.name, test.parent.name, isEnabled(test))

val total = results.size
Expand All @@ -36,4 +34,12 @@ class TestEnabledCounter extends Commons {
val percentage = constructionsResults.sum / constructionsResults.size
println(s"total constructions passed: $percentage%")
}
}

private def isEnabled(f: File): Boolean = {
val yaml = new Yaml()
val map = yaml.load[java.util.Map[String, String]](new FileInputStream(f.jfile))

map.containsKey("enabled") && map.getOrDefault("enabled", "false").asInstanceOf[Boolean]
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ trait Commons {
}

def isEnabled(file: File): Boolean = yaml2pythonModel(file.jfile).enabled
def isModule(file: File): Boolean = yaml2pythonModel(file.jfile).isModule

def collect(dir: Directory, filterEnabled: Boolean = false): Array[File] = {
val allYamlFiles = dir.deepFiles.filter(_.extension == "yaml").toArray
Expand Down

0 comments on commit 845f972

Please sign in to comment.