Skip to content

Commit

Permalink
added top level project building and reporting. Added action to build…
Browse files Browse the repository at this point in the history
… the gradle project
  • Loading branch information
davidparry committed Sep 7, 2024
1 parent 85da7c8 commit f0fb937
Show file tree
Hide file tree
Showing 14 changed files with 662 additions and 6 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Gradle Build and Test Cover Agent Plugin

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '21'

- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build and Test Cover Agent Plugin
working-directory: cover-agent-plugin
run: ../gradlew clean build --stacktrace --info

- name: Run Check for Cover Agent Plugin
working-directory: cover-agent-plugin
run: ../gradlew check

- name: Generate Jacoco Coverage Report
working-directory: cover-agent-plugin
run: ../gradlew jacocoTestReport

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results
path: cover-agent-plugin/build/test-results/test

- name: Upload Code Coverage Report
if: always()
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: cover-agent-plugin/build/reports/jacoco/test/html
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/cover-agent-plugin/.gradle/
/cover-agent-plugin/.idea/
/cover-agent-plugin/build/
/cover-agent-plugin/build/
/cover-agent-plugin/.java-version
/build/
/.idea/
/.gradle/
/cover-agent-plugin/reports/
/reports/
32 changes: 32 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
plugins {
id 'java'
id 'jacoco'
}

group = 'ai.codium'
version = '1.0.0'

repositories {
mavenCentral()
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
// Add other dependencies as needed
}

test {
useJUnitPlatform()
finalizedBy jacocoTestReport
}



check {
dependsOn test
}

build {
dependsOn check
}
170 changes: 170 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">


<module name="Checker">
<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
https://checkstyle.org/config.html#Checker
<property name="basedir" value="${basedir}"/>
-->
<property name="severity" value="error"/>

<property name="fileExtensions" value="java, properties, xml"/>

<!-- Excludes all 'module-info.java' files -->
<!-- See https://checkstyle.org/config_filefilters.html -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>

<!-- https://checkstyle.org/config_filters.html#SuppressionFilter ${config_loc} -->
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/suppressions.xml"/>
<property name="optional" value="true"/>
</module>

<!-- Checks that a package-info.java file exists for each package. -->
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
<!-- module name="JavadocPackage"/ -->

<!-- Checks whether files end with a new line. -->
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>

<!-- Checks that property files contain the same keys. -->
<!-- See https://checkstyle.org/config_misc.html#Translation -->
<module name="Translation"/>

<!-- Checks for Size Violations. -->
<!-- See https://checkstyle.org/config_sizes.html -->
<module name="FileLength"/>
<module name="LineLength">
<property name="max" value="120"/>
<property name="fileExtensions" value="java"/>
</module>

<!-- Checks for whitespace -->
<!-- See https://checkstyle.org/config_whitespace.html -->
<module name="FileTabCharacter"/>

<!-- Miscellaneous other checks. -->
<!-- See https://checkstyle.org/config_misc.html -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Line has trailing spaces."/>
</module>

<!-- Checks for Headers -->
<!-- See https://checkstyle.org/config_header.html -->
<!-- <module name="Header"> -->
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
<!-- <property name="fileExtensions" value="java"/> -->
<!-- </module> -->

<module name="TreeWalker">

<!-- Checks for Javadoc comments. -->
<!-- See https://checkstyle.org/config_javadoc.html -->
<module name="InvalidJavadocPosition"/>
<!-- module name="JavadocMethod"/>
<module name="JavadocType"/>
<module name="JavadocVariable"/ -->
<module name="JavadocStyle"/>
<!-- module name="MissingJavadocMethod"/ -->

<!-- Checks for Naming Conventions. -->
<!-- See https://checkstyle.org/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>

<!-- Checks for imports -->
<!-- See https://checkstyle.org/config_imports.html -->
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="false"/>
</module>

<!-- Checks for Size Violations. -->
<!-- See https://checkstyle.org/config_sizes.html -->
<module name="MethodLength"/>
<module name="ParameterNumber"/>

<!-- Checks for whitespace -->
<!-- See https://checkstyle.org/config_whitespace.html -->
<module name="EmptyForIteratorPad"/>
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>

