Skip to content
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
66 changes: 66 additions & 0 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Java Tests

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

defaults:
run:
working-directory: java-example

jobs:
test:
name: JUnit 5 + JaCoCo Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
cache: "maven"

- name: Run tests with coverage
run: mvn clean verify -Dmaven.test.failure.ignore=true

# Upload JUnit test results to Gaffer
# Skip on Dependabot PRs (no access to secrets)
- name: Upload JUnit results to Gaffer
if: always() && github.actor != 'dependabot[bot]'
uses: gaffer-sh/gaffer-uploader@v0.4.0
with:
gaffer_upload_token: ${{ secrets.GAFFER_UPLOAD_TOKEN }}
report_path: java-example/target/surefire-reports/
commit_sha: ${{ github.event.pull_request.head.sha || github.sha }}
branch: ${{ github.head_ref || github.ref_name }}
test_framework: junit
test_suite: junit-results

# Upload JaCoCo coverage to Gaffer
- name: Upload JaCoCo coverage to Gaffer
if: always() && github.actor != 'dependabot[bot]'
uses: gaffer-sh/gaffer-uploader@v0.4.0
with:
gaffer_upload_token: ${{ secrets.GAFFER_UPLOAD_TOKEN }}
report_path: java-example/target/site/jacoco/jacoco.xml
commit_sha: ${{ github.event.pull_request.head.sha || github.sha }}
branch: ${{ github.head_ref || github.ref_name }}
test_framework: junit
test_suite: jacoco-coverage

# Store artifacts for parser development
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: java-reports-${{ github.sha }}
path: |
java-example/target/surefire-reports/
java-example/target/site/jacoco/
retention-days: 7
86 changes: 86 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: PHPUnit Tests

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

defaults:
run:
working-directory: php-example

jobs:
test:
name: PHPUnit + Clover Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
coverage: pcov
tools: composer:v2

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('php-example/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Create reports directory
run: mkdir -p reports

- name: Run tests with coverage
run: |
vendor/bin/phpunit \
--coverage-clover reports/clover.xml \
--coverage-html reports/htmlcov \
--log-junit reports/phpunit-results.xml
continue-on-error: true

# Upload PHPUnit test results to Gaffer
# Skip on Dependabot PRs (no access to secrets)
- name: Upload PHPUnit results to Gaffer
if: always() && github.actor != 'dependabot[bot]'
uses: gaffer-sh/gaffer-uploader@v0.4.0
with:
gaffer_upload_token: ${{ secrets.GAFFER_UPLOAD_TOKEN }}
report_path: php-example/reports/phpunit-results.xml
commit_sha: ${{ github.event.pull_request.head.sha || github.sha }}
branch: ${{ github.head_ref || github.ref_name }}
test_framework: phpunit
test_suite: phpunit-results

# Upload Clover coverage to Gaffer
- name: Upload Clover coverage to Gaffer
if: always() && github.actor != 'dependabot[bot]'
uses: gaffer-sh/gaffer-uploader@v0.4.0
with:
gaffer_upload_token: ${{ secrets.GAFFER_UPLOAD_TOKEN }}
report_path: php-example/reports/clover.xml
commit_sha: ${{ github.event.pull_request.head.sha || github.sha }}
branch: ${{ github.head_ref || github.ref_name }}
test_framework: phpunit
test_suite: phpunit-coverage

# Store artifacts for parser development
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: phpunit-reports-${{ github.sha }}
path: php-example/reports/
retention-days: 7
24 changes: 21 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ jobs:
- name: Create reports directory
run: mkdir -p reports

- name: Run tests with HTML output
run: pytest --html=reports/pytest-report.html --self-contained-html
- name: Run tests with HTML output and coverage
run: |
pytest \
--html=reports/pytest-report.html \
--self-contained-html \
--cov=src \
--cov-report=xml:reports/coverage.xml \
--cov-report=html:reports/htmlcov
continue-on-error: true

# Upload via GitHub Action (recommended)
Expand All @@ -49,6 +55,18 @@ jobs:
test_framework: pytest
test_suite: pytest-html

# Upload Cobertura coverage report
- name: Upload coverage to Gaffer
if: always() && github.actor != 'dependabot[bot]'
uses: gaffer-sh/gaffer-uploader@v0.4.0
with:
gaffer_upload_token: ${{ secrets.GAFFER_UPLOAD_TOKEN }}
report_path: pytest-example/reports/coverage.xml
commit_sha: ${{ github.event.pull_request.head.sha || github.sha }}
branch: ${{ github.head_ref || github.ref_name }}
test_framework: pytest
test_suite: pytest-coverage

# Alternative: Upload via curl (for documentation/reference)
# - name: Upload via curl (example)
# if: always() && github.actor != 'dependabot[bot]'
Expand All @@ -71,4 +89,4 @@ jobs:
with:
name: pytest-reports-${{ github.sha }}
path: pytest-example/reports/
retention-days: 30
retention-days: 7
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Example test projects demonstrating [Gaffer](https://gaffer.sh) integration for various test frameworks.

Parser Check: December 25 2025 - 1:10PM - Merry Christmas
Parser Check: January 22 2026 - 8:16am

## Examples

Expand Down
22 changes: 22 additions & 0 deletions java-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar

# IDE
.idea/
*.iml
*.ipr
*.iws
.project
.classpath
.settings/
.vscode/
*.swp
46 changes: 46 additions & 0 deletions java-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Java Example (JUnit 5 + JaCoCo Coverage)

This example demonstrates how to integrate Gaffer with JUnit 5 test reports and JaCoCo coverage reports.

## Overview

This project uses:
- **JUnit 5** (Jupiter) for testing
- **JaCoCo** for code coverage
- **Maven** as the build tool

## Requirements

- Java 17+
- Maven 3.8+

## Local Development

```bash
# Run tests with coverage
mvn clean test

# View coverage report
open target/site/jacoco/index.html
```

## Test Reports

After running tests, reports are generated in:
- `target/surefire-reports/*.xml` - JUnit XML test results
- `target/site/jacoco/jacoco.xml` - JaCoCo coverage XML
- `target/site/jacoco/index.html` - HTML coverage report

## CI Integration

The GitHub Actions workflow (`.github/workflows/java.yml`):
1. Runs Maven test with JaCoCo coverage
2. Generates JUnit test results and JaCoCo coverage
3. Uploads both reports to Gaffer

## Coverage Formats

JaCoCo generates multiple formats:
- **JaCoCo XML** - Parsed by Gaffer for coverage metrics
- **JaCoCo CSV** - Machine-readable summary
- **HTML** - Human-readable coverage browser
85 changes: 85 additions & 0 deletions java-example/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>

<groupId>com.example</groupId>
<artifactId>gaffer-java-example</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>Gaffer Java Example</name>
<description>Gaffer JUnit 5 example with JaCoCo coverage reporting</description>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.10.2</junit.version>
<jacoco.version>0.8.12</jacoco.version>
</properties>

<dependencies>
<!-- JUnit 5 -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<!-- Compiler Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>

<!-- Surefire Plugin (for running tests) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<!-- Generate JUnit XML reports -->
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
</configuration>
</plugin>

<!-- JaCoCo Plugin (for coverage) -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<!-- Prepare agent for coverage collection -->
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- Generate coverage report after tests -->
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/site/jacoco</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading
Loading