Skip to content

Commit

Permalink
Merge pull request #72 from jtx1999/it
Browse files Browse the repository at this point in the history
Add it and report coverage
  • Loading branch information
owolabileg authored May 27, 2021
2 parents b60e5cd + 0b2a021 commit 215203a
Show file tree
Hide file tree
Showing 37 changed files with 786 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Report coverage

on:
push:
branches:
- '**' # any branch
pull_request:
branches:
- '**'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: '8'

- name: Build with Maven
run: mvn -B verify --file pom.xml

- name: Merge coverage
run: mvn jacoco:merge@merge-id -pl starts-core

- name: Report
run: mvn jacoco:report@report-id -pl starts-core

- name: Generate JaCoCo Badge
id: jacoco
uses: cicirello/jacoco-badge-generator@v2
with:
jacoco-csv-file: starts-core/target/site/jacoco-merged/jacoco.csv
generate-branches-badge: true

- name: Log coverage percentage
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
# Getting: RequestError [HttpError]: Resource not accessible by integration
# - name: Add comment to PR
# uses: actions/github-script@v4
# if: ${{ github.event_name == 'pull_request' }}
# with:
# github-token: ${{secrets.GITHUB_TOKEN}}
# script: |
# github.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: 'Statement coverage = ${{ steps.jacoco.outputs.coverage }}\n\nBranch coverage = ${{ steps.jacoco.outputs.branches }}'
# })
50 changes: 50 additions & 0 deletions starts-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,55 @@
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>report-id</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>
${project.build.directory}/jacoco-merged.exec
</dataFile>
<excludes>
<exclude>edu/illinois/starts/asm/**</exclude>
</excludes>
<outputDirectory>
${project.reporting.outputDirectory}/jacoco-merged
</outputDirectory>
</configuration>
</execution>
<execution>
<id>merge-id</id>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<directory>
${project.basedir}/../
</directory>
<includes>
<include>starts-core/target/jacoco.exec</include>
<include>starts-plugin/target/jacoco-it.exec</include>
</includes>
</fileSet>
</fileSets>
<destFile>
${project.build.directory}/jacoco-merged.exec
</destFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
18 changes: 18 additions & 0 deletions starts-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>pre-integration-test-execution</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
<propertyName>invoker.mavenOpts</propertyName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
21 changes: 21 additions & 0 deletions starts-plugin/src/it/multilevel-interfaces-it/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2015 - Present. The STARTS Team. All Rights Reserved.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>starts.plugin.it</groupId>
<artifactId>parent-pom</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../parent-pom.xml</relativePath>
</parent>

<artifactId>multilevel-interfaces-it</artifactId>
<description>This integration test checks that the tests selected are only those
that reach a changed class or it's subclasses, but neither tests of
unrelated siblings nor superclasses.</description>
</project>
9 changes: 9 additions & 0 deletions starts-plugin/src/it/multilevel-interfaces-it/setup.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright (c) 2015 - Present. The STARTS Team. All Rights Reserved.
*/

import edu.illinois.starts.jdeps.SetupUtil;

setupUtil = new SetupUtil(new File(basedir, ".starts/deps.zlc"))
file = new File(basedir, "src/main/java/inter/BaseB.java");
setupUtil.replaceAllInFile(file, "List", "ArrayList")
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2015 - Present. The STARTS Team. All Rights Reserved.
*/

package inter;

import java.util.List;