<!-- Modifier Checks -->
<!-- See https://checkstyle.org/config_modifiers.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>

<!-- Checks for blocks. You know, those {}'s -->
<!-- See https://checkstyle.org/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>

<!-- Checks for common coding problems -->
<!-- See https://checkstyle.org/config_coding.html -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField">
<property name="tokens" value="VARIABLE_DEF, PATTERN_VARIABLE_DEF, LAMBDA, RECORD_COMPONENT_DEF" />
</module>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
<module name="MissingSwitchDefault"/>
<module name="MultipleVariableDeclarations"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>

<!-- Checks for class design -->
<!-- See https://checkstyle.org/config_design.html -->
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>

<!-- Miscellaneous other checks. -->
<!-- See https://checkstyle.org/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="TodoComment"/>
<module name="UpperEll"/>

<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
<module name="SuppressionXpathFilter">
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}"
default="checkstyle-xpath-suppressions.xml" />
<property name="optional" value="true"/>
</module>

</module>

</module>
12 changes: 12 additions & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress checks="[a-zA-Z0-9]*" files="Test"/>
<suppress checks="[a-zA-Z0-9]*" files="Spec"/>
<suppress files="CoverAgentExecutor.java" checks="FinalClass" />


</suppressions>
10 changes: 10 additions & 0 deletions config/findbugs/findbugs-filter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter
xmlns="https://github.com/spotbugs/filter/3.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">

<Match>
<Source name="integrationTest"/>
</Match>
</FindBugsFilter>
3 changes: 3 additions & 0 deletions config/findbugs/include.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<FindBugsFilter>
<Package name="ai.codium.cover.plugin.*"/>
</FindBugsFilter>
12 changes: 12 additions & 0 deletions config/pmd/pmd-ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>

<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="minimal-ruleset"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>
Minimal ruleset for testing purposes.
</description>

<rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace"/>
</ruleset>
29 changes: 24 additions & 5 deletions cover-agent-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.Confidence

import org.gradle.api.tasks.Delete
plugins {
id 'groovy'
id 'java-gradle-plugin'
Expand Down Expand Up @@ -52,7 +52,7 @@ gradlePlugin {
tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
reports {
html.required.set(true)
html.outputLocation.set(file("$buildDir/reports/spotbugs/spotbugs.html"))
html.outputLocation.set(file("$rootDir/build/reports/spotbugs/spotbugs.html"))
}
}

Expand All @@ -67,8 +67,10 @@ test {
ignoreFailures = false
}


checkstyle {
toolVersion '8.36.1'
toolVersion = '10.0' // Use the version you want
configFile = file("$rootDir/config/checkstyle/checkstyle.xml")
}

checkstyleMain {
Expand All @@ -84,14 +86,14 @@ checkstyleTest {
pmdMain {
ignoreFailures = false
ruleSets = []
ruleSetFiles = files("${project.projectDir}/config/pmd/pmd-ruleset.xml")
ruleSetFiles = files("${rootDir}/config/pmd/pmd-ruleset.xml")
excludes = ['BeanMembersShouldSerialize', 'LoosePackageCoupling']
}

pmdTest {
ignoreFailures = true
ruleSets = []
ruleSetFiles = files("${project.projectDir}/config/pmd/pmd-ruleset.xml")
ruleSetFiles = files("${rootDir}/config/pmd/pmd-ruleset.xml")
excludes = ['BeanMembersShouldSerialize', 'LoosePackageCoupling']
}

Expand All @@ -117,6 +119,23 @@ jacocoTestCoverageVerification {
}
}
}

jacocoTestReport {
dependsOn test
reports {
xml.required.set(true)
xml.outputLocation.set(file("$rootDir/build/customJacocoReportDir/jacocoTestReport.xml"))
csv.required.set(false)
html.required.set(true)
html.outputLocation.set(file("$rootDir/build/customJacocoReportDir/html"))
}
}

task cleanTopBuild(type: Delete) {
delete "$rootDir/build"
}


spotbugsMain {
ignoreFailures = false
dependsOn compileJava
Expand Down
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading

0 comments on commit f0fb937

Please sign in to comment.