public interface BaseA {
public List<String> toStringsBaseA();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package inter;

import java.util.List;

public interface BaseB {
public List<String> toStringsBaseB();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2015 - Present. The STARTS Team. All Rights Reserved.
*/

package inter;


import java.util.ArrayList;
import java.util.Arrays;

public class Child implements BaseA, BaseB {
@Override
public ArrayList<String> toStringsBaseA() {
return new ArrayList<>(Arrays.asList("BaseA", "child"));
}

@Override
public ArrayList<String> toStringsBaseB() {
return new ArrayList<>(Arrays.asList("BaseB", "child"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2015 - Present. The STARTS Team. All Rights Reserved.
*/

package inter;

import java.util.ArrayList;
import java.util.Arrays;

public class GrandChild extends Child {
@Override
public ArrayList<String> toStringsBaseA(){
return new ArrayList<>(Arrays.asList("BaseA", "GrandChild"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2015 - Present. The STARTS Team. All Rights Reserved.
*/

package inter;

import java.util.ArrayList;
import java.util.Arrays;

public class Sibling implements BaseA {

@Override
public ArrayList<String> toStringsBaseA() {
return new ArrayList<>(Arrays.asList("sibling"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2015 - Present. The STARTS Team. All Rights Reserved.
*/

package inter;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import static org.junit.Assert.assertEquals;

public class ChildTest {
@Test
public void test() {
assertEquals("1", new ArrayList<>(Arrays.asList("BaseA", "child")), new Child().toStringsBaseA());
assertEquals("2", new ArrayList<>(Arrays.asList("BaseB", "child")), new Child().toStringsBaseB());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2015 - Present. The STARTS Team. All Rights Reserved.
*/

package inter;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set;
import static org.junit.Assert.assertEquals;

public class GrandChildTest {
@Test
public void test() {
assertEquals("1", new ArrayList<>(Arrays.asList("BaseA", "GrandChild")), new GrandChild().toStringsBaseA());
assertEquals("2", new ArrayList<>(Arrays.asList("BaseB", "child")), new GrandChild().toStringsBaseB());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2015 - Present. The STARTS Team. All Rights Reserved.
*/

package inter;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set;
import static org.junit.Assert.assertEquals;

public class SiblingTest {
@Test
public void test() {
assertEquals("1", new ArrayList<>(Arrays.asList("sibling")), new Sibling().toStringsBaseA());
}
}
23 changes: 23 additions & 0 deletions starts-plugin/src/it/multilevel-interfaces-it/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2015 - Present. The STARTS Team. All Rights Reserved.
*/

import edu.illinois.starts.jdeps.VerifyUtil;

firstRun = new File(basedir, "first-run.txt");
verifyUtil = new VerifyUtil(new File(basedir, "build.log"));

if (!firstRun.exists()) {
firstRun.createNewFile();
verifyUtil.assertCorrectlyAffected("3");
verifyUtil.assertContains("Running inter.ChildTest");
verifyUtil.assertContains("Running inter.SiblingTest");
verifyUtil.assertContains("Running inter.GrandChildTest");
} else {
verifyUtil.assertCorrectlyAffected("2");
verifyUtil.assertContains("Running inter.ChildTest");
verifyUtil.assertNotContains("Running inter.SiblingTest");
verifyUtil.assertContains("Running inter.GrandChildTest");
verifyUtil.deleteFile(firstRun);
verifyUtil.deleteFile(new File(basedir, ".starts/deps.zlc"));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2015 - Present. The STARTS Team. All Rights Reserved.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>starts.plugin.it</groupId>
<artifactId>parent-pom</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../parent-pom.xml</relativePath>
</parent>

<artifactId>multilevel-no-parents-or-siblings-it</artifactId>
<description>This integration test checks that the tests selected are only those
that reach a changed class or it's subclasses, but neither tests of
unrelated siblings nor superclasses.</description>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>touch</id>
<phase>validate</phase>
<goals>
<goal>starts</goal>
</goals>
<configuration>
<depFormat>CLZ</depFormat>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright (c) 2015 - Present. The STARTS Team. All Rights Reserved.
*/

import edu.illinois.starts.jdeps.SetupUtil;

setupUtil = new SetupUtil(new File(basedir, ".starts/deps.zlc"))
file = new File(basedir, "src/main/java/inter/Child.java");
setupUtil.replaceAllInFile(file, "Set<Integer>", "Set")
Loading

0 comments on commit 215203a

Please sign in to comment